Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[data grid] Add Api type param to cell params model #15968

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/pages/x/api/data-grid/grid-cell-params.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"import { GridCellParams } from '@mui/x-data-grid'"
],
"properties": {
"api": { "type": { "description": "GridApiCommunity" }, "required": true },
"api": { "type": { "description": "Api" }, "required": true },
"cellMode": { "type": { "description": "GridCellMode" }, "required": true },
"colDef": { "type": { "description": "GridStateColDef" }, "required": true },
"field": { "type": { "description": "string" }, "required": true },
Expand Down
2 changes: 2 additions & 0 deletions packages/x-data-grid/src/models/api/gridApiCommunity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ export interface GridPrivateApiCommunity
GridRowMultiSelectionApi,
GridColumnReorderApi,
GridRowProApi {}

export type { GridApiCommon };
22 changes: 8 additions & 14 deletions packages/x-data-grid/src/models/params/gridCellParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from '../gridRows';
import type { GridStateColDef } from '../colDef/gridColDef';
import { GridEditCellProps } from '../gridEditRowModel';
import { GridApiCommunity } from '../api/gridApiCommunity';
import { GridApiCommunity, GridApiCommon } from '../api/gridApiCommunity';

/**
* Object passed as parameter in the column [[GridColDef]] cell renderer.
Expand All @@ -19,6 +19,7 @@ export interface GridCellParams<
V = unknown,
F = V,
N extends GridTreeNode = GridTreeNode,
Api extends GridApiCommon = GridApiCommunity,
> {
/**
* The grid row id.
Expand Down Expand Up @@ -68,7 +69,7 @@ export interface GridCellParams<
/**
* GridApi that let you manipulate the grid.
*/
api: GridApiCommunity;
api: Api;
}

export interface FocusElement {
Expand All @@ -83,11 +84,8 @@ export interface GridRenderCellParams<
V = any,
F = V,
N extends GridTreeNodeWithRender = GridTreeNodeWithRender,
> extends GridCellParams<R, V, F, N> {
/**
* GridApi that let you manipulate the grid.
*/
api: GridApiCommunity;
Api extends GridApiCommon = GridApiCommunity,
> extends GridCellParams<R, V, F, N, Api> {
/**
* A ref allowing to set imperative focus.
* It can be passed to the element that should receive focus.
Expand All @@ -104,13 +102,9 @@ export interface GridRenderEditCellParams<
V = any,
F = V,
N extends GridTreeNodeWithRender = GridTreeNodeWithRender,
> extends GridCellParams<R, V, F, N>,
GridEditCellProps<V> {
/**
* GridApi that let you manipulate the grid.
*/
api: GridApiCommunity;
}
Api extends GridApiCommon = GridApiCommunity,
> extends GridCellParams<R, V, F, N, Api>,
GridEditCellProps<V> {}

/**
* Object passed as parameter in the column [[GridColDef]] edit cell props change callback.
Expand Down
Loading