UNPKG

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