0
我是GWT應用程序開發的初學者。我在網上搜索了CellTable。除了一些例子,沒有任何解釋。DataProvider在GWT中CellTable究竟做什麼
現在我真的很想知道DataProvider究竟在CellTable中做了什麼? 也想知道更多關於celltable,如果有任何資源可用於相同?
我是GWT應用程序開發的初學者。我在網上搜索了CellTable。除了一些例子,沒有任何解釋。DataProvider在GWT中CellTable究竟做什麼
現在我真的很想知道DataProvider究竟在CellTable中做了什麼? 也想知道更多關於celltable,如果有任何資源可用於相同?
該數據提供程序包含您的模型。 無論何時您更改模型(例如,映射到cellTable的對象列表),它都將負責更新顯示。
它充當顯示器(cellTable)和模型(即對象列表,通常是來自後端的共享對象列表)之間的控制器。
這是一個帶listdataprovider一個例子:
@UiField(provided = true)
protected CellTable<TableRowDataShared> cellTable;
protected ListDataProvider<TableRowDataShared> dataProvider = new ListDataProvider<TableRowDataShared>();
public void init() {
dataProvider.addDataDisplay(cellTable);
// init your cellTable here...
}
public void onModelUpdate(List<TableRowDataShared> newData) {
dataProvider.getList().clear();
dataProvider.getList().addAll(newData);
dataProvider.flush();
dataProvider.refresh();
cellTable.redraw();
}
很清楚。但是,在使用SimplePager實現分頁時,是否有必要使用DataProvider? –
好問題...如果您使用cellTable,則應使用數據提供程序。如果你正在使用cellList或其他東西,你可以設置自己的數據提供實現。 SimplePager會工作嗎?我想是這樣,因爲數據提供和分頁是分離的任務。使用分頁時,您只是顯示數據的不同部分,但數據保持不變,不是嗎?從本節http://www.gwtproject.org/doc/latest/DevGuideUiCellWidgets.html#Selection_Data_Paging – otonglet