Page 1 of 1

viewing selected lines in data grid

Posted: Tue Feb 18, 2014 11:38 am
by keram
Hi everybody,

I have another question about data grids.

In the attached stack Inserting the data into the dg works fine. Selecting the checkboxes and putting their hilite values into variable works also fine. But I'm not able to view the selected lines (click on the 'View Selections' button in the attached stack).

I'm using this code for the 'View Selections' button:
(gAllLines and gMySelection variables are created by the code in the Insert Data' button)

Code: Select all

global gAllLines,gMySelection,gMySelectedLineNrs

on mouseUp
   put empty into gMySelectedLineNrs
   set the itemDelimiter to tab
   local DataArray
   put "0" into Counter
   repeat for each line i in gMySelection
      if item 2 of i is true then
         put item 1 of i & tab after gMySelectedLineNrs 
         add 1 to Counter
      end if
   end repeat
   
   set the dgData of group "DataGrid 1" to empty
   put "0" into Counter
   repeat for each line i in gAllLines
      if item 1 of i is among the items of gMySelectedLineNrs then 
         put item 1 of i into DataArray[Counter]["Num"]
         put item 2 of i into DataArray[Counter]["BtnCheck"]
         put item 3 of i into DataArray[Counter]["Cat"]
         put item 4 of i into DataArray[Counter]["Label"]
         add 1 to Counter
      end if
   end repeat
   lock screen
   set the dgData of group "DataGrid 1" to DataArray
   send "RefreshList" to grp "DataGrid 1"  --update changes
   
end mouseUp
Any idea why the selected lines do not show up?

keram

Re: viewing selected lines in data grid

Posted: Tue Feb 18, 2014 1:17 pm
by Klaus
You obviously do not fill the variable "gAllLines" with any value, so it stays empty = no data in the end!

Re: viewing selected lines in data grid

Posted: Tue Feb 18, 2014 4:59 pm
by keram
Thanks again, Klaus! :)

How could i have missed that? :oops:

Also I had to change this line: put item 2 of i into DataArray[Counter]["BtnCheck"]
to this: put true into DataArray[Counter]["BtnCheck"]
so that the hilites of all the checkboxes stay there.

But now when I view the selected lines and click on the 'Wrap' button then the 1st line disappears (???), only the checkbox is visible (see the attached, corrected stack).

Any idea how to fix that?

keram

Re: viewing selected lines in data grid

Posted: Tue Feb 18, 2014 5:06 pm
by Klaus
Hi keram,
keram wrote:But now when I view the selected lines and click on the 'Wrap' button then the 1st line disappears (???), only the checkbox is visible (see the attached, corrected stack).
I do not see this here!?
All lines visible with text!

But LC complained about a stack already being in memory, even after I restarted LC!? :shock:


Best

Klaus

Re: viewing selected lines in data grid

Posted: Tue Feb 18, 2014 5:13 pm
by keram
Hi Klaus,

Thanks for looking into that.
Klaus wrote:I do not see this here!?
All lines visible with text!
When you open the stack click on buttons in this order:
1.Insert Data
2. select few checkboxes
3. View Selections
4. Wrap o/x

then the 1st line disappears.
Klaus wrote:But LC complained about a stack already being in memory, even after I restarted LC!?
Strange, the 'Purge stack on close' is set on.

keram

Re: viewing selected lines in data grid

Posted: Tue Feb 18, 2014 5:27 pm
by Klaus
Ahm yes, I see!

BUT the line did not diappear, scroll the dg up and down a couple of time et voila: the first line will appear! :D
But only in "expanded" mode!?

Sorry, no idea what's going on there, I neve modified the template stuff "live" 8)


Best

Klaus

Re: viewing selected lines in data grid

Posted: Tue Feb 18, 2014 5:35 pm
by keram
Yes, scrolling helps, also in compacted mode.
Klaus wrote:Sorry, no idea what's going on there, I neve modified the template stuff "live"
I know what you are often saying about data grids - 'they are beasts'! Complicated.

Well, we need the help from TheSlug -super expert on data grids :) Hello TheSlug, are you there?? Help, please!

keram

Re: viewing selected lines in data grid

Posted: Tue Feb 18, 2014 8:16 pm
by Zryip TheSlug
Hi Keram,

No datagrid expert here. In your "View selections" button you are starting your counter by 0, so the index for the first array item is 0.

Code: Select all

   set the dgData of group "DataGrid 1" to empty
   put 1 into Counter -- the error was here
   repeat for each line i in gAllLines
      if item 1 of i is among the items of gMySelectedLineNrs then 
         put item 1 of i into DataArray[Counter]["Num"]
         put true into DataArray[Counter]["BtnCheck"]
         put item 3 of i into DataArray[Counter]["Cat"]
         put item 4 of i into DataArray[Counter]["Label"]
         add 1 to Counter
      end if
   end repeat

Best,

Re: viewing selected lines in data grid

Posted: Wed Feb 19, 2014 1:48 am
by keram
Hi TheSlug,

Thanks a lot! It works perfectly now :D
Zryip TheSlug wrote:No datagrid expert here.
Yes, you are here, fortunately :D , and you are an expert in dg (!) because only and expert could have created Data Grid Helper. Some time when I get the LC Commercial version I'll get it.

keram

Re: viewing selected lines in data grid

Posted: Thu Feb 20, 2014 12:18 am
by Zryip TheSlug
Hi Keram,
and you are an expert in dg (!) because only and expert could have created Data Grid Helper
Okay, I have probably to assume to be close of this "dg expert state", but most of all I'm always happy to help with datagrids when I can. ;)

Some time when I get the LC Commercial version I'll get it.
I have the plan to have a DGH version available for the community edition for the middle of this year, but I've not started to work on it. Fighting against MS Excel is actually taking all my free LiveCode time. :)



Best,