Skip to content

Commit

Permalink
[docs] Add warning clarifications (#5399)
Browse files Browse the repository at this point in the history
* [docs] Add warning clarifications

* fix

* try to clarify examples
  • Loading branch information
alexfauquette committed Jul 25, 2022
1 parent 69fbaab commit 06bd76e
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions docs/data/data-grid/row-grouping/row-grouping.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ For instance if you group by `"director"`, you will have two columns titled _Dir
To automatically hide the grouped columns, use the `useKeepGroupedColumnsHidden` utility hook.
The hook will automatically hide the columns when added to the model and show them back when removed from it.

:::warning
This hook is not compatible with the deprecated column property `hide`.

You can manage column visibility with `columnVisibilityModel`, `initialState`, or both together.
To do so, pass them to the hook parameters.
:::

Bellow are two examples about how to use `columnVisibilityModel` or `initialState` with `useKeepGroupedColumnsHidden` hook.
You can mix the two examples to support both at the same time.

```tsx
// Usage with the initial state
const apiRef = useGridApiRef();
Expand Down Expand Up @@ -123,12 +133,6 @@ const [rowGroupingModel, setRowGroupingModel] = React.useState([
const initialState = useKeepGroupedColumnsHidden({
apiRef,
rowGroupingModel,
initialState: {
columns: {
// Other hidden columns
columnVisibilityModel: { gross: false },
},
},
});

return (
Expand All @@ -141,12 +145,6 @@ return (
);
```

:::warning
This hook is only compatible with the deprecated column property `hide` or with the controlled `columnVisibilityModel` prop.

You must use the `columnVisibilityModel` in the `initialState` instead.
:::

{{"demo": "RowGroupingUseKeepGroupedColumnsHidden.js", "bg": "inline", "defaultCodeOpen": false}}

## Disable the row grouping
Expand Down

0 comments on commit 06bd76e

Please sign in to comment.