2013-12-15 35 views
1

我製作的堆棧顯示分類的文本行。我做了一個卡,選擇類別把它們放在一個變量,並填充數據網格形式,而是用於填充了我的分類數據網格的代碼不起作用:用選定的類別填充數據網格表格

下面是用於填充表單代碼:

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%確定)是:
https://dl.dropboxusercontent.com/u/99863601/Data%20grid%20Form_All%20Lines%20Categories%20Selections3.zip

請讓我知道如何解決它。
在此先感謝。
keram

回答

1

問題是你有兩個不同的itemDelimiters。您的字段「alllines」使用製表符分隔的數據,而您的gSelectedCategories使用逗號分隔。嘗試:

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所以我不知道爲什麼買這個數據網格似乎不接受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 
+0

謝謝蒙特。我更改了itemDelimiter,現在gMyCategories正確顯示在msg框中,但是當我用它填充數據表單時,只有複選框在右側可見。使用gAllLines填充相同的表單而不是顯示所有行,所以很奇怪......以下是更正後的堆棧的鏈接:https://dl.dropboxusercontent.com/u/99863601/Data%20grid%20Form_All%20Lines%20Categories %20Selections3.zip – keram

+0

我添加了一個簡化的堆棧,其中包含相同的問題 - 可能會更容易跟蹤錯誤。儘管數據網格形式對於兩者都完全相同,但類別不會顯示,但所有行都會顯示。以下是測試堆棧的鏈接:https://dl.dropboxusercontent.com/u/99863601/TextLine%20Categories.zip – keram

+0

再次感謝!它很好。現在我必須把它放到我的主棧中。 – keram

0

我沒有看過你的堆棧,但處理程序工作得很好。也就是說,如果其中一個複選框按鈕的名稱中包含您正在檢查的單詞之一,則會加載全局變量「gSelectedCategories」,您沒有看到什麼?

克雷格紐曼

+0

如果我選擇的組的一個複選框,然後單擊在代碼編輯器應用按鈕,然後我得到一個錯誤,這條線:* *如果它的hilite然後**,說:**組「grpSelectCategories」:執行錯誤在行n/a(對象:對象沒有這個屬性)**。當然其餘的 - 填充數據網格 - 也不起作用。 – keram

+0

嗨克雷格,我設法做出更正,以便類別的選擇工作,但填充表單不起作用(請參閱上面的代碼和新的下載鏈接)。 – keram