2013-03-07 57 views

回答

4

回答我自己的問題,因爲它可能對他人有用。

將字段編輯器行爲按鈕從revDataGridLibrary堆棧複製到具有行模板的卡上。

編輯字段的腳本編輯如下(注意,你將需要修復的行爲按鈕參考作爲新的領域edtior行爲的長期ID):

on preOpenFieldEditor pEditor 
    set the behavior of pEditor to the long id of button id 1023 of card id 1010 of stack "Data Grid Templates 1362091650635" 
    set the uRowControl of pEditor to the long id of the owner of me 
end preOpenFieldEditor 

編輯字段編輯器行爲腳本中加入以下內容:

local sHeight,sRowControl 

setProp uRowControl pRowControl 
    put pRowControl into sRowControl 
end uRowControl 

on openField 
    put the formattedHeight of me into sHeight 
    pass openField 
end openField 

on textChanged 
    local tHeight,tRect 
    lock screen 
    put the formattedHeight of me into tHeight 
    if sHeight <> tHeight then 
     put the rect of me into tRect 
     put item 2 of tRect+ tHeight into item 4 of tRect 
     set the rect of me to tRect 
     put tHeight into sHeight 
     dispatch "UpdateRow" to sRowControl with the long id of me 
    end if 
    unlock screen 
    pass textChanged 
end textChanged 

現在編輯的行模板,行爲添加以下處理程序(注意,在這種情況下,現場正在編輯名爲「注意」,所以你會想改變您的使用情況) :

on UpdateRow pFieldEditor 
    set the rect of graphic "Background" of me to the rect of pFieldEditor 
    set the rect of fld "note" of me to the rect of pFieldEditor 
    set the rect of me to the formattedRect of me 
    put the uScriptLocal["sTableObjectsA"] of me into tTableObjectsA 
    repeat for each line tControl in tTableObjectsA["all row controls"] 
     delete word -2 to -1 of tControl -- of me 
     put tControl into tControlA[the dgIndex of tControl] 
    end repeat 
    put the bottomLeft of me into tTopLeft 
    repeat for each item tIndex in tTableObjectsA["current"]["indexes"] 
     if tIndex > the dgIndex of me then 
     set the topLeft of tControlA[tIndex] to tTopLeft 
     put the bottomLeft of tControlA[tIndex] into tTopLeft 
     end if 
    end repeat 
end UpdateRow 
0

看起來有用,蒙特。問題:爲什麼preOpenField處理程序?無法在設計時只設置一次該信息?每次調用編輯器時,DataGrid是否創建一個新的字段控件?

+0

我認爲它確實創造了飛行中的領域。無論哪種方式,編輯datagrid組內某個對象的屬性比動態設置屬性更爲複雜。 preOpenFieldEditor處理程序是設置字段編輯器屬性的文檔化方式。 – 2013-03-08 21:59:06