如何在数据网格中自动刷新收藏夹选择

how to refresh the favorites selection automatically in data grid

我使用带有复选框的数据网格显示了许多文本行。在显示收藏夹时,我希望它们在任何收藏夹被取消select 时自动刷新。 现在我可以使用 'favorites' 按钮刷新显示,但我希望无需单击该按钮(在第二张卡片上)即可刷新显示。

我尝试将 'refreshFavorites' 命令(参见堆栈级别的代码)放入数据网格行行为按钮(参见下面的代码),但它不起作用。

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

这也行不通:

   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

如何让它正常工作?

堆栈可以下载here

为了测试它,select 收藏几行,然后单击按钮 'favorites' 然后取消 select 其中一些。

感谢 LC 论坛上的 TerryL,我让它工作正常

创建了另一个命令 deleteFavorites,它与 refreshFavorites 相同,除了第 1 行:回答 "Sorry, but you must select at least..." 和我在数据网格的行行为中放入的新命令:

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