mark
mark

Reputation: 222

how to refresh the favorites selection automatically in data grid

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.

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:

   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?

The stack can be downloaded here

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

Upvotes: 0

Views: 158

Answers (1)

mark
mark

Reputation: 222

I've got it working OK, thanks to TerryL on LC Forum

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:

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

Upvotes: 0

Related Questions