-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathgridCellParams.ts
182 lines (173 loc) · 4.74 KB
/
gridCellParams.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
import { GridCellMode } from '../gridCell';
import { GridRowId, GridRowModel, GridRowTreeNodeConfig, GridValidRowModel } from '../gridRows';
import type { GridStateColDef } from '../colDef/gridColDef';
import { GridEditCellProps } from '../gridEditRowModel';
/**
* Object passed as parameter in the column [[GridColDef]] cell renderer.
*/
export interface GridCellParams<V = any, R extends GridValidRowModel = any, F = V> {
/**
* The grid row id.
*/
id: GridRowId;
/**
* The column field of the cell that triggered the event.
*/
field: string;
/**
* The cell value, but if the column has valueGetter, use getValue.
*/
value?: V | undefined;
/**
* The cell value formatted with the column valueFormatter.
*/
formattedValue?: F | undefined;
/**
* The row model of the row that the current cell belongs to.
*/
row: GridRowModel<R>;
/**
* The node of the row that the current cell belongs to.
*/
rowNode: GridRowTreeNodeConfig;
/**
* The column of the row that the current cell belongs to.
*/
colDef: GridStateColDef;
/**
* If true, the cell is editable.
*/
isEditable?: boolean;
/**
* The mode of the cell.
*/
cellMode: GridCellMode;
/**
* If true, the cell is the active element.
*/
hasFocus: boolean;
/**
* the tabIndex value.
*/
tabIndex: 0 | -1;
/**
* Get the cell value of a row and field.
* @param {GridRowId} id The row id.
* @param {string} field The field.
* @returns {any} The cell value.
* @deprecated Use `params.row` to directly access the fields you want instead.
*/
getValue: (id: GridRowId, field: string) => any;
}
export interface FocusElement {
focus(): void;
}
/**
* GridCellParams containing api.
*/
export interface GridRenderCellParams<V = any, R extends GridValidRowModel = any, F = V>
extends GridCellParams<V, R, F> {
/**
* GridApi that let you manipulate the grid.
* @deprecated Use the `apiRef` returned by `useGridApiContext` or `useGridApiRef` (only available in `@mui/x-data-grid-pro`)
*/
api: any;
/**
* A ref allowing to set imperative focus.
* It can be passed to the element that should receive focus.
* @ignore - do not document.
*/
focusElementRef?: React.Ref<FocusElement>;
}
/**
* GridEditCellProps containing api.
*/
export interface GridRenderEditCellParams<V = any, R extends GridValidRowModel = any, F = V>
extends GridCellParams<V, R, F>,
GridEditCellProps<V> {
/**
* GridApi that let you manipulate the grid.
* @deprecated Use the `apiRef` returned by `useGridApiContext` or `useGridApiRef` (only available in `@mui/x-data-grid-pro`)
*/
api: any;
}
/**
* Parameters passed to `colDef.valueGetter`.
*/
export interface GridValueGetterParams<V = any, R = any>
extends Omit<GridCellParams<V, R, any>, 'formattedValue' | 'isEditable'> {
/**
* GridApi that let you manipulate the grid.
* @deprecated Use the `apiRef` returned by `useGridApiContext` or `useGridApiRef` (only available in `@mui/x-data-grid-pro`)
*/
api: any;
}
/**
* @deprecated Use `GridValueGetterParams` instead.
*/
export type GridValueGetterFullParams<
V = any,
R extends GridValidRowModel = any,
> = GridValueGetterParams<V, R>;
/**
* Object passed as parameter in the column [[GridColDef]] value setter callback.
*/
export interface GridValueSetterParams<R extends GridValidRowModel = any, V = any> {
/**
* The new cell value.
*/
value: V;
/**
* The row that is being edited.
*/
row: R;
}
/**
* Object passed as parameter in the column [[GridColDef]] value formatter callback.
*/
export interface GridValueFormatterParams<V = any> {
/**
* The grid row id.
* It is not available when the value formatter is called by the filter panel.
*/
id?: GridRowId;
/**
* The column field of the cell that triggered the event.
*/
field: string;
/**
* The cell value, if the column has valueGetter it is the value returned by it.
*/
value: V;
/**
* GridApi that let you manipulate the grid.
* @deprecated Use the `apiRef` returned by `useGridApiContext` or `useGridApiRef` (only available in `@mui/x-data-grid-pro`)
*/
api: any;
}
/**
* Object passed as parameter in the column [[GridColDef]] edit cell props change callback.
*/
export interface GridPreProcessEditCellProps {
/**
* The grid row id.
*/
id: GridRowId;
/**
* The row that is being edited.
*/
row: GridRowModel;
/**
* The edit cell props.
*/
props: GridEditCellProps;
/**
* Whether the new value is different from the stored value or not.
*/
hasChanged?: boolean;
/**
* Object containing the props of the other fields.
* Only available for row editing and when using the new editing API.
*/
otherFieldsProps?: Record<string, GridEditCellProps>;
}