Open mkabatek opened 1 year ago
Did you figure this out after all?
I am curious to know if you, @mkabatek, have found a solution, or if you still require assistance.
Allow me to share my findings on this matter:
also "defaultSortAsc" is working as I checked it at my side. so may be if you update your version then it can resolve error.
I hope this clarification resolves any doubts you may have
Yeh, just to add to this, I have had no issues with default sort, my rough implementation below:
const dateSort = (rowA, rowB) => {
const a = new Date(rowA.id);
const b = new Date(rowB.id);
if (a > b) {
return 1;
}
if (b > a) {
return -1;
}
return 0;
};
const columns = [
{
name: 'Date',
selector: row => row.date,
format: row => format(row.date, "MMM yy"),
sortable: true,
sortField: 'id',
sortFunction: dateSort
},
{
name: 'Amount',
selector: row => row.amount,
},
];
<DataTable title="By Month" columns={columns} data={rows} progressPending={pending}
defaultSortFieldId={1} defaultSortAsc={false}
progressComponent={<Spinner animation="border" role="status" size="m"> </Spinner>} pagination />
Hello,
I have some simple columns defined like this:
However for the life of me I cannot get the default sort to work when the table loads:
If I'm sorting by name which is my first column - setting
defaultSortAsc={true}
ordefaultSortAsc={false}
changes nothing. Same thing for date. I have tried using the unique ids, but it simply not working. I feel like this is a bug, however I'm unsure. Any help is appreciated.