You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to sort the "status field" in such a way that only numeric values are sorted, while blank values remain unchanged and are always placed at the end.
Like this:
asc [2,'',4,'',3] => [2,3,4,'','']
desc [2,'',4,'',3] => [4,3,2,'','']
false [2,'',4,'',3] = [2,'',4,'',3]
I tried handling the data manually outside, meaning rearranging the array manually. However, this causes an issue as column.getIsSorted() cannot retrieve the sorted status.
I hope to achieve this functionality with as little modification as possible or minimal changes to the DataTable component.
I've looked at the documentation for the tanstack table, such as the usage of sortingFn, but I still can't figure out the correct approach to achieve this.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
How to implement custom asc and desc sorting?
I want to sort the "status field" in such a way that only numeric values are sorted, while blank values remain unchanged and are always placed at the end.
Like this:
asc [2,'',4,'',3] => [2,3,4,'','']
desc [2,'',4,'',3] => [4,3,2,'','']
false [2,'',4,'',3] = [2,'',4,'',3]
I tried handling the data manually outside, meaning rearranging the array manually. However, this causes an issue as column.getIsSorted() cannot retrieve the sorted status.
I hope to achieve this functionality with as little modification as possible or minimal changes to the DataTable component.
I've looked at the documentation for the tanstack table, such as the usage of sortingFn, but I still can't figure out the correct approach to achieve this.
Here's my code:
Beta Was this translation helpful? Give feedback.
All reactions