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