From 4cfc71143491db778a84426f7eee77e71f7801c6 Mon Sep 17 00:00:00 2001 From: Bilal Shafi Date: Fri, 25 Oct 2024 23:20:39 +0500 Subject: [PATCH] [DataGrid] Move `rowGroupingModelChange` handler to respective hook (#15124) --- .../src/hooks/features/rowGrouping/useGridRowGrouping.tsx | 3 +++ .../src/hooks/features/dataSource/useGridDataSource.ts | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/x-data-grid-premium/src/hooks/features/rowGrouping/useGridRowGrouping.tsx b/packages/x-data-grid-premium/src/hooks/features/rowGrouping/useGridRowGrouping.tsx index 24bff5926a7b..fe562ab900c3 100644 --- a/packages/x-data-grid-premium/src/hooks/features/rowGrouping/useGridRowGrouping.tsx +++ b/packages/x-data-grid-premium/src/hooks/features/rowGrouping/useGridRowGrouping.tsx @@ -284,6 +284,9 @@ export const useGridRowGrouping = ( useGridApiEventHandler(apiRef, 'cellKeyDown', handleCellKeyDown); useGridApiEventHandler(apiRef, 'columnsChange', checkGroupingColumnsModelDiff); useGridApiEventHandler(apiRef, 'rowGroupingModelChange', checkGroupingColumnsModelDiff); + useGridApiEventHandler(apiRef, 'rowGroupingModelChange', () => + apiRef.current.unstable_dataSource.fetchRows(), + ); /* * EFFECTS diff --git a/packages/x-data-grid-pro/src/hooks/features/dataSource/useGridDataSource.ts b/packages/x-data-grid-pro/src/hooks/features/dataSource/useGridDataSource.ts index 63e042a84126..31f3d209a695 100644 --- a/packages/x-data-grid-pro/src/hooks/features/dataSource/useGridDataSource.ts +++ b/packages/x-data-grid-pro/src/hooks/features/dataSource/useGridDataSource.ts @@ -275,8 +275,6 @@ export const useGridDataSource = ( 'paginationModelChange', runIfServerMode(props.paginationMode, fetchRows), ); - // @ts-ignore - Event is not defined in the Pro API - useGridApiEventHandler(apiRef, 'rowGroupingModelChange', () => fetchRows()); const isFirstRender = React.useRef(true); React.useEffect(() => {