I have a list of column definitions, where I want to update one of them to allow for sorting in a particular way.
I can not get it to work. The propert plans in the data is a boolean. The column definition for "plans" looks like this after my code underneath has been run:
accessor: "plans" canSort: true header: "plans" sequence: 0 sortType: ƒ boolSort(rowA, rowB, columnId) type: "string"
Here is my go at it
let newCols = columns;
if (columns.length > 0) {
const filteredCols = columns.filter(c => c.accessor !== "plans");
const boolSort = (rowA, rowB, columnId) => {
const a = rowA.values[columnId].toString();
const b = rowB.values[columnId].toString();
return a > b ? 1 : -1;
};
const change = columns.find(c => c.accessor === "plans");
if (change) {
change.canSort = true;
change.sortType = boolSort;
newCols = [...filteredCols, change];
}
Why does the sorting not work for this column now?
"react-table": "^7.0.0-beta.15",