/grid-packages/ag-grid-community/dist/lib/entities/colDef.d.ts

https://github.com/ceolter/angular-grid · TypeScript Typings · 371 lines · 250 code · 0 blank · 121 comment · 51 complexity · cf5bb0b87959047bbb0f4ecdf9fe9e7a MD5 · raw file

  1. import { RowNode } from "./rowNode";
  2. import { ICellEditorComp, ICellEditorParams } from "../interfaces/iCellEditor";
  3. import { ICellRendererComp, ICellRendererFunc, ICellRendererParams } from "../rendering/cellRenderers/iCellRenderer";
  4. import { Column } from "./column";
  5. import { GridApi } from "../gridApi";
  6. import { ColumnApi } from "../columnController/columnApi";
  7. import { IHeaderGroupComp } from "../headerRendering/headerGroup/headerGroupComp";
  8. import { CellClickedEvent, CellContextMenuEvent, CellDoubleClickedEvent } from "../events";
  9. import { ITooltipComp, ITooltipParams } from "../rendering/tooltipComponent";
  10. import { ComponentSelectorResult } from "../components/framework/userComponentFactory";
  11. import { IRowDragItem } from "../rendering/row/rowDragComp";
  12. import { IFilterDef } from '../interfaces/iFilter';
  13. /***********************************************************************
  14. * Don't forget to update PropertyKeys if changing this class. PLEASE! *
  15. ***********************************************************************/
  16. export declare const COL_DEF_PARAM_OBJECTS: string[];
  17. /** AbstractColDef can be a group or a column definition */
  18. export 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 Columns Tool Panel */
  32. suppressColumnsToolPanel?: boolean;
  33. /** Set to true to not include this column / filter in the Filters Tool Panel */
  34. suppressFiltersToolPanel?: boolean;
  35. /** Tooltip for the column header */
  36. headerTooltip?: string;
  37. tooltipComponent?: {
  38. new (): ITooltipComp;
  39. } | string;
  40. tooltipComponentFramework?: any;
  41. tooltipComponentParams?: any;
  42. }
  43. export interface ColGroupDef extends AbstractColDef {
  44. /** Columns in this group */
  45. children: (ColDef | ColGroupDef)[];
  46. /** Group ID */
  47. groupId?: string;
  48. /** Open by Default */
  49. openByDefault?: boolean;
  50. /** 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 */
  51. marryChildren?: boolean;
  52. /** The custom header group component to be used for rendering the component header. If none specified the default ag-Grid is used**/
  53. headerGroupComponent?: string | {
  54. new (): IHeaderGroupComp;
  55. };
  56. /** 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**/
  57. headerGroupComponentFramework?: any;
  58. /** The custom header group component to be used for rendering the component header. If none specified the default ag-Grid is used**/
  59. headerGroupComponentParams?: any;
  60. }
  61. export interface IAggFunc {
  62. (params: IAggFuncParams): any;
  63. }
  64. export interface IAggFuncParams {
  65. values: any[];
  66. column: Column;
  67. colDef: ColDef;
  68. rowNode: RowNode;
  69. data: any;
  70. api: GridApi;
  71. columnApi: ColumnApi;
  72. context: any;
  73. }
  74. /***********************************************************************
  75. * Don't forget to update PropertyKeys if changing this class. PLEASE! *
  76. ***********************************************************************/
  77. export interface ColDef extends AbstractColDef, IFilterDef {
  78. /** The unique ID to give the column. This is optional. If missing, the ID will default to the field.
  79. * If both field and colId are missing, a unique ID will be generated.
  80. * This ID is used to identify the column in the API for sorting, filtering etc. */
  81. colId?: string;
  82. /** If sorting by default, set it here. Set to 'asc' or 'desc' */
  83. sort?: string;
  84. initialSort?: string;
  85. /** If sorting more than one column by default, specifies order in which the sorting should be applied. */
  86. sortIndex?: number;
  87. initialSortIndex?: number;
  88. /** @deprecated since v24 - use sortOrder instead*/
  89. sortedAt?: number;
  90. /** The sort order, provide an array with any of the following in any order ['asc','desc',null] */
  91. sortingOrder?: (string | null)[];
  92. /** The field of the row to get the cells data from */
  93. field?: string;
  94. /**
  95. * A comma separated string or array of strings containing ColumnType keys which can be used as a template for a column.
  96. * This helps to reduce duplication of properties when you have a lot of common column properties.
  97. */
  98. type?: string | string[];
  99. /** 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,
  100. * however we want all default values to be false and we want columns to be visible by default. */
  101. hide?: boolean;
  102. initialHide?: boolean;
  103. /** Whether this column is pinned or not. */
  104. pinned?: boolean | string;
  105. initialPinned?: boolean | string;
  106. /** The field where we get the tooltip on the object */
  107. tooltipField?: string;
  108. /** The function used to calculate the tooltip of the object, tooltipField takes precedence */
  109. tooltipValueGetter?: (params: ITooltipParams) => string;
  110. /** Expression or function to get the cells value. */
  111. valueGetter?: ((params: ValueGetterParams) => any) | string;
  112. /** Expression or function to get the cells value for filtering. */
  113. filterValueGetter?: ((params: ValueGetterParams) => any) | string;
  114. /** If not using a field, then this puts the value into the cell */
  115. valueSetter?: ((params: ValueSetterParams) => boolean) | string;
  116. /** Function to return the key for a value - use this if the value is an object (not a primitive type) and you
  117. * want to a) group by this field or b) use set filter on this field. */
  118. keyCreator?: (value: any) => string;
  119. /** Actual width, in pixels, of the cell */
  120. width?: number;
  121. /** Default width, in pixels, of the cell */
  122. initialWidth?: number;
  123. /** Min width, in pixels, of the cell */
  124. minWidth?: number;
  125. /** Max width, in pixels, of the cell */
  126. maxWidth?: number;
  127. /** Sets the grow factor of a column. It specifies how much of the remaining
  128. * space should be assigned to the column.
  129. */
  130. flex?: number;
  131. initialFlex?: number;
  132. /** True if this column should stretch rows height to fit contents */
  133. autoHeight?: boolean;
  134. /** True if this column should wrap cell contents - typically used with autoHeight */
  135. wrapText?: boolean;
  136. /** Class to use for the cell. Can be string, array of strings, or function. */
  137. cellClass?: string | string[] | ((cellClassParams: CellClassParams) => string | string[]);
  138. /** An object of css values. Or a function returning an object of css values. */
  139. cellStyle?: {} | ((params: any) => {});
  140. /** A function for rendering a cell. */
  141. cellRenderer?: {
  142. new (): ICellRendererComp;
  143. } | ICellRendererFunc | string;
  144. cellRendererFramework?: any;
  145. cellRendererParams?: any;
  146. cellRendererSelector?: (params: ICellRendererParams) => ComponentSelectorResult;
  147. /** Cell editor */
  148. cellEditor?: {
  149. new (): ICellEditorComp;
  150. } | string;
  151. cellEditorFramework?: any;
  152. cellEditorParams?: any;
  153. cellEditorSelector?: (params: ICellEditorParams) => ComponentSelectorResult;
  154. /** A function for rendering a pinned row cell. */
  155. pinnedRowCellRenderer?: {
  156. new (): ICellRendererComp;
  157. } | ICellRendererFunc | string;
  158. pinnedRowCellRendererFramework?: any;
  159. pinnedRowCellRendererParams?: any;
  160. /** A function to format a value, should return a string. Not used for CSV export or copy to clipboard, only for UI cell rendering. */
  161. valueFormatter?: ((params: ValueFormatterParams) => string) | string;
  162. /** 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. */
  163. pinnedRowValueFormatter?: ((params: ValueFormatterParams) => string) | string;
  164. /** Gets called after editing, converts the value in the cell. */
  165. valueParser?: ((params: ValueParserParams) => any) | string;
  166. /** Name of function to use for aggregation. One of [sum,min,max,first,last] or a function. */
  167. aggFunc?: string | IAggFunc;
  168. initialAggFunc?: string | IAggFunc;
  169. /** Agg funcs allowed on this column. If missing, all installed agg funcs are allowed.
  170. * Can be eg ['sum','avg']. This will restrict what the GUI allows to select only.*/
  171. allowedAggFuncs?: string[];
  172. /** To group by this column by default, either provide an index (eg rowGroupIndex=1), or set rowGroup=true. */
  173. rowGroupIndex?: number;
  174. rowGroup?: boolean;
  175. initialRowGroupIndex?: number;
  176. initialRowGroup?: boolean;
  177. /** 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. */
  178. showRowGroup?: string | boolean;
  179. /** To pivot by this column by default, either provide an index (eg pivotIndex=1), or set pivot=true. */
  180. pivotIndex?: number;
  181. pivot?: boolean;
  182. initialPivotIndex?: number;
  183. initialPivot?: boolean;
  184. /** Comparator function for custom sorting. */
  185. comparator?: (valueA: any, valueB: any, nodeA: RowNode, nodeB: RowNode, isInverted: boolean) => number;
  186. /** Comparator for values, used by renderer to know if values have changed. Cells who's values have not changed don't get refreshed. */
  187. equals?: (valueA: any, valueB: any) => boolean;
  188. /** Comparator for ordering the pivot columns */
  189. pivotComparator?: (valueA: string, valueB: string) => number;
  190. /** Set to true to render a selection checkbox in the column. */
  191. checkboxSelection?: boolean | ((params: any) => boolean) | null;
  192. /** If true, a 'select all' checkbox will be put into the header */
  193. headerCheckboxSelection?: boolean | ((params: any) => boolean);
  194. /** If true, the header checkbox selection will work on filtered items*/
  195. headerCheckboxSelectionFilteredOnly?: boolean;
  196. /** For grid row dragging, set to true to enable row dragging within the grid */
  197. rowDrag?: boolean | ((params: any) => boolean);
  198. /** To configure the text to be displayed in the floating div while dragging a row when rowDrag is true */
  199. rowDragText?: ((params: IRowDragItem, dragItemCount: number) => string);
  200. /** For native drag and drop, set to true to enable drag source */
  201. dndSource?: boolean | ((params: any) => boolean);
  202. /** For native drag and drop, set to true to allow custom onRowDrag processing */
  203. dndSourceOnRowDrag?: ((params: {
  204. rowNode: RowNode;
  205. dragEvent: DragEvent;
  206. }) => void);
  207. /** Set to true if no menu should be shown for this column header. */
  208. suppressMenu?: boolean;
  209. /** The menu tabs to show, and in which order, the valid values for this property are:
  210. * filterMenuTab, generalMenuTab, columnsMenuTab **/
  211. menuTabs?: string[];
  212. /** Set to true if sorting allowed for this column. */
  213. sortable?: boolean;
  214. /** Set to true to not allow moving this column via dragging it's header */
  215. suppressMovable?: boolean;
  216. /** Set to true to not flash this column for value changes */
  217. suppressCellFlash?: boolean;
  218. /** Set to true to make sure this column is always first. Other columns, if movable, cannot move before this column. */
  219. lockPosition?: boolean;
  220. /** Set to true to block the user showing / hiding the column, the column can only be shown / hidden via definitions or API */
  221. lockVisible?: boolean;
  222. /** Set to true to block the user pinning the column, the column can only be pinned via definitions or API */
  223. lockPinned?: boolean;
  224. /** Set to true if you want the unsorted icon to be shown when no sort is applied to this column. */
  225. unSortIcon?: boolean;
  226. /** Set to true if you want this columns width to be fixed during 'size to fit' operation. */
  227. suppressSizeToFit?: boolean;
  228. /** Set to true if this column should be resizable */
  229. resizable?: boolean;
  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. /** Allows user to suppress certain keyboard events */
  233. suppressKeyboardEvent?: (params: SuppressKeyboardEventParams) => boolean;
  234. /** If true, GUI will allow adding this columns as a row group */
  235. enableRowGroup?: boolean;
  236. /** If true, GUI will allow adding this columns as a pivot */
  237. enablePivot?: boolean;
  238. /** If true, GUI will allow adding this columns as a value */
  239. enableValue?: boolean;
  240. /** Set to true if this col is editable, otherwise false. Can also be a function to have different rows editable. */
  241. editable?: boolean | IsColumnFunc;
  242. colSpan?: (params: ColSpanParams) => number;
  243. rowSpan?: (params: RowSpanParams) => number;
  244. /** Set to true if this col should not be allowed take new values from the clipboard . */
  245. suppressPaste?: boolean | IsColumnFunc;
  246. /** Set to tru if this col should not be navigable with the tab key. Can also be a function to have different rows editable. */
  247. suppressNavigable?: boolean | IsColumnFunc;
  248. /** To create the quick filter text for this column, if toString is not good enough on the value. */
  249. getQuickFilterText?: (params: GetQuickFilterTextParams) => string;
  250. /** Callbacks for editing. See editing section for further details.
  251. * Return true if the update was successful, or false if not.
  252. * If false, then skips the UI refresh and no events are emitted.
  253. * Return false if the values are the same (ie no update). */
  254. newValueHandler?: (params: any) => boolean;
  255. /** If true, this cell will be in editing mode after first click. */
  256. singleClickEdit?: boolean;
  257. /** Cell template to use for cell. Useful for AngularJS cells. */
  258. template?: string;
  259. /** Cell template URL to load template from to use for cell. Useful for AngularJS cells. */
  260. templateUrl?: string;
  261. /** Rules for applying css classes */
  262. cellClassRules?: {
  263. [cssClassName: string]: (Function | string);
  264. };
  265. /** Callbacks for editing.See editing section for further details. */
  266. onCellValueChanged?: Function;
  267. /** Function callback, gets called when a cell is clicked. */
  268. onCellClicked?: (event: CellClickedEvent) => void;
  269. /** Function callback, gets called when a cell is double clicked. */
  270. onCellDoubleClicked?: (event: CellDoubleClickedEvent) => void;
  271. /** Function callback, gets called when a cell is right clicked. */
  272. onCellContextMenu?: (event: CellContextMenuEvent) => void;
  273. /** Icons for this column. Leave blank to use default. */
  274. icons?: {
  275. [key: string]: string;
  276. };
  277. /** If true, grid will flash cell after cell is refreshed */
  278. enableCellChangeFlash?: boolean;
  279. /** Never set this, it is used internally by grid when doing in-grid pivoting */
  280. pivotValueColumn?: Column | null;
  281. /** Never set this, it is used internally by grid when doing in-grid pivoting */
  282. pivotTotalColumnIds?: string[];
  283. /** The custom header component to be used for rendering the component header. If none specified the default ag-Grid is used**/
  284. headerComponent?: string | {
  285. new (): any;
  286. };
  287. /** 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**/
  288. headerComponentFramework?: any;
  289. /** The custom header component parameters**/
  290. headerComponentParams?: any;
  291. /** Whether to display a floating filter for this column. */
  292. floatingFilter?: boolean;
  293. refData?: {
  294. [key: string]: string;
  295. };
  296. /** Defines the column data type used when charting, i.e. 'category' | 'series' | 'excluded' | undefined **/
  297. chartDataType?: string;
  298. /** Params to customise the columns menu behaviour and appearance */
  299. columnsMenuParams?: ColumnsMenuParams;
  300. }
  301. export interface IsColumnFunc {
  302. (params: IsColumnFuncParams): boolean;
  303. }
  304. export interface IsColumnFuncParams {
  305. node: RowNode;
  306. data: any;
  307. column: Column;
  308. colDef: ColDef;
  309. context: any;
  310. api: GridApi | null | undefined;
  311. columnApi: ColumnApi | null | undefined;
  312. }
  313. export interface GetQuickFilterTextParams {
  314. value: any;
  315. node: RowNode;
  316. data: any;
  317. column: Column;
  318. colDef: ColDef;
  319. context: any;
  320. }
  321. export interface ColumnsMenuParams {
  322. suppressSyncLayoutWithGrid?: boolean;
  323. suppressColumnFilter?: boolean;
  324. suppressColumnSelectAll?: boolean;
  325. suppressColumnExpandAll?: boolean;
  326. contractColumnSelection?: boolean;
  327. }
  328. export interface BaseColDefParams {
  329. node: RowNode;
  330. data: any;
  331. colDef: ColDef;
  332. column: Column;
  333. api: GridApi | null | undefined;
  334. columnApi: ColumnApi | null | undefined;
  335. context: any;
  336. }
  337. export interface BaseWithValueColDefParams extends BaseColDefParams {
  338. value: any;
  339. }
  340. export interface ValueGetterParams extends BaseColDefParams {
  341. getValue: (field: string) => any;
  342. }
  343. export interface NewValueParams extends BaseColDefParams {
  344. oldValue: any;
  345. newValue: any;
  346. }
  347. export interface ValueSetterParams extends NewValueParams {
  348. }
  349. export interface ValueParserParams extends NewValueParams {
  350. }
  351. export interface ValueFormatterParams extends BaseWithValueColDefParams {
  352. }
  353. export interface ColSpanParams extends BaseColDefParams {
  354. }
  355. export interface RowSpanParams extends BaseColDefParams {
  356. }
  357. export interface SuppressKeyboardEventParams extends IsColumnFuncParams {
  358. event: KeyboardEvent;
  359. editing: boolean;
  360. }
  361. export interface CellClassParams {
  362. value: any;
  363. data: any;
  364. node: RowNode;
  365. colDef: ColDef;
  366. rowIndex: number;
  367. $scope: any;
  368. api: GridApi;
  369. columnApi: ColumnApi;
  370. context: any;
  371. }