我制作的堆栈显示分类的文本行。我制作了一张卡片来选择将它们放入变量并填充数据网格表单的类别,但填充“我的类别”的数据网格的代码不起作用:
以下是填充表单的代码:
global gAllLines,gSelectedCategories,gMyCategories
on mouseUp
put empty into gAllLines
put fld "alllines" of cd "settings_files" of stack "settingsandfiles" into gAllLines
put empty into gMyCategories
repeat for each line i in gAllLines
if item 2 of i is among the items of gSelectedCategories then put i & cr after gMyCategories
end repeat
set the dgText of group "mycategories_compact" to gMyCategories
end mouseUp
堆栈的下载链接(目前最好的工作,但仍然不是100%OK)是:
https://dl.dropboxusercontent.com/u/99863601/Data%20grid%20Form_All%20Lines%20Categories%20Selections3.zip
请让我知道如何解决它。
提前谢谢。
keram
答案 0 :(得分:1)
问题是你有两个不同的itemDelimiters。当您的gSelectedCategories以逗号分隔时,您的字段“alllines”具有制表符分隔的数据。尝试:
global gAllLines,gSelectedCategories,gMyCategories
on mouseUp
put empty into gAllLines
put fld "alllines" of cd "settings_files" of stack "settingsandfiles" into gAllLines
put empty into gMyCategories
replace comma with tab in gSelectedCategories
set the itemDelimiter to tab
repeat for each line i in gAllLines
if item 2 of i is among the items of gSelectedCategories then put i & cr after gMyCategories
end repeat
set the dgText of group "mycategories_compact" to gMyCategories
end mouseUp
修改
我从不使用dgText所以我不确定为什么购买这个datagrid似乎不再接受dgText [“firstLineContainsColumnNames”]。所以对我来说,逻辑解决方案是使用dgData:
global gAllLines,gSelectedCategories,gMyCategories
on mouseUp
set the dgData of group "mycategories_compact" to empty
put empty into gMyCategories
replace comma with tab in gSelectedCategories
set the itemDelimiter to tab
local tIndex = 1,tDataA
repeat for each line i in gAllLines
if item 2 of i is among the items of gSelectedCategories then
put item 1 of i into tDataA[tIndex]["Text"]
put item 2 of i into tDataA[tIndex]["Category"]
add 1 to tIndex
end if
end repeat
set the dgData of group "mycategories_compact" to tDataA
end mouseUp
答案 1 :(得分:0)
我没有看过你的堆栈,但处理程序的工作正常。也就是说,全局变量" gSelectedCategories"如果其中一个复选框按钮的名称中包含您正在检查的单词之一,那么您是否加载了什么?
克雷格纽曼