我想创建一个CellTable。但是,celltable的列应该基于服务器的响应。我将服务器响应作为List。
No of Columns = Size of the list.
CellTable列标题应该是服务器的值。
对于前者服务器响应:List<Contacts> contacts
标题应为contacts.getName()
。
答案 0 :(得分:1)
我通过以下代码实现了它。
for (Contacts contact : contacts) {
final String city = contact.getCity();
final TextColumn<String> addressColumn = new TextColumn<String>() {
@Override
public String getValue(Contacts object) {
return city;
}
};
cellTable.addColumn(addressColumn, contact.getAddress());
}
此致 Gnik
答案 1 :(得分:0)
将CellList
与AsyncDataProvider:
//Create a cellList
@UiField
CellList<Contact> cellList;
//Creating dataProvider and completion of the cellList
@UiFactory
CellList<Contact> makeCellList() {
private AsyncDataProvider<Contact> provider = new AsyncDataProvider<Contact>() {
@Override
public void onRangeChanged(final HasData<Contact> display) {
rpcService.getContact(new AsyncCallback<List<Contact>>() {
@Override
public void onSuccess(List<Contact> result) {
display.setRowData(0, result);
}
@Override
public void onFailure(Exception ex) {
//TODO
}
});
}
};
//Adding the cellList to the provider in a constructor
provider.addDataDisplay(cellList);