The List component below has an importedUsers variable stored in an Inertia useRemember hook. Once the importedUser hook is triggered, the page reloads and the DataTable then selects/ checks the imported users via the rowSelectModel prop. I've used the SortCheckedAtTop prop to sort the rows based on the selected/ checked row but doesn't seem to be taking any effect. I've used the MUI documentation (https://mui.com/x/react-data-grid/sorting/#controlled-sort-model) for controlled sorting but didn't seem to help much.
import * as React from 'react';
import DataTable from '../../components/DataTable/DataTable'
import { useRemember } from '@inertiajs/inertia-react'
const List = ({users, visibleColumns, columns, pageSizes, }) => {
const [importedUsers, setimportedUsers] = useRemember(null, 'Users/Import')
return (
<div>
<DataTable
// initialState={{
// sorting: {
// sortModel: [{ field: 'created_at', sort: 'desc' }, ],
// },
// SortCheckedAtTop
// }}
data={users}
columns={columns}
visibleColumns={visibleColumns}
SortCheckedAtTop
rowSelectionModel={importedUsers?.map(item => item.id)}
/>
</div>
)
}
export default List
I've searched everywhere for a solution before posting here and gpt doesn't seem to know much either.I've managed to sort based on 'created at' and other fields. But can't seem to find out how to sort if a particular row is selected/ checked.
Thanks in advance!