populate data grid and keep the hilite state of checkboxes

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

populate data grid and keep the hilite state of checkboxes

Post by keram » Mon Feb 17, 2014 11:18 am

Hello,

In the attached stack I have text lines belonging to 3 categories that can be selected with 3 checkboxes.
After selecting the categories when you click the button 'Lines of Selected Categories' the data grid should populate with the lines in selected categories.
However it does not as it is now.

If I disable the line 'set the hilite of btn "BtnCheck" of me to pDataArray["BtnCheck"]' in the 'FillInData pDataArray' handler in the button 'Behavior Scrip' then the data grid gets populated and I get everything, but the checkboxes do not hold the hilite states, i.e when I click on 'Wrap o/x' button the selections disappear.

How to correct the code to populate the dg and have the checkboxes maintain the hilite state?

keram
Attachments
DG Form-categories card.zip
(14.37 KiB) Downloaded 197 times
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: populate data grid and keep the hilite state of checkbox

Post by Zryip TheSlug » Mon Feb 17, 2014 11:21 pm

Hi Keram,

When you are preparing the data for populating the datagrid, you are omitting the second column of your group named "data".

Your code should be:

Code: Select all

   repeat for each line i in AllLines
      if item 3 of i is among items of gMyCategories then put item 1 of i &tab& item 2 of i & tab & \ 
            item 3 of i &tab& item 4 of i &cr after LinesInMyCategories  --lines in selected categories
   end repeat
You have to store the state of the checkboxes in the second column of your "data" group to have them revert back when you are populating the datagrid.



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: populate data grid and keep the hilite state of checkbox

Post by keram » Tue Feb 18, 2014 4:34 am

Hi TheSlug,

Thanks for your help! It works OK now :D
(Yes, I missed that item... :oops: )

Now I have increased the number of lines to over 600.
Is there any way to make the refreshing of the view and the toggling of the wrapping of the grid more speedy?

I'm attaching the corrected stack with 640 lines.

keram
Attachments
DG Form-categories card2.zip
(20.26 KiB) Downloaded 205 times
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: populate data grid and keep the hilite state of checkbox

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

Now I have increased the number of lines to over 600.
Is there any way to make the refreshing of the view and the toggling of the wrapping of the grid more speedy?
I done a quick test, and drawing the datagrid is just immediate for me.

However you can try this:
- adding a "lock screen" before to change the wrap:

Code: Select all

on mouseUp  --toggle dontWrap t/f
   local tNewSetting, tRowTemplateRef
   
   lock screen
   
   put not the dgProp["fixed row height"] of grp "DataGrid 1" into tNewSetting
   set the dgProp["fixed row height"] of grp "DataGrid 1" to tNewSetting  --toggle t/f fixed line height
   put the dgProp["row template"] of grp "DataGrid 1" into tRowTemplateRef
   set the dontWrap of fld "Label" of tRowTemplateRef to tNewSetting
   
   set the dgVScroll of grp "DataGrid 1" to 0 --top
   send "ResetList" to grp "DataGrid 1" --update changes
   
   unlock screen
end mouseUp
- having a look to the following lesson:
http://lessons.runrev.com/s/lessons/m/d ... t-is-false


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: populate data grid and keep the hilite state of checkbox

Post by keram » Wed Feb 19, 2014 2:02 am

Thanks again TheSlug,

Great tip!
Zryip TheSlug wrote:and drawing the datagrid is just immediate for me
Perhaps your computer is faster. In my case there some noticeable improvement. Without the 'lock screen' it would expand in 2 steps:

this is no-wrapping view:
1.png

this is first stage when I click on Wrap button - it's visible just for a fraction of second:
2.png
2.png (10.5 KiB) Viewed 3816 times

and this is when the lines are wrapping:
3.png
3.png (11.05 KiB) Viewed 3816 times
So it's quite a difference.

keram
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

Post Reply