viewing selected lines in data grid

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

viewing selected lines in data grid

Post by keram » Tue Feb 18, 2014 11:38 am

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
Attachments
DG Form selection.zip
(19.49 KiB) Downloaded 171 times
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: viewing selected lines in data grid

Post by Klaus » Tue Feb 18, 2014 1:17 pm

You obviously do not fill the variable "gAllLines" with any value, so it stays empty = no data in the end!

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: viewing selected lines in data grid

Post by keram » Tue Feb 18, 2014 4:59 pm

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
Attachments
DG Form selection2.zip
(19.42 KiB) Downloaded 172 times
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: viewing selected lines in data grid

Post by Klaus » Tue Feb 18, 2014 5:06 pm

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

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: viewing selected lines in data grid

Post by keram » Tue Feb 18, 2014 5:13 pm

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
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: viewing selected lines in data grid

Post by Klaus » Tue Feb 18, 2014 5:27 pm

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

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: viewing selected lines in data grid

Post by keram » Tue Feb 18, 2014 5:35 pm

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
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

Zryip TheSlug
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 163
Joined: Tue Jan 26, 2010 10:15 pm
Contact:

Re: viewing selected lines in data grid

Post by Zryip TheSlug » Tue Feb 18, 2014 8:16 pm

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,
TheSlug
http://www.aslugontheroad.com - Tutorials, demo stacks and plugins for LiveCode
Data Grid Helper - An intuitive interface for building LiveCode's Data Grids
Excel Library- Extends the LiveCode language for controlling MS Excel

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: viewing selected lines in data grid

Post by keram » Wed Feb 19, 2014 1:48 am

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
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

Zryip TheSlug
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 163
Joined: Tue Jan 26, 2010 10:15 pm
Contact:

Re: viewing selected lines in data grid

Post by Zryip TheSlug » Thu Feb 20, 2014 12:18 am

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,
TheSlug
http://www.aslugontheroad.com - Tutorials, demo stacks and plugins for LiveCode
Data Grid Helper - An intuitive interface for building LiveCode's Data Grids
Excel Library- Extends the LiveCode language for controlling MS Excel

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”