2012-02-23 58 views
1

我正在使用一個網格來選擇項目,而另一個網格用於顯示所選項目。我在更新新網格時遇到問題。EXT GWT將選定項目綁定到新的空網格

在僞代碼:

selectionGrid = new Grid(); 

selectionGrid.addlistener(new listener { 
    update(); 
}); 

void update() { 

targetGrid = new Grid(selectionGrid.getstore().getselecteditems(), columns); 
} 

我能更新targetgrid的第一次,但有麻煩了新的選擇之後再進行更新。

有沒有不同的方式,我應該這樣做?

謝謝。

回答

1

這幾乎是 - 使兩個網格,其中一個與原始項目,另一個與空的ListStore。更新電話應該爲store.addAll(selected),但可能首先是store.clear()

這些方法假定GXT 3 - 在GXT 2中,我認爲它是store.add(selected)store.removeAll()。在2中,您還可能發現Events.SelectionChange未被Grid觸發,而是被SelectionModel - 閱讀javadoc以確定每個類觸發了什麼事件。在GXT 3中,通過公開的HasSelectionHandlers接口可以明確事件,表明您可以爲選擇事件添加處理程序。

如果這仍然不起作用,請考慮發佈一個幾乎可行的示例來展示您嘗試過的內容。

+0

完美工作。非常感謝! – rcheuk 2012-02-23 16:29:28

相關問題