-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
gridColumnApi.ts
79 lines (78 loc) · 3.28 KB
/
gridColumnApi.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
import { GridColDef, GridColumnsMeta, GridStateColDef } from '../colDef/gridColDef';
import type { GridColumnVisibilityModel } from '../../hooks/features/columns/gridColumnsInterfaces';
/**
* The column API interface that is available in the grid [[apiRef]].
* TODO: Differentiate interfaces based on the plan
*/
export interface GridColumnApi {
/**
* Returns the [[GridColDef]] for the given `field`.
* @param {string} field The column field.
* @returns {{GridStateColDef}} The [[GridStateColDef]].
*/
getColumn: (field: string) => GridStateColDef;
/**
* Returns an array of [[GridColDef]] containing all the column definitions.
* @returns {GridStateColDef[]} An array of [[GridStateColDef]].
*/
getAllColumns: () => GridStateColDef[];
/**
* Returns the currently visible columns.
* @returns {GridStateColDef[]} An array of [[GridStateColDef]].
*/
getVisibleColumns: () => GridStateColDef[];
/**
* Returns the [[GridColumnsMeta]] for each column.
* @returns {GridColumnsMeta[]} All [[GridColumnsMeta]] objects.
* @deprecatedUse Use `gridColumnsTotalWidthSelector` or `gridColumnPositionsSelector` selectors instead.
*/
getColumnsMeta: () => GridColumnsMeta;
/**
* Returns the index position of a column. By default, only the visible columns are considered.
* Pass `false` to `useVisibleColumns` to consider all columns.
* @param {string} field The column field.
* @param {boolean} useVisibleColumns Determines if all columns or the visible ones should be considered. Default is `true`.
* @returns {number} The index position.
*/
getColumnIndex: (field: string, useVisibleColumns?: boolean) => number;
/**
* Returns the left-position of a column relative to the inner border of the grid.
* @param {string} field The column field.
* @returns {number} The position in pixels.
*/
getColumnPosition: (field: string) => number;
/**
* Updates the definition of a column.
* @param {GridColDef} col The new [[GridColDef]] object.
* @deprecated Use `apiRef.current.updateColumns` instead.
*/
updateColumn: (col: GridColDef) => void;
/**
* Updates the definition of multiple columns at the same time.
* @param {GridColDef[]} cols The new column [[GridColDef]] objects.
*/
updateColumns: (cols: GridColDef[]) => void;
/**
* Sets the column visibility model to the one given by `model`.
* @param {GridColumnVisibilityModel} model The new visible columns model.
*/
setColumnVisibilityModel: (model: GridColumnVisibilityModel) => void;
/**
* Changes the visibility of the column referred by `field`.
* @param {string} field The column to change visibility.
* @param {boolean} isVisible Pass `true` to show the column, or `false` to hide it. Default is `false`
*/
setColumnVisibility: (field: string, isVisible: boolean) => void;
/**
* Moves a column from its original position to the position given by `targetIndexPosition`.
* @param {string} field The field name
* @param {number} targetIndexPosition The new position (0-based).
*/
setColumnIndex: (field: string, targetIndexPosition: number) => void;
/**
* Updates the width of a column.
* @param {string} field The column field.
* @param {number} width The new width.
*/
setColumnWidth: (field: string, width: number) => void;
}