From b79556421ff0952df2d3eae170d4f0ba60a7cdd5 Mon Sep 17 00:00:00 2001 From: Pascal Corpet Date: Thu, 25 Jul 2024 04:50:24 +0200 Subject: [PATCH] [DataGrid] Also send the API with events in Premium (#13893) Co-authored-by: Bilal Shafi --- .../src/DataGridPremium/useDataGridPremiumProps.ts | 3 ++- .../x-data-grid/src/hooks/core/useGridApiInitialization.ts | 3 ++- packages/x-data-grid/src/hooks/utils/useGridApiEventHandler.ts | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/x-data-grid-premium/src/DataGridPremium/useDataGridPremiumProps.ts b/packages/x-data-grid-premium/src/DataGridPremium/useDataGridPremiumProps.ts index 0d50f1b0a819..b1efe92d1480 100644 --- a/packages/x-data-grid-premium/src/DataGridPremium/useDataGridPremiumProps.ts +++ b/packages/x-data-grid-premium/src/DataGridPremium/useDataGridPremiumProps.ts @@ -4,6 +4,7 @@ import { DATA_GRID_PRO_PROPS_DEFAULT_VALUES, GRID_DEFAULT_LOCALE_TEXT, DataGridProProps, + GridSignature, } from '@mui/x-data-grid-pro'; import { computeSlots, useProps } from '@mui/x-data-grid-pro/internals'; import { @@ -25,7 +26,7 @@ type GetDataGridProForcedProps = ( ) => DataGridProForcedProps; const getDataGridPremiumForcedProps: GetDataGridProForcedProps = (themedProps) => ({ - signature: 'DataGridPremium', + signature: GridSignature.DataGridPremium, ...(themedProps.unstable_dataSource ? { filterMode: 'server', diff --git a/packages/x-data-grid/src/hooks/core/useGridApiInitialization.ts b/packages/x-data-grid/src/hooks/core/useGridApiInitialization.ts index 61f639fb183a..3113bc997010 100644 --- a/packages/x-data-grid/src/hooks/core/useGridApiInitialization.ts +++ b/packages/x-data-grid/src/hooks/core/useGridApiInitialization.ts @@ -120,7 +120,8 @@ export function useGridApiInitialization< } const details = - props.signature === GridSignature.DataGridPro + props.signature === GridSignature.DataGridPro || + props.signature === GridSignature.DataGridPremium ? { api: privateApiRef.current.getPublicApi() } : {}; privateApiRef.current.eventManager.emit(name, params, event, details); diff --git a/packages/x-data-grid/src/hooks/utils/useGridApiEventHandler.ts b/packages/x-data-grid/src/hooks/utils/useGridApiEventHandler.ts index 2e75893309e9..b35036c795bf 100644 --- a/packages/x-data-grid/src/hooks/utils/useGridApiEventHandler.ts +++ b/packages/x-data-grid/src/hooks/utils/useGridApiEventHandler.ts @@ -13,6 +13,7 @@ import type { GridApiCommon } from '../../models'; enum GridSignature { DataGrid = 'DataGrid', DataGridPro = 'DataGridPro', + DataGridPremium = 'DataGridPremium', } interface RegistryContainer {