primereact
primereact copied to clipboard
DataTable - Multiple sort won't work when any column has a sortFunction defined.
There is no guarantee in receiving an immediate response in GitHub Issue Tracker, If you'd like to secure our response, you may consider PrimeReact PRO Support where support is provided within 4 business hours
I'm submitting a ... (check one with "x")
[ x] bug report
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://forum.primefaces.org/viewforum.php?f=57
Codesandbox Case (Bug Reports) https://codesandbox.io/s/primereact-test-forked-bq3q5?file=/src/index.js
When multiple column sorting is used and a sortfunction is supplied for a column, multiple sort does not work.
Current behavior
-
Datatable is sorted by multiple columns but does not use custom sort function(s) defined if the first sort column has not a custom sort funtion.
-
Datatable is sorted by only the custom sort function of the first sort column if the first sort column has a custom sort funtion.
Expected behavior Datatable should be sorted by multiple columns whether sortfunction is defined for sort columns or not.
The problem is that the contract of the sortFunction does not allow us to do compare two rows of the data, instead we can only sort all the data. The Column component needs to have a propetry like compareFunction(data1, data2, sortOrder).
The problem is that the contract of the sortFunction does not allow us to do compare two rows of the data, instead we can only sort all the data. The Column component needs to have a propetry like compareFunction(data1, data2, sortOrder).
I agree that having a sort comparator function as mentioned above for the column would be much better and more flexible than the current sortFunction
approach. Even better IMO would be a simple sortCompator(row1, row2)
that takes 2 data rows and returns -1, 0, or 1
. primereact could handle the sortOrder
internally.