T
TanStack•7mo ago
probable-pink

Stale sorting results

Hi all! I am having difficulty sorting the table based on row selection. I have created a custom SortingFn, which appears to work fine. It correctly sorts the rows ascending or descending as I toggle the sort direction. The problem is that if I change the row selection, the sorting table continues to sort based on the row selection when it was sorted for the first time. I have tried various memoizations depending on rowSelection, but the table shows the same final row model based on stale selection values. Sorting on other columns (that don't use a built-in sorting function) works as expected, which makes sense because those values are not dynamically changing. Any suggestion will be greatly appreciated! I've been pounding my head against this issue all afternoon. Thanks! 🙂
1 Reply
probable-pink
probable-pinkOP•7mo ago
I think I have found a solution: Use a global filtering function to place fresh metadata on each row and then use that metadata in the sorting function. The column value would still be cached in the row, but neither the sorting, filtering, nor rendering functions will look at that.

Did you find this page helpful?