Skip to content

Commit d4195bc

Browse files
committed
Add docs about hiddenColumns property of <DataTable>.
1 parent 048d39f commit d4195bc

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

docs/DataTable.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,25 @@ export const ReviewList = () => (
836836
);
837837
```
838838

839+
## `hiddenColumns`
840+
841+
By default, `<DataTable>` renders all `<DataTable.Col>` children. Use the `hiddenColumns` property to set hidden columns by default.
842+
843+
Using the `hiddenColumns` property instead of removing `<DataTable.Col>` elements entirely allows hidden columns to be displayed again using a `ColumnsButton`, as in [Hiding or Reordering](#hiding-or-reordering-columns) section.
844+
845+
```tsx
846+
const PostList = () => (
847+
<List actions={<PostListActions />}>
848+
<DataTable hiddenColumns={['id', 'author']}>
849+
<DataTable.Col source="id" />
850+
<DataTable.Col source="title" />
851+
<DataTable.Col source="author" />
852+
<DataTable.Col source="year" />
853+
</DataTable>
854+
</List>
855+
);
856+
```
857+
839858
## `size`
840859

841860
The `<DataTable>` is designed for a high content density, so the row padding is low. If you want to add more margin to each cell, set the `size` prop to `medium`.

0 commit comments

Comments
 (0)