@mui/x-data-grid
Version:
The Community plan edition of the Data Grid components (MUI X).
43 lines • 2.61 kB
TypeScript
import { RefObject } from '@mui/x-internals/types';
import { GridPrivateApiCommon } from "../../../models/api/gridApiCommon.js";
import { GridStrategyProcessorName, GridStrategyGroupValue } from "./gridStrategyProcessingApi.js";
export declare const GRID_DEFAULT_STRATEGY = "none";
export declare const GRID_STRATEGIES_PROCESSORS: { [P in GridStrategyProcessorName]: GridStrategyGroupValue };
/**
* Implements a variant of the Strategy Pattern (see https://en.wikipedia.org/wiki/Strategy_pattern)
*
* More information and detailed example in (TODO add link to technical doc when ready)
*
* Some plugins contains custom logic that must only be applied if the right strategy is active.
* For instance, the row grouping plugin has a custom filtering algorithm.
* This algorithm must be applied by the filtering plugin if the row grouping is the current way of grouping rows,
* but not if the tree data is the current way of grouping rows.
*
* =====================================================================================================================
*
* The plugin containing the custom logic must use:
*
* - `useGridRegisterStrategyProcessor` to register their processor.
* When the processor of the active strategy changes, it will fire `"activeStrategyProcessorChange"` to re-apply the processor.
*
* - `apiRef.current.setStrategyAvailability` to tell if their strategy can be used.
*
* =====================================================================================================================
*
* The plugin or component that needs to apply the custom logic of the current strategy must use:
*
* - `apiRef.current.applyStrategyProcessor` to run the processor of the active strategy for a given processor name.
*
* - the "strategyAvailabilityChange" event to update something when the active strategy changes.
* Warning: Be careful not to apply the processor several times.
* For instance "rowsSet" is fired by `useGridRows` whenever the active strategy changes.
* So listening to both would most likely run your logic twice.
*
* - The "activeStrategyProcessorChange" event to update something when the processor of the active strategy changes.
*
* =====================================================================================================================
*
* Each processor name is part of a strategy group which can only have one active strategy at the time.
* There are two active groups named `rowTree` and `dataSource`.
*/
export declare const useGridStrategyProcessing: (apiRef: RefObject<GridPrivateApiCommon>) => void;