UNPKG

16.6 kBTypeScriptView Raw
1// Type definitions for ag-grid v18.1.2
2// Project: http://www.ag-grid.com/
3// Definitions by: Niall Crosby <https://github.com/ag-grid/>
4import { RowNode } from "./rowNode";
5import { ICellEditorComp } from "../rendering/cellEditors/iCellEditor";
6import { ICellRendererComp, ICellRendererFunc } from "../rendering/cellRenderers/iCellRenderer";
7import { Column } from "./column";
8import { IFilterComp } from "../interfaces/iFilter";
9import { GridApi } from "../gridApi";
10import { ColumnApi } from "../columnController/columnApi";
11import { IHeaderGroupComp } from "../headerRendering/headerGroup/headerGroupComp";
12import { IFloatingFilterComp } from "../filter/floatingFilter";
13import { CellClickedEvent, CellContextMenuEvent, CellDoubleClickedEvent } from "../events";
14import { DynamicComponentDef, DynamicComponentParams } from "../components/framework/componentResolver";
15/****************************************************************
16 * Don't forget to update ComponentUtil if changing this class. PLEASE!*
17 ****************************************************************/
18/** AbstractColDef can be a group or a column definition */
19export interface AbstractColDef {
20 /** The name to render in the column header */
21 headerName?: string;
22 /** Whether to show the column when the group is open / closed. */
23 columnGroupShow?: string;
24 /** CSS class for the header */
25 headerClass?: string | string[] | ((params: any) => string | string[]);
26 /** CSS class for the header */
27 toolPanelClass?: string | string[] | ((params: any) => string | string[]);
28 /** Expression or function to get the cells value. */
29 headerValueGetter?: string | Function;
30 /** Never set this, it is used internally by grid when doing in-grid pivoting */
31 pivotKeys?: string[];
32 /** Set to true to not include this column in the toolpanel */
33 suppressToolPanel?: boolean;
34 /** Tooltip for the column header */
35 headerTooltip?: string;
36}
37export interface ColGroupDef extends AbstractColDef {
38 /** Columns in this group */
39 children: (ColDef | ColGroupDef)[];
40 /** Group ID */
41 groupId?: string;
42 /** Open by Default */
43 openByDefault?: boolean;
44 /** If true, group cannot be broken up by column moving, child columns will always appear side by side, however you can rearrange child columns within the group */
45 marryChildren?: boolean;
46 /** The custom header group component to be used for rendering the component header. If none specified the default ag-Grid is used**/
47 headerGroupComponent?: string | {
48 new (): IHeaderGroupComp;
49 };
50 /** The custom header group component to be used for rendering the component header in the hosting framework (ie: React/Angular). If none specified the default ag-Grid is used**/
51 headerGroupComponentFramework?: {
52 new (): any;
53 };
54 /** The custom header group component to be used for rendering the component header. If none specified the default ag-Grid is used**/
55 headerGroupComponentParams?: any;
56}
57export interface IAggFunc {
58 (input: any[]): any;
59}
60/****************************************************************
61 * Don't forget to update ComponentUtil if changing this class. PLEASE!*
62 ****************************************************************/
63export interface ColDef extends AbstractColDef {
64 /** The unique ID to give the column. This is optional. If missing, the ID will default to the field.
65 * If both field and colId are missing, a unique ID will be generated.
66 * This ID is used to identify the column in the API for sorting, filtering etc. */
67 colId?: string;
68 /** If sorting by default, set it here. Set to 'asc' or 'desc' */
69 sort?: string;
70 /** If sorting more than one column by default, the milliseconds when this column was sorted, so we know what order to sort the columns in. */
71 sortedAt?: number;
72 /** The sort order, provide an array with any of the following in any order ['asc','desc',null] */
73 sortingOrder?: string[];
74 /** The field of the row to get the cells data from */
75 field?: string;
76 /**
77 * A comma separated string or array of strings containing ColumnType keys which can be used as a template for a column.
78 * This helps to reduce duplication of properties when you have a lot of common column properties.
79 */
80 type?: string | string[];
81 /** Set to true for this column to be hidden. Naturally you might think, it would make more sense to call this field 'visible' and mark it false to hide,
82 * however we want all default values to be false and we want columns to be visible by default. */
83 hide?: boolean;
84 /** Whether this column is pinned or not. */
85 pinned?: boolean | string;
86 /** The field where we get the tooltip on the object */
87 tooltipField?: string;
88 /** The function used to calculate the tooltip of the object, tooltipField takes precedence*/
89 tooltip?: (params: TooltipParams) => string;
90 /** Expression or function to get the cells value. */
91 valueGetter?: ((params: ValueGetterParams) => any) | string;
92 /** Expression or function to get the cells value for filtering. */
93 filterValueGetter?: ((params: ValueGetterParams) => any) | string;
94 /** If not using a field, then this puts the value into the cell */
95 valueSetter?: ((params: ValueSetterParams) => boolean) | string;
96 /** Function to return the key for a value - use this if the value is an object (not a primitive type) and you
97 * want to a) group by this field or b) use set filter on this field. */
98 keyCreator?: Function;
99 /** Initial width, in pixels, of the cell */
100 width?: number;
101 /** Min width, in pixels, of the cell */
102 minWidth?: number;
103 /** Max width, in pixels, of the cell */
104 maxWidth?: number;
105 /** True if this column should stretch rows height to fit contents */
106 autoHeight?: boolean;
107 /** Class to use for the cell. Can be string, array of strings, or function. */
108 cellClass?: string | string[] | ((cellClassParams: CellClassParams) => string | string[]);
109 /** An object of css values. Or a function returning an object of css values. */
110 cellStyle?: {} | ((params: any) => {});
111 /** A function for rendering a cell. */
112 cellRenderer?: {
113 new (): ICellRendererComp;
114 } | ICellRendererFunc | string;
115 cellRendererFramework?: any;
116 cellRendererParams?: any;
117 cellRendererSelector?: (params: DynamicComponentParams) => DynamicComponentDef;
118 /** Cell editor */
119 cellEditor?: {
120 new (): ICellEditorComp;
121 } | string;
122 cellEditorFramework?: any;
123 cellEditorParams?: any;
124 cellEditorSelector?: (params: DynamicComponentParams) => DynamicComponentDef;
125 /** A function for rendering a pinned row cell. */
126 pinnedRowCellRenderer?: {
127 new (): ICellRendererComp;
128 } | ICellRendererFunc | string;
129 pinnedRowCellRendererFramework?: any;
130 pinnedRowCellRendererParams?: any;
131 /** A function to format a value, should return a string. Not used for CSV export or copy to clipboard, only for UI cell rendering. */
132 valueFormatter?: (params: ValueFormatterParams) => string | string;
133 /** A function to format a pinned row value, should return a string. Not used for CSV export or copy to clipboard, only for UI cell rendering. */
134 pinnedRowValueFormatter?: (params: ValueFormatterParams) => string | string;
135 /** Gets called after editing, converts the value in the cell. */
136 valueParser?: (params: ValueParserParams) => any | string;
137 /** Name of function to use for aggregation. One of [sum,min,max,first,last] or a function. */
138 aggFunc?: string | IAggFunc;
139 /** Agg funcs allowed on this column. If missing, all installed agg funcs are allowed.
140 * Can be eg ['sum','avg']. This will restrict what the GUI allows to select only.*/
141 allowedAggFuncs?: string[];
142 /** To group by this column by default, either provide an index (eg rowGroupIndex=1), or set rowGroup=true. */
143 rowGroupIndex?: number;
144 rowGroup?: boolean;
145 /** Set to true to have the grid place the values for the group into the cell, or put the name of a grouped column to just show that group. */
146 showRowGroup?: string | boolean;
147 /** To pivot by this column by default, either provide an index (eg pivotIndex=1), or set pivot=true. */
148 pivotIndex?: number;
149 pivot?: boolean;
150 /** Comparator function for custom sorting. */
151 comparator?: (valueA: any, valueB: any, nodeA?: RowNode, nodeB?: RowNode, isInverted?: boolean) => number;
152 /** Comparator for values, used by renderer to know if values have changed. Cells who's values have not changed don't get refreshed. */
153 equals?: (valueA: any, valueB: any) => boolean;
154 /** Comparator for ordering the pivot columns */
155 pivotComparator?: (valueA: string, valueB: string) => number;
156 /** Set to true to render a selection checkbox in the column. */
157 checkboxSelection?: boolean | ((params: any) => boolean);
158 /** If true, a 'select all' checkbox will be put into the header */
159 headerCheckboxSelection?: boolean | ((params: any) => boolean);
160 /** If true, the header checkbox selection will work on filtered items*/
161 headerCheckboxSelectionFilteredOnly?: boolean;
162 rowDrag?: boolean | ((params: any) => boolean);
163 /** Set to true if no menu should be shown for this column header. */
164 suppressMenu?: boolean;
165 /** The menu tabs to show, and in which order, the valid values for this property are:
166 * filterMenuTab, generalMenuTab, columnsMenuTab **/
167 menuTabs?: string[];
168 /** Set to true if no sorting should be done for this column. */
169 suppressSorting?: boolean;
170 /** Set to true to not allow moving this column via dragging it's header */
171 suppressMovable?: boolean;
172 /** Set to true to not flash this column for value changes */
173 suppressCellFlash?: boolean;
174 /** Set to true to make sure this column is always first. Other columns, if movable, cannot move before this column. */
175 lockPosition?: boolean;
176 /** Set to true to block the user showing / hiding the column, the column can only be shown / hidden via definitions or API */
177 lockVisible?: boolean;
178 /** Set to true to block the user pinning the column, the column can only be pinned via definitions or API */
179 lockPinned?: boolean;
180 /** Set to true to not allow filter on this column */
181 suppressFilter?: boolean;
182 /** Set to true if you want the unsorted icon to be shown when no sort is applied to this column. */
183 unSortIcon?: boolean;
184 /** Set to true if you want this columns width to be fixed during 'size to fit' operation. */
185 suppressSizeToFit?: boolean;
186 /** Set to true if you do not want this column to be resizable by dragging it's edge. */
187 suppressResize?: boolean;
188 /** Set to true if you do not want this column to be auto-resizable by double clicking it's edge. */
189 suppressAutoSize?: boolean;
190 suppressKeyboardEvent?: (params: SuppressKeyboardEventParams) => boolean;
191 /** If true, GUI will allow adding this columns as a row group */
192 enableRowGroup?: boolean;
193 /** If true, GUI will allow adding this columns as a pivot */
194 enablePivot?: boolean;
195 /** If true, GUI will allow adding this columns as a value */
196 enableValue?: boolean;
197 /** Set to true if this col is editable, otherwise false. Can also be a function to have different rows editable. */
198 editable?: boolean | IsColumnFunc;
199 colSpan?: (params: ColSpanParams) => number;
200 rowSpan?: (params: RowSpanParams) => number;
201 /** Set to true if this col should not be allowed take new values from teh clipboard . */
202 suppressPaste?: boolean | IsColumnFunc;
203 /** Set to tru if this col should not be navigable with the tab key. Can also be a function to have different rows editable. */
204 suppressNavigable?: boolean | IsColumnFunc;
205 /** To create the quick filter text for this column, if toString is not good enough on the value. */
206 getQuickFilterText?: (params: GetQuickFilterTextParams) => string;
207 /** Callbacks for editing. See editing section for further details.
208 * Return true if the update was successful, or false if not.
209 * If false, then skips the UI refresh and no events are emitted.
210 * Return false if the values are the same (ie no update). */
211 newValueHandler?: (params: any) => boolean;
212 /** If true, this cell will be in editing mode after first click. */
213 singleClickEdit?: boolean;
214 /** Cell template to use for cell. Useful for AngularJS cells. */
215 template?: string;
216 /** Cell template URL to load template from to use for cell. Useful for AngularJS cells. */
217 templateUrl?: string;
218 /** one of the built in filter names: [set, number, text], or a filter function*/
219 filter?: string | {
220 new (): IFilterComp;
221 };
222 filterFramework?: any;
223 /** The filter params are specific to each filter! */
224 filterParams?: any;
225 /** Rules for applying css classes */
226 cellClassRules?: {
227 [cssClassName: string]: (Function | string);
228 };
229 /** Callbacks for editing.See editing section for further details. */
230 onCellValueChanged?: Function;
231 /** Function callback, gets called when a cell is clicked. */
232 onCellClicked?: (event: CellClickedEvent) => void;
233 /** Function callback, gets called when a cell is double clicked. */
234 onCellDoubleClicked?: (event: CellDoubleClickedEvent) => void;
235 /** Function callback, gets called when a cell is right clicked. */
236 onCellContextMenu?: (event: CellContextMenuEvent) => void;
237 /** Icons for this column. Leave blank to use default. */
238 icons?: {
239 [key: string]: string;
240 };
241 /** If true, grid will flash cell after cell is refreshed */
242 enableCellChangeFlash?: boolean;
243 /** Never set this, it is used internally by grid when doing in-grid pivoting */
244 pivotValueColumn?: Column;
245 /** Never set this, it is used internally by grid when doing in-grid pivoting */
246 pivotTotalColumnIds?: string[];
247 /** The custom header component to be used for rendering the component header. If none specified the default ag-Grid is used**/
248 headerComponent?: string | {
249 new (): any;
250 };
251 /** The custom header component to be used for rendering the component header in the hosting framework (ie: React/Angular). If none specified the default ag-Grid is used**/
252 headerComponentFramework?: {
253 new (): any;
254 };
255 /** The custom header component parameters**/
256 headerComponentParams?: any;
257 /** The custom header component to be used for rendering the floating filter. If none specified the default ag-Grid is used**/
258 floatingFilterComponent?: {
259 new (): IFloatingFilterComp<any, any, any>;
260 };
261 floatingFilterComponentParams?: any;
262 floatingFilterComponentFramework?: {
263 new (): any;
264 };
265 refData?: {
266 [key: string]: string;
267 };
268}
269export interface IsColumnFunc {
270 (params: IsColumnFuncParams): boolean;
271}
272export interface IsColumnFuncParams {
273 node: RowNode;
274 data: any;
275 column: Column;
276 colDef: ColDef;
277 context: any;
278 api: GridApi;
279 columnApi: ColumnApi;
280}
281export interface GetQuickFilterTextParams {
282 value: any;
283 node: RowNode;
284 data: any;
285 column: Column;
286 colDef: ColDef;
287}
288export interface BaseColDefParams {
289 node: RowNode;
290 data: any;
291 colDef: ColDef;
292 column: Column;
293 api: GridApi;
294 columnApi: ColumnApi;
295 context: any;
296}
297export interface BaseWithValueColDefParams extends BaseColDefParams {
298 value: any;
299}
300export interface ValueGetterParams extends BaseColDefParams {
301 getValue: (field: string) => any;
302}
303export interface NewValueParams extends BaseColDefParams {
304 oldValue: any;
305 newValue: any;
306}
307export interface ValueSetterParams extends NewValueParams {
308}
309export interface ValueParserParams extends NewValueParams {
310}
311export interface ValueFormatterParams extends BaseWithValueColDefParams {
312}
313export interface ColSpanParams extends BaseColDefParams {
314}
315export interface RowSpanParams extends BaseColDefParams {
316}
317export interface SuppressKeyboardEventParams extends IsColumnFuncParams {
318 event: KeyboardEvent;
319 editing: boolean;
320}
321export interface CellClassParams {
322 value: any;
323 data: any;
324 node: RowNode;
325 colDef: ColDef;
326 rowIndex: number;
327 $scope: any;
328 api: GridApi;
329 context: any;
330}
331export interface TooltipParams {
332 value: any;
333 valueFormatted: any;
334 data: any;
335 node: RowNode;
336 colDef: ColDef;
337 rowIndex: number;
338 $scope: any;
339 api: GridApi;
340 context: any;
341}