How to sort the data by clicking column (not only text or icon)
I would like to ask how to sort the data by clicking column?
it is because data cannot be sorted when I click the column (not on column text or icon).
Thanks.
give all datas to material table. It can handle sort
also if your column is numbers dont forget to give type: 'numeric' that column.
column must be like this;
columns={[
{ title: 'Birth Year', field: 'birthYear', type: 'numeric' },
]}
you must add sorting:true to material table options
options={{
sorting: true
}}
If customized render function returns react components, sorting may not work. In this case you should set column.customSort like
columns={[
{
title: 'Birth Year',
render: (row) => (<span class="birthYear">{row.birthYear}</span>),
customSort: (a, b) => a.birthYear - b.birthYear
},
]}
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You can reopen it if it required.