I want to create a CellTable. But Columns of the celltable should be based on the response from the server. I'm getting the server response as List.
No of Columns = Size of the list.
CellTable column header should be the value from the server. For ex. Server response:
List<Contacts> contacts
Header should be
contacts.getName()
.
How to create CellTable based on the response from the server
426 views Asked by Gnik At
2
There are 2 answers
2
On
Use CellList
with an 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);
I achieved it by the following code.
Regards, Gnik