how to auto refresh favorites selection in data grid

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

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

how to auto refresh favorites selection in data grid

Post by keram » Wed Jan 14, 2015 2:51 am

Hello,

I moved this post from Beginners section to this one since no one there could offer any help. I've noticed there are more questions related to Data Grid in this section so hopefully someone can answer the following.

I have a display of a number of text lines using a data grid with a checkbox. When displaying the favorites I want them to automatically be refreshed when any of the favorites are disselected.
Right now I can refresh the display by using the 'favorites' button but I would like it to happen without having to click on that button (on the 2nd card).

I tried to put the 'refreshFavorites' command (see the code on the stack level) into the Data Grid Row Behavior button (see the code below) but it does not work.

Code: Select all

on mouseUp pMouseBtnNum  --user click
   set the itemDel to tab
   if pMouseBtnNum = "1" then  --left click
      if the short name of target() = "BtnCheck" then   --do something when checkbox is clicked
         SetDataOfLine the dgLine of me,"BtnCheck",the hilite of target()  --checkbox t/f
         put the dgDataOfLine[the dgHilitedLines of me] of me into TheData  --array of line clicked
         put TheData["BtnCheck"] into item 2 of line (TheData["Num"]) of gMySelection
         
         refreshFavorites -- DOES NOT WORK!		
         
         put TheData["BtnCheck"] into item 2 of line (TheData["Num"]) of gAllLines
         set cMySelection of stack gPrefsFile to gMySelection
         
      end if
   end if
end mouseUp


Also this does not work:

Code: Select all

   on mouseUp pMouseBtnNum  --user click
   set the itemDel to tab
   if pMouseBtnNum = "1" then  --left click
      if the short name of target() = "BtnCheck" then   --do something when checkbox is clicked
         SetDataOfLine the dgLine of me,"BtnCheck",the hilite of target()  --checkbox t/f
         
         ## the lines below do not work!
         if text of fld "view" of cd "main" is "Favorites" then
            if the hilite of btn "BtnCheck" is false then
               refreshFavorites
            end if 
         end if
         ## the above lines do not work!
         
         put the dgDataOfLine[the dgHilitedLines of me] of me into TheData  --array of line clicked
         put TheData["BtnCheck"] into item 2 of line (TheData["Num"]) of gMySelection
         
         put TheData["BtnCheck"] into item 2 of line (TheData["Num"]) of gAllLines
         set cMySelection of stack gPrefsFile to gMySelection
         
      end if
   end if
   
end mouseUp

How to make it work properly?

To test it in the attached stack, select few quotes as favorites, then click on the button 'favorites' and then disselect some of them.

Thanks in advance for any help.

keram
Attachments
q_4forum.zip
(25.89 KiB) Downloaded 221 times
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

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

Re: how to auto refresh favorites selection in data grid

Post by keram » Wed Jan 21, 2015 3:32 am

Hi,

I've got it working OK, thanks to TerryL :D

Created another command, deleteFavorites which is identical with refreshFavorites except the 1 line: answer "Sorry, but you must select at least..." and that new command I have put in the Row Behavior of the data grid:

Code: Select all

on mouseUp pMouseBtnNum  --user click
   .....
......
         if the text of fld "view" = "Favorites" then send "deleteFavorites" to this stack in 0 secs  --delete unchecked
      end if
keram
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

Post Reply