1 | import {ColDef, ColGroupDef} from "../entities/colDef";
|
2 | import {ColumnGroupChild} from "../entities/columnGroupChild";
|
3 | import {ColumnController, ColumnState} from "./columnController";
|
4 | import {OriginalColumnGroup} from "../entities/originalColumnGroup";
|
5 | import {ColumnGroup} from "../entities/columnGroup";
|
6 | import {Column} from "../entities/column";
|
7 | import {Autowired, Bean} from "../context/context";
|
8 |
|
9 | @Bean('columnApi')
|
10 | export class ColumnApi {
|
11 |
|
12 | @Autowired('columnController') private columnController: ColumnController;
|
13 |
|
14 | public sizeColumnsToFit(gridWidth: any): void { this.columnController.sizeColumnsToFit(gridWidth, 'api'); }
|
15 | public setColumnGroupOpened(group: OriginalColumnGroup|string, newValue: boolean): void { this.columnController.setColumnGroupOpened(group, newValue, 'api'); }
|
16 | public getColumnGroup(name: string, instanceId?: number): ColumnGroup { return this.columnController.getColumnGroup(name, instanceId); }
|
17 | public getOriginalColumnGroup(name: string): OriginalColumnGroup { return this.columnController.getOriginalColumnGroup(name); }
|
18 |
|
19 | public getDisplayNameForColumn(column: Column, location: string): string { return this.columnController.getDisplayNameForColumn(column, location); }
|
20 | public getDisplayNameForColumnGroup(columnGroup: ColumnGroup, location: string): string { return this.columnController.getDisplayNameForColumnGroup(columnGroup, location); }
|
21 |
|
22 | public getColumn(key: any): Column { return this.columnController.getPrimaryColumn(key); }
|
23 | public setColumnState(columnState: ColumnState[]): boolean { return this.columnController.setColumnState(columnState, 'api'); }
|
24 | public getColumnState(): ColumnState[] { return this.columnController.getColumnState(); }
|
25 | public resetColumnState(): void { this.columnController.resetColumnState('api'); }
|
26 | public getColumnGroupState(): {groupId: string, open: boolean}[] {return this.columnController.getColumnGroupState();}
|
27 | public setColumnGroupState(stateItems: ({groupId: string, open: boolean})[]): void {this.columnController.setColumnGroupState(stateItems, 'api');}
|
28 | public resetColumnGroupState(): void { this.columnController.resetColumnGroupState('api'); }
|
29 |
|
30 | public isPinning(): boolean { return this.columnController.isPinningLeft() || this.columnController.isPinningRight(); }
|
31 | public isPinningLeft(): boolean { return this.columnController.isPinningLeft(); }
|
32 | public isPinningRight(): boolean { return this.columnController.isPinningRight(); }
|
33 | public getDisplayedColAfter(col: Column): Column { return this.columnController.getDisplayedColAfter(col); }
|
34 | public getDisplayedColBefore(col: Column): Column { return this.columnController.getDisplayedColBefore(col); }
|
35 | public setColumnVisible(key: string|Column, visible: boolean): void { this.columnController.setColumnVisible(key, visible, 'api'); }
|
36 | public setColumnsVisible(keys: (string|Column)[], visible: boolean): void { this.columnController.setColumnsVisible(keys, visible, 'api'); }
|
37 | public setColumnPinned(key: string|Column, pinned: string): void { this.columnController.setColumnPinned(key, pinned, 'api'); }
|
38 | public setColumnsPinned(keys: (string|Column)[], pinned: string): void { this.columnController.setColumnsPinned(keys, pinned, 'api'); }
|
39 |
|
40 | public getAllColumns(): Column[] { return this.columnController.getAllPrimaryColumns(); }
|
41 | public getAllGridColumns(): Column[] { return this.columnController.getAllGridColumns(); }
|
42 | public getDisplayedLeftColumns(): Column[] { return this.columnController.getDisplayedLeftColumns(); }
|
43 | public getDisplayedCenterColumns(): Column[] { return this.columnController.getDisplayedCenterColumns(); }
|
44 | public getDisplayedRightColumns(): Column[] { return this.columnController.getDisplayedRightColumns(); }
|
45 | public getAllDisplayedColumns(): Column[] { return this.columnController.getAllDisplayedColumns(); }
|
46 | public getAllDisplayedVirtualColumns(): Column[] { return this.columnController.getAllDisplayedVirtualColumns(); }
|
47 |
|
48 | public moveColumn(key: string|Column, toIndex: number): void {
|
49 | if (typeof key === 'number') {
|
50 |
|
51 | console.log('ag-Grid: you are using moveColumn(fromIndex, toIndex) - moveColumn takes a column key and a destination index, not two indexes, to move with indexes use moveColumnByIndex(from,to) instead');
|
52 | this.columnController.moveColumnByIndex(<number>key, toIndex, 'api');
|
53 | } else {
|
54 | this.columnController.moveColumn(key, toIndex, 'api');
|
55 | }
|
56 | }
|
57 | public moveColumnByIndex(fromIndex: number, toIndex: number): void { this.columnController.moveColumnByIndex(fromIndex, toIndex, 'api'); }
|
58 | public moveColumns(columnsToMoveKeys: (string|Column)[], toIndex: number) { this.columnController.moveColumns(columnsToMoveKeys, toIndex, 'api'); }
|
59 |
|
60 | public moveRowGroupColumn(fromIndex: number, toIndex: number): void { this.columnController.moveRowGroupColumn(fromIndex, toIndex); }
|
61 | public setColumnAggFunc(column: Column, aggFunc: string): void { this.columnController.setColumnAggFunc(column, aggFunc); }
|
62 | public setColumnWidth(key: string|Column, newWidth: number, finished: boolean = true): void { this.columnController.setColumnWidth(key, newWidth, false, finished); }
|
63 | public setPivotMode(pivotMode: boolean): void { this.columnController.setPivotMode(pivotMode); }
|
64 | public isPivotMode(): boolean { return this.columnController.isPivotMode(); }
|
65 | public getSecondaryPivotColumn(pivotKeys: string[], valueColKey: string|Column): Column { return this.columnController.getSecondaryPivotColumn(pivotKeys, valueColKey); }
|
66 |
|
67 | public setValueColumns(colKeys: (string|Column)[]): void { this.columnController.setValueColumns(colKeys, 'api'); }
|
68 | public getValueColumns(): Column[] { return this.columnController.getValueColumns(); }
|
69 | public removeValueColumn(colKey: (string|Column)): void { this.columnController.removeValueColumn(colKey, 'api'); }
|
70 | public removeValueColumns(colKeys: (string|Column)[]): void { this.columnController.removeValueColumns(colKeys, 'api'); }
|
71 | public addValueColumn(colKey: (string|Column)): void { this.columnController.addValueColumn(colKey, 'api'); }
|
72 | public addValueColumns(colKeys: (string|Column)[]): void { this.columnController.addValueColumns(colKeys, 'api'); }
|
73 |
|
74 | public setRowGroupColumns(colKeys: (string|Column)[]): void { this.columnController.setRowGroupColumns(colKeys, 'api'); }
|
75 | public removeRowGroupColumn(colKey: string|Column): void { this.columnController.removeRowGroupColumn(colKey, 'api'); }
|
76 | public removeRowGroupColumns(colKeys: (string|Column)[]): void { this.columnController.removeRowGroupColumns(colKeys, 'api'); }
|
77 | public addRowGroupColumn(colKey: string|Column): void { this.columnController.addRowGroupColumn(colKey, 'api'); }
|
78 | public addRowGroupColumns(colKeys: (string|Column)[]): void { this.columnController.addRowGroupColumns(colKeys, 'api'); }
|
79 | public getRowGroupColumns(): Column[] { return this.columnController.getRowGroupColumns(); }
|
80 |
|
81 | public setPivotColumns(colKeys: (string|Column)[]): void { this.columnController.setPivotColumns(colKeys, 'api'); }
|
82 | public removePivotColumn(colKey: string|Column): void { this.columnController.removePivotColumn(colKey, 'api'); }
|
83 | public removePivotColumns(colKeys: (string|Column)[]): void { this.columnController.removePivotColumns(colKeys, 'api'); }
|
84 | public addPivotColumn(colKey: string|Column): void { this.columnController.addPivotColumn(colKey, 'api'); }
|
85 | public addPivotColumns(colKeys: (string|Column)[]): void { this.columnController.addPivotColumns(colKeys, 'api'); }
|
86 | public getPivotColumns(): Column[] { return this.columnController.getPivotColumns(); }
|
87 |
|
88 | public getLeftDisplayedColumnGroups(): ColumnGroupChild[] { return this.columnController.getLeftDisplayedColumnGroups(); }
|
89 | public getCenterDisplayedColumnGroups(): ColumnGroupChild[] { return this.columnController.getCenterDisplayedColumnGroups(); }
|
90 | public getRightDisplayedColumnGroups(): ColumnGroupChild[] { return this.columnController.getRightDisplayedColumnGroups(); }
|
91 | public getAllDisplayedColumnGroups(): ColumnGroupChild[] { return this.columnController.getAllDisplayedColumnGroups(); }
|
92 | public autoSizeColumn(key: string|Column): void {return this.columnController.autoSizeColumn(key, 'api'); }
|
93 | public autoSizeColumns(keys: (string|Column)[]): void {return this.columnController.autoSizeColumns(keys, 'api'); }
|
94 | public autoSizeAllColumns(): void { this.columnController.autoSizeAllColumns('api'); }
|
95 |
|
96 | public setSecondaryColumns(colDefs: (ColDef|ColGroupDef)[]): void { this.columnController.setSecondaryColumns(colDefs, 'api'); }
|
97 |
|
98 |
|
99 |
|
100 | public columnGroupOpened(group: OriginalColumnGroup|string, newValue: boolean): void {
|
101 | console.error('ag-Grid: columnGroupOpened no longer exists, use setColumnGroupOpened');
|
102 | this.setColumnGroupOpened(group, newValue);
|
103 | }
|
104 | public hideColumns(colIds: any, hide: any): void {
|
105 | console.error('ag-Grid: hideColumns is deprecated, use setColumnsVisible');
|
106 | this.columnController.setColumnsVisible(colIds, !hide, 'api');
|
107 | }
|
108 | public hideColumn(colId: any, hide: any): void {
|
109 | console.error('ag-Grid: hideColumn is deprecated, use setColumnVisible');
|
110 | this.columnController.setColumnVisible(colId, !hide, 'api');
|
111 | }
|
112 |
|
113 | public setState(columnState: ColumnState[]): boolean {
|
114 | console.error('ag-Grid: setState is deprecated, use setColumnState');
|
115 | return this.setColumnState(columnState);
|
116 | }
|
117 | public getState(): ColumnState[] {
|
118 | console.error('ag-Grid: getState is deprecated, use getColumnState');
|
119 | return this.getColumnState();
|
120 | }
|
121 | public resetState(): void {
|
122 | console.error('ag-Grid: resetState is deprecated, use resetColumnState');
|
123 | this.resetColumnState();
|
124 | }
|
125 |
|
126 | public getAggregationColumns(): Column[] {
|
127 | console.error('ag-Grid: getAggregationColumns is deprecated, use getValueColumns');
|
128 | return this.columnController.getValueColumns();
|
129 | }
|
130 |
|
131 | public removeAggregationColumn(colKey: (string|Column)): void {
|
132 | console.error('ag-Grid: removeAggregationColumn is deprecated, use removeValueColumn');
|
133 | this.columnController.removeValueColumn(colKey, 'api');
|
134 | }
|
135 |
|
136 | public removeAggregationColumns(colKeys: (string|Column)[]): void {
|
137 | console.error('ag-Grid: removeAggregationColumns is deprecated, use removeValueColumns');
|
138 | this.columnController.removeValueColumns(colKeys, 'api');
|
139 | }
|
140 |
|
141 | public addAggregationColumn(colKey: (string|Column)): void {
|
142 | console.error('ag-Grid: addAggregationColumn is deprecated, use addValueColumn');
|
143 | this.columnController.addValueColumn(colKey, 'api');
|
144 | }
|
145 |
|
146 | public addAggregationColumns(colKeys: (string|Column)[]): void {
|
147 | console.error('ag-Grid: addAggregationColumns is deprecated, use addValueColumns');
|
148 | this.columnController.addValueColumns(colKeys, 'api');
|
149 | }
|
150 |
|
151 | public setColumnAggFunction(column: Column, aggFunc: string): void {
|
152 | console.error('ag-Grid: setColumnAggFunction is deprecated, use setColumnAggFunc');
|
153 | this.columnController.setColumnAggFunc(column, aggFunc, 'api');
|
154 | }
|
155 |
|
156 | public getDisplayNameForCol(column: any): string {
|
157 | console.error('ag-Grid: getDisplayNameForCol is deprecated, use getDisplayNameForColumn');
|
158 | return this.getDisplayNameForColumn(column, null);
|
159 | }
|
160 | } |
\ | No newline at end of file |