Reputation: 2626
I have following code, which crates a cell table and adds SimplePager to it.
public class CellTableTestClass {
private VerticalPanel applicationPanel = new VerticalPanel();
private CellTable<Contact> cellTable = new CellTable<Contact>();
public VerticalPanel createContent() {
List<Contact> list=Arrays.asList(new Contact("John","123 Fourth Road"), new Contact("Mary", "222 Lancer Lane"), new Contact("Zander", "94 Road Street"), new Contact("Harry","303 Shakti"));
cellTable.addColumn(new TextColumn<Contact>() {
@Override
public String getValue(Contact object) {
return object.name;
}
}, "Log Name");
cellTable.addColumn(new TextColumn<Contact>() {
@Override
public String getValue(Contact object) {
return object.address;
}
}, "Size");
// create a pager, giving it a handle to the CellTable
SimplePager.Resources pagerResources =
GWT.create(SimplePager.Resources.class);
SimplePager pager = new SimplePager(TextLocation.CENTER,
pagerResources, true, 0, true);
pager.setDisplay(cellTable);
pager.setPageSize(2);
cellTable.setRowData(0,list);
cellTable.setRowCount(list.size());
// add the Pager to the dialog
applicationPanel.add(pager);
applicationPanel.add(new HTML("<hr />"));
applicationPanel.add(cellTable);
return applicationPanel;
}
}
When I click the next button of the pager it shows loading screen only. Can anyone point out the possible errors in the code??
Upvotes: 2
Views: 2865
Reputation: 539
Here is a simple example of CellTable, SimplePager and ListDataProvider.
CellTable<AlarmDisplayBTO> cellTable= new CellTable<AlarmDisplayBTO>();
TextColumn<AlarmDisplayBTO> dateColumn = new TextColumn<AlarmDisplayBTO>() {
@Override
public String getValue(AlarmDisplayBTO object) {
return object.getDate();
}
};
cellTable.addColumn(dateColumn, "Date");
TextColumn<AlarmDisplayBTO> alarmNameColumn = new TextColumn<AlarmDisplayBTO>() {
@Override
public String getValue(AlarmDisplayBTO object) {
return object.getAlarmName();
}
};
cellTable.addColumn(alarmNameColumn, "Alarm Name");
cellTable.setRowCount(alarmList.size());
// alarmList is an ArrayList<AlarmDisplayBTO> rendered from RPC call
cellTable.setRowData(0, alarmList);
cellTable.setEmptyTableWidget(new Label(" No Records Found"));
ListDataProvider<AlarmDisplayBTO> dataProvider = new ListDataProvider<AlarmDisplayBTO>();
dataProvider.addDataDisplay(cellTable);
dataProvider.setList(alarmList);
SimplePager pager = new SimplePager();
pager.setDisplay(cellTable);
pager.setPageSize(20); // 20 rows will be shown at a time
VerticalPanel vPanel = new VerticalPanel();
vPanel.add(cellTable);
vPanel.add(pager);
setWidget(new ScrollPanel(vPanel));
Hope this may help..
Upvotes: 2
Reputation: 3502
As mentionned here you should use a dataprovider when using a cellTable. If you don't want to you can use a cellList instead of a cellTable and use cellList.setRowData().
Upvotes: 1