sorting is not toggled properly when used with custom 'sortType' callback function
See original GitHub issueUsing v7
Hi there! First of all thanks for all your efforts in creating such a great library.
Bug Description I did encounter a rather strange problem with the latest version (v7.0.0-rc.16): when I use a custom function for sorting, the results are sorted for one direction only. P.S: same code works fine with v7.0.0-rc.15
Additional context here is the code for the custom sorting function
const sortHelper = ({
isAfter,
isBefore,
desc
}) => {
let order
if (isAfter) {
order = 1
} else if (isBefore) {
order = -1
} else {
order = 0
}
if (desc) {
return -order
} else {
return order
}
}
const sortString = (rowA, rowB, columnId, desc) => {
const stringA = rowA.values[columnId].trim().toLowerCase()
const stringB = rowB.values[columnId].trim().toLowerCase()
const isAfter = stringA > stringB
const isBefore = stringA < stringB
return sortHelper({
isAfter,
isBefore,
desc
})
}
here the code for the table component
const OverviewTable = (props) => {
const columns = [
{
Header: <span>{translate({ text: 'FIRSTNAME' }).text}</span>,
accessor: 'firstname',
sortType: sortString
},
{
Header: <span>{translate({ text: 'LASTNAME' }).text}</span>,
accessor: 'lastname',
sortType: sortString
}
]
const data = props.data
return (
<Table columns={columns} data={data} />
)
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
sorting is not toggled properly when used with custom ...
16): when I use a custom function for sorting, the results are sorted for one direction only. P.S: same code works fine with...
Read more >jqGrid with Custom sorttype - Stack Overflow
My suggestion to use index as a function for custom sorting of local ... be called when jqGrid is initialized and not the...
Read more >TableColumn (JavaFX 15)
Have a context menu when the user right-clicks the column header area; Have the contents of the table be sorted (using comparator ,...
Read more >TableColumn (JavaFX 2.2) - Oracle Help Center
Have the contents of the table be sorted (using comparator , sortable and sortType ). When creating a TableColumn instance, perhaps the two...
Read more >ParamQuery Grid Pro API Documentation for Version 8.x
Use toggle method to toggle the display state of grid dynamically. ... This is a callback function to customize sorting of pivot columns(v5.4.0)....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Sort Comparator function should return
-1 || 0 || 1
.Boolean will not work.
@mattstates, please ask your question in https://spectrum.chat/react-table 😃 Thanks!