GWT CellTable - Column Sorting is reset after ListDataProvider refresh

StackOverflow https://stackoverflow.com/questions/23434226

  •  14-07-2023
  •  | 
  •  

質問

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?

役に立ちましたか?

解決 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.

他のヒント

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>
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top