From 4b842703dbeb5306fef5c804bc5366e52fa830a0 Mon Sep 17 00:00:00 2001 From: Sergio Rene Tapia-Fikes <47071119+Sergio16T@users.noreply.github.com> Date: Thu, 18 Jul 2024 07:06:05 -0500 Subject: [PATCH] fix(useDataGrid): overide DataGridPropsType onFilterModelChange (#6151) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Ali Emir Şen --- .changeset/fast-hounds-guess.md | 9 +++++++++ .../material-ui/hooks/use-data-grid/index.md | 4 ++-- packages/mui/src/hooks/useDataGrid/index.ts | 6 +++++- 3 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 .changeset/fast-hounds-guess.md diff --git a/.changeset/fast-hounds-guess.md b/.changeset/fast-hounds-guess.md new file mode 100644 index 000000000000..f548f66278d2 --- /dev/null +++ b/.changeset/fast-hounds-guess.md @@ -0,0 +1,9 @@ +--- +"@refinedev/mui": patch +--- + +fix(use-data-grid): incompatible types when using data-grid-pro + +useDataGrid overide DataGridPropsType onFilterModelChange. + +[Fixes #5997](https://github.com/refinedev/refine/issues/5997) diff --git a/documentation/docs/ui-integrations/material-ui/hooks/use-data-grid/index.md b/documentation/docs/ui-integrations/material-ui/hooks/use-data-grid/index.md index 8209096cf6d7..89293ba625f7 100644 --- a/documentation/docs/ui-integrations/material-ui/hooks/use-data-grid/index.md +++ b/documentation/docs/ui-integrations/material-ui/hooks/use-data-grid/index.md @@ -786,8 +786,8 @@ When the user filters a column, this function is called with the new filter mode {...dataGridProps} columns={columns} autoHeight - onFilterModelChange={(model, details) => { - dataGridProps.onFilterModelChange(model, details); + onFilterModelChange={(model) => { + dataGridProps.onFilterModelChange(model); // do something else }} /> diff --git a/packages/mui/src/hooks/useDataGrid/index.ts b/packages/mui/src/hooks/useDataGrid/index.ts index a6c0f561cc06..730b509ec2fe 100644 --- a/packages/mui/src/hooks/useDataGrid/index.ts +++ b/packages/mui/src/hooks/useDataGrid/index.ts @@ -33,9 +33,13 @@ import { transformSortModelToCrudSorting, } from "@definitions"; +type DataGridPropsOverride = Omit & { + onFilterModelChange: (model: GridFilterModel) => void; +}; + type DataGridPropsType = Required< Pick< - DataGridProps, + DataGridPropsOverride, | "rows" | "loading" | "rowCount"