2011-12-27 125 views
2

現在我遇到了GWT中的Widget分頁問題。如何將Widget作爲單元格添加到單元格表中GWT

我正在使用Cell表格來顯示我的UI Binder類(例如:LocationView)的實例列表。 http://gwt.google.com/samples/Showcase/Showcase.html#!CwCellTable 這是CellTable的展示。

現在我想將我的小部件(UI Binder類)添加到表格的每個單元格中。它看起來在某種程度上是這樣 enter image description here

在這個單元表,每個單元是該小組件(LocationView - 一個UI粘結劑類):

enter image description here

所以,我怎麼能利用細胞表創建該表(我不使用網格視圖,因爲它不支持分頁)

或者如果我不能使用Cell表創建這個表,我可以使用它來支持pagnigation(如果LocationView的數量(你看到的圖標)超過6,它將跳轉到第2頁)。

謝謝你的幫助!

回答

2

要將小部件添加到單元格我使用自定義CellTableBuilder,併爲應包含小部件的單元格設置唯一的ID。 然後,我將該小部件附加到DOM並將其移動到單元格。

void addWidgetToCell(final String cellId, final Widget widget) { 
    Scheduler.get().scheduleDeferred(new ScheduledCommand() { 
     @Override 
     public void execute() { 
      Element cellElem = DOM.getElementById(cellId); 

      if (!widget.isAttached()) { 
       // attach the detail to DOM (cannot attach it directly to the cell, because it has existing parent widget) 
       RootPanel.get().add(widget); 
      } 
      // move detail element under the cell element 
      cellElem.appendChild(widget.getElement()); 
     } 
    }); 
} 
+0

您能否解釋scheduleDeferred調用的用法? – cellepo 2016-01-19 21:31:24

相關問題