Skip to content

ColumnsButton

Lets the user choose the visible columns in a <DataTable>, and reorder them.

Use it in conjunction with a <DataTable> inside a <List>:

import { List, DataTable, EditButton, CreateButton, ExportButton, ColumnsButton } from '@/components/admin';
const PostsList = () => (
<List
actions={<>
<ColumnsButton />
<CreateButton />
<ExportButton />
</>}
>
<DataTable>
<DataTable.Col source="title" />
<DataTable.Col source="body" />
<DataTable.Col source="updated_at" />
<EditButton />
</DataTable>
</List>
);

It persists the user choices in the Store (usually in localStorage).

If yoa page has multiple <DataTable> components, use the storeKey prop to associate each button with its data table:

<List
actions={<>
<ColumnsButton storeKey="posts-list" />
<CreateButton />
<ExportButton />
</>}
>
<DataTable storeKey="posts-list">
...
</DataTable>
</List>
PropRequiredTypeDefaultDescription
iconOptionalReactNodeColumns iconCustom icon
labelOptionalstringra.action.columnsButton label key
resourceOptionalstringinferredResource name for i18n
storeKeyOptionalstring-Key for persisted column visibility state