Question

I'm using a CellTable, which is fed data via a ListDataProvider. Currently a user can sort the CellTable columns, then click a row. Clicking a row pops up a stand alone editor next to the cell table. When the user clicks "save", the code updates the employee in the ListDataProvider, then calls:

listDataProvider.refresh();

This works, but the column sort is reset. This is not acceptable because it resets the column sort that they have used, and it is a pain to have to resort the columns after every save. Is there some way to tell the CellTable to keep its current column sort when refresh is called?

Was it helpful?

Solution 2

Ended up adding a listener on the column sort, and sorted the list in code rather than allowing the CellTable to handle the sort. This kept the sort order. I'd post the code, but I no longer have access to the code base.

OTHER TIPS

Your need to call ColumnSortEvent.fire(dataGrid, dataGrid.getColumnSortList()); if you want to recover the sort order after refresh. I think it should work the same for CellTable.

This is how we refresh the DataGrid:

selectionModel.clear(); // SingleSelectionModel
dataList.clear(); // List<Data>
dataList.addAll(newData); // List<Data>
dataProvider.flush(); // ListDataProvider<Data>
dataProvider.refresh();
ColumnSortEvent.fire(dataGrid, dataGrid.getColumnSortList()); // DataGrid<Data>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top