Mui-datatables: Define Default Sorting

Created on 15 Nov 2018  路  8Comments  路  Source: gregnb/mui-datatables

Is there a way to define a default sort?

bug help wanted

Most helpful comment

@drdouglasghd I think you can do something like this:

const columns = [
{ name: 'ColA' },
{ name: 'ColB', options: { sortDirection: 'asc' } },
{ name: 'ColC' },
];

All 8 comments

What do you mean? a default sort order or a default sorting function?

I have an integer column, and I want the initial/default sort of the table to be on that column in asc order.

Is there a way to set a default sort... or maybe I pre-sort the data prior to passing it to the datatable?

@drdouglasghd I think you can do something like this:

const columns = [
{ name: 'ColA' },
{ name: 'ColB', options: { sortDirection: 'asc' } },
{ name: 'ColC' },
];

screenshot 2018-11-19 16 06 26

If we do that, it marks the column as sorted... but doesn't sort the data. So this works if your data is presorted in this order.

Can confirm it only appears sorted but isn't. This method doesn't call customSort method either.

That's correct. The method is not being called. Anyone want to take this up as PR?

This issue should be resolved

This issue should be resolved

Yup, works fine for me 馃憤

Was this page helpful?
0 / 5 - 0 ratings