column-ordering
Users can customize the order of columns in their tables. The default order of columns is determined by the order in which they are defined in the column configuration.
When a user reorders columns, their preferences are saved in local storage so that the next time they visit the table, their custom column order is preserved.
Disable Column Ordering
You can disable column ordering entirely by setting tableOptions.enableColumnOrdering to false. When column ordering
is disabled, the grab handles in the columns dropdown and column headers are replaced with a lock icon.
<DataTable tableOptions={{ enableColumnOrdering: false }} />
Disable Column Reordering for Specific Columns
You can disable column reordering for specific columns by setting enableColumnReordering to false in the column
definition.
const columns: Columns<Cat> = [
{
accessorKey: 'name',
enableColumnReordering: false, // Disable reordering for this column
header: 'Name',
},
{
accessorKey: 'age',
enableColumnReordering: false, // Disable reordering for this column
header: 'Age',
},
]