I have a DataGrid which shows say Employee details. For example, every row corresponds to an employee(name, age, salary) and name+age are anchors and salary is plain-text.
Everything is working fine so far, but since the number of rows very high my browser starts to hang. So I decided to use pagination in my DataGrid. I did something like:
List<Employee> tableRowData = new ArrayList<Employee>();
DockPanel dock = new DockPanel();
empTable = new DataGrid<Employee>(tableRowData.size());
SimplePager pager = new SimplePager(TextLocation.CENTER);
pager.setDisplay(hotelsTable);
pager.setPageSize(25);
dock.add(empTable, DockPanel.CENTER);
dock.add(pager, DockPanel.SOUTH);
dock.setWidth("100%");
dock.setCellWidth(empTable, "100%");
dock.setCellWidth(pager, "100%");
empTable.setRowCount(1, true);
empTable.setRowData(0, tableRowData);
empTable.setStyleName(style.hotelTable());
empTable.setWidget(dock);
Now, my pager& table shows up fine with first 25 rows, but on clicking next on the pager Table body disappears and some loading bar shows up in the body forever.
I also read somewhere that paging can not be done without using DataProviders. Is it so?
I have seen the example of paging here. It looks easy but I get it messed up when use in my case. Any help is highly appreciated. Also I wish you can provide basic code to get me going.
Thanks, Mohit
I think you are missing ListProvider. In your case.You should try:
empTable = new DataGrid<Employee>(25);
ListDataProvider<Employee> provider = new ListDataProvider<Employee>(tableRowData);
provider.addDataDisplay(empTable);
.
.
.
//empTable.setRowCount(1, true);
//empTable.setRowData(0, tableRowData);
And add data by using provider.getList().add()
or something like this.