UNPKG

106 kBJavaScriptView Raw
1/**
2 * ag-grid - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
3 * @version v18.1.2
4 * @link http://www.ag-grid.com/
5 * @license MIT
6 */
7"use strict";
8var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
9 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
11 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
12 return c > 3 && r && Object.defineProperty(target, key, r), r;
13};
14var __metadata = (this && this.__metadata) || function (k, v) {
15 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
16};
17var __param = (this && this.__param) || function (paramIndex, decorator) {
18 return function (target, key) { decorator(target, key, paramIndex); }
19};
20Object.defineProperty(exports, "__esModule", { value: true });
21var utils_1 = require("../utils");
22var columnGroup_1 = require("../entities/columnGroup");
23var column_1 = require("../entities/column");
24var gridOptionsWrapper_1 = require("../gridOptionsWrapper");
25var expressionService_1 = require("../valueService/expressionService");
26var balancedColumnTreeBuilder_1 = require("./balancedColumnTreeBuilder");
27var displayedGroupCreator_1 = require("./displayedGroupCreator");
28var autoWidthCalculator_1 = require("../rendering/autoWidthCalculator");
29var eventService_1 = require("../eventService");
30var columnUtils_1 = require("./columnUtils");
31var logger_1 = require("../logger");
32var events_1 = require("../events");
33var originalColumnGroup_1 = require("../entities/originalColumnGroup");
34var groupInstanceIdCreator_1 = require("./groupInstanceIdCreator");
35var context_1 = require("../context/context");
36var columnAnimationService_1 = require("../rendering/columnAnimationService");
37var autoGroupColService_1 = require("./autoGroupColService");
38var valueCache_1 = require("../valueService/valueCache");
39var gridApi_1 = require("../gridApi");
40var columnApi_1 = require("./columnApi");
41var ColumnController = (function () {
42 function ColumnController() {
43 // header row count, based on user provided columns
44 this.primaryHeaderRowCount = 0;
45 this.secondaryHeaderRowCount = 0;
46 this.secondaryColumnsPresent = false;
47 // header row count, either above, or based on pivoting if we are pivoting
48 this.gridHeaderRowCount = 0;
49 // these are the lists used by the rowRenderer to render nodes. almost the leaf nodes of the above
50 // displayed trees, however it also takes into account if the groups are open or not.
51 this.displayedLeftColumns = [];
52 this.displayedRightColumns = [];
53 this.displayedCenterColumns = [];
54 // all three lists above combined
55 this.allDisplayedColumns = [];
56 // same as above, except trimmed down to only columns within the viewport
57 this.allDisplayedVirtualColumns = [];
58 this.allDisplayedCenterVirtualColumns = [];
59 this.rowGroupColumns = [];
60 this.valueColumns = [];
61 this.pivotColumns = [];
62 this.ready = false;
63 this.autoGroupsNeedBuilding = false;
64 this.pivotMode = false;
65 this.bodyWidth = 0;
66 this.leftWidth = 0;
67 this.rightWidth = 0;
68 this.bodyWidthDirty = true;
69 }
70 ColumnController.prototype.init = function () {
71 var pivotMode = this.gridOptionsWrapper.isPivotMode();
72 this.suppressColumnVirtualisation = this.gridOptionsWrapper.isSuppressColumnVirtualisation();
73 if (this.isPivotSettingAllowed(pivotMode)) {
74 this.pivotMode = pivotMode;
75 }
76 this.usingTreeData = this.gridOptionsWrapper.isTreeData();
77 };
78 ColumnController.prototype.isAutoRowHeightActive = function () {
79 return this.autoRowHeightColumns && this.autoRowHeightColumns.length > 0;
80 };
81 ColumnController.prototype.getAllAutoRowHeightCols = function () {
82 return this.autoRowHeightColumns;
83 };
84 ColumnController.prototype.setVirtualViewportLeftAndRight = function () {
85 if (this.gridOptionsWrapper.isEnableRtl()) {
86 this.viewportLeft = this.bodyWidth - this.scrollPosition - this.scrollWidth;
87 this.viewportRight = this.bodyWidth - this.scrollPosition;
88 }
89 else {
90 this.viewportLeft = this.scrollPosition;
91 this.viewportRight = this.scrollWidth + this.scrollPosition;
92 }
93 };
94 // used by clipboard service, to know what columns to paste into
95 ColumnController.prototype.getDisplayedColumnsStartingAt = function (column) {
96 var currentColumn = column;
97 var result = [];
98 while (utils_1.Utils.exists(currentColumn)) {
99 result.push(currentColumn);
100 currentColumn = this.getDisplayedColAfter(currentColumn);
101 }
102 return result;
103 };
104 // checks what columns are currently displayed due to column virtualisation. fires an event
105 // if the list of columns has changed.
106 // + setColumnWidth(), setVirtualViewportPosition(), setColumnDefs(), sizeColumnsToFit()
107 ColumnController.prototype.checkDisplayedVirtualColumns = function () {
108 // check displayCenterColumnTree exists first, as it won't exist when grid is initialising
109 if (utils_1.Utils.exists(this.displayedCenterColumns)) {
110 var hashBefore = this.allDisplayedVirtualColumns.map(function (column) { return column.getId(); }).join('#');
111 this.updateVirtualSets();
112 var hashAfter = this.allDisplayedVirtualColumns.map(function (column) { return column.getId(); }).join('#');
113 if (hashBefore !== hashAfter) {
114 var event_1 = {
115 type: events_1.Events.EVENT_VIRTUAL_COLUMNS_CHANGED,
116 api: this.gridApi,
117 columnApi: this.columnApi
118 };
119 this.eventService.dispatchEvent(event_1);
120 }
121 }
122 };
123 ColumnController.prototype.setVirtualViewportPosition = function (scrollWidth, scrollPosition) {
124 if (scrollWidth !== this.scrollWidth || scrollPosition !== this.scrollPosition || this.bodyWidthDirty) {
125 this.scrollWidth = scrollWidth;
126 this.scrollPosition = scrollPosition;
127 // we need to call setVirtualViewportLeftAndRight() at least once after the body width changes,
128 // as the viewport can stay the same, but in RTL, if body width changes, we need to work out the
129 // virtual columns again
130 this.bodyWidthDirty = true;
131 this.setVirtualViewportLeftAndRight();
132 if (this.ready) {
133 this.checkDisplayedVirtualColumns();
134 }
135 }
136 };
137 ColumnController.prototype.isPivotMode = function () {
138 return this.pivotMode;
139 };
140 ColumnController.prototype.isPivotSettingAllowed = function (pivot) {
141 if (pivot) {
142 if (this.gridOptionsWrapper.isTreeData()) {
143 console.warn("ag-Grid: Pivot mode not available in conjunction Tree Data i.e. 'gridOptions.treeData: true'");
144 return false;
145 }
146 else {
147 return true;
148 }
149 }
150 else {
151 return true;
152 }
153 };
154 ColumnController.prototype.setPivotMode = function (pivotMode, source) {
155 if (source === void 0) { source = "api"; }
156 if (pivotMode === this.pivotMode) {
157 return;
158 }
159 if (!this.isPivotSettingAllowed(this.pivotMode)) {
160 return;
161 }
162 this.pivotMode = pivotMode;
163 this.updateDisplayedColumns(source);
164 var event = {
165 type: events_1.Events.EVENT_COLUMN_PIVOT_MODE_CHANGED,
166 api: this.gridApi,
167 columnApi: this.columnApi
168 };
169 this.eventService.dispatchEvent(event);
170 };
171 ColumnController.prototype.getSecondaryPivotColumn = function (pivotKeys, valueColKey) {
172 if (!this.secondaryColumnsPresent) {
173 return null;
174 }
175 var valueColumnToFind = this.getPrimaryColumn(valueColKey);
176 var foundColumn = null;
177 this.secondaryColumns.forEach(function (column) {
178 var thisPivotKeys = column.getColDef().pivotKeys;
179 var pivotValueColumn = column.getColDef().pivotValueColumn;
180 var pivotKeyMatches = utils_1.Utils.compareArrays(thisPivotKeys, pivotKeys);
181 var pivotValueMatches = pivotValueColumn === valueColumnToFind;
182 if (pivotKeyMatches && pivotValueMatches) {
183 foundColumn = column;
184 }
185 });
186 return foundColumn;
187 };
188 ColumnController.prototype.setBeans = function (loggerFactory) {
189 this.logger = loggerFactory.create('ColumnController');
190 };
191 ColumnController.prototype.setFirstRightAndLastLeftPinned = function (source) {
192 var lastLeft;
193 var firstRight;
194 if (this.gridOptionsWrapper.isEnableRtl()) {
195 lastLeft = this.displayedLeftColumns ? this.displayedLeftColumns[0] : null;
196 firstRight = this.displayedRightColumns ? this.displayedRightColumns[this.displayedRightColumns.length - 1] : null;
197 }
198 else {
199 lastLeft = this.displayedLeftColumns ? this.displayedLeftColumns[this.displayedLeftColumns.length - 1] : null;
200 firstRight = this.displayedRightColumns ? this.displayedRightColumns[0] : null;
201 }
202 this.gridColumns.forEach(function (column) {
203 column.setLastLeftPinned(column === lastLeft, source);
204 column.setFirstRightPinned(column === firstRight, source);
205 });
206 };
207 ColumnController.prototype.autoSizeColumns = function (keys, source) {
208 // because of column virtualisation, we can only do this function on columns that are
209 // actually rendered, as non-rendered columns (outside the viewport and not rendered
210 // due to column virtualisation) are not present. this can result in all rendered columns
211 // getting narrowed, which in turn introduces more rendered columns on the RHS which
212 // did not get autosized in the original run, leaving the visible grid with columns on
213 // the LHS sized, but RHS no. so we keep looping through teh visible columns until
214 // no more cols are available (rendered) to be resized
215 var _this = this;
216 if (source === void 0) { source = "api"; }
217 // keep track of which cols we have resized in here
218 var columnsAutosized = [];
219 // initialise with anything except 0 so that while loop executs at least once
220 var changesThisTimeAround = -1;
221 while (changesThisTimeAround !== 0) {
222 changesThisTimeAround = 0;
223 this.actionOnGridColumns(keys, function (column) {
224 // if already autosized, skip it
225 if (columnsAutosized.indexOf(column) >= 0) {
226 return;
227 }
228 // get how wide this col should be
229 var preferredWidth = _this.autoWidthCalculator.getPreferredWidthForColumn(column);
230 // preferredWidth = -1 if this col is not on the screen
231 if (preferredWidth > 0) {
232 var newWidth = _this.normaliseColumnWidth(column, preferredWidth);
233 column.setActualWidth(newWidth, source);
234 columnsAutosized.push(column);
235 changesThisTimeAround++;
236 }
237 return true;
238 }, source);
239 }
240 if (columnsAutosized.length > 0) {
241 var event_2 = {
242 type: events_1.Events.EVENT_COLUMN_RESIZED,
243 columns: columnsAutosized,
244 column: columnsAutosized.length === 1 ? columnsAutosized[0] : null,
245 finished: true,
246 api: this.gridApi,
247 columnApi: this.columnApi,
248 source: "autosizeColumns"
249 };
250 this.eventService.dispatchEvent(event_2);
251 }
252 };
253 ColumnController.prototype.autoSizeColumn = function (key, source) {
254 if (source === void 0) { source = "api"; }
255 this.autoSizeColumns([key], source);
256 };
257 ColumnController.prototype.autoSizeAllColumns = function (source) {
258 if (source === void 0) { source = "api"; }
259 var allDisplayedColumns = this.getAllDisplayedColumns();
260 this.autoSizeColumns(allDisplayedColumns, source);
261 };
262 ColumnController.prototype.getColumnsFromTree = function (rootColumns) {
263 var result = [];
264 recursiveFindColumns(rootColumns);
265 return result;
266 function recursiveFindColumns(childColumns) {
267 for (var i = 0; i < childColumns.length; i++) {
268 var child = childColumns[i];
269 if (child instanceof column_1.Column) {
270 result.push(child);
271 }
272 else if (child instanceof originalColumnGroup_1.OriginalColumnGroup) {
273 recursiveFindColumns(child.getChildren());
274 }
275 }
276 }
277 };
278 ColumnController.prototype.getAllDisplayedColumnGroups = function () {
279 if (this.displayedLeftColumnTree && this.displayedRightColumnTree && this.displayedCentreColumnTree) {
280 return this.displayedLeftColumnTree
281 .concat(this.displayedCentreColumnTree)
282 .concat(this.displayedRightColumnTree);
283 }
284 else {
285 return null;
286 }
287 };
288 // + columnSelectPanel
289 ColumnController.prototype.getPrimaryColumnTree = function () {
290 return this.primaryBalancedTree;
291 };
292 // + gridPanel -> for resizing the body and setting top margin
293 ColumnController.prototype.getHeaderRowCount = function () {
294 return this.gridHeaderRowCount;
295 };
296 // + headerRenderer -> setting pinned body width
297 ColumnController.prototype.getLeftDisplayedColumnGroups = function () {
298 return this.displayedLeftColumnTree;
299 };
300 // + headerRenderer -> setting pinned body width
301 ColumnController.prototype.getRightDisplayedColumnGroups = function () {
302 return this.displayedRightColumnTree;
303 };
304 // + headerRenderer -> setting pinned body width
305 ColumnController.prototype.getCenterDisplayedColumnGroups = function () {
306 return this.displayedCentreColumnTree;
307 };
308 ColumnController.prototype.getDisplayedColumnGroups = function (type) {
309 switch (type) {
310 case column_1.Column.PINNED_LEFT: return this.getLeftDisplayedColumnGroups();
311 case column_1.Column.PINNED_RIGHT: return this.getRightDisplayedColumnGroups();
312 default: return this.getCenterDisplayedColumnGroups();
313 }
314 };
315 // gridPanel -> ensureColumnVisible
316 ColumnController.prototype.isColumnDisplayed = function (column) {
317 return this.getAllDisplayedColumns().indexOf(column) >= 0;
318 };
319 // + csvCreator
320 ColumnController.prototype.getAllDisplayedColumns = function () {
321 return this.allDisplayedColumns;
322 };
323 ColumnController.prototype.getAllDisplayedVirtualColumns = function () {
324 return this.allDisplayedVirtualColumns;
325 };
326 ColumnController.prototype.getDisplayedLeftColumnsForRow = function (rowNode) {
327 if (!this.colSpanActive) {
328 return this.displayedLeftColumns;
329 }
330 else {
331 return this.getDisplayedColumnsForRow(rowNode, this.displayedLeftColumns);
332 }
333 };
334 ColumnController.prototype.getDisplayedRightColumnsForRow = function (rowNode) {
335 if (!this.colSpanActive) {
336 return this.displayedRightColumns;
337 }
338 else {
339 return this.getDisplayedColumnsForRow(rowNode, this.displayedRightColumns);
340 }
341 };
342 ColumnController.prototype.getDisplayedColumnsForRow = function (rowNode, displayedColumns, filterCallback, emptySpaceBeforeColumn) {
343 var result = [];
344 var lastConsideredCol = null;
345 var _loop_1 = function (i) {
346 var col = displayedColumns[i];
347 var colSpan = col.getColSpan(rowNode);
348 var columnsToCheckFilter = [col];
349 if (colSpan > 1) {
350 var colsToRemove = colSpan - 1;
351 for (var j = 1; j <= colsToRemove; j++) {
352 columnsToCheckFilter.push(displayedColumns[i + j]);
353 }
354 i += colsToRemove;
355 }
356 // see which cols we should take out for column virtualisation
357 var filterPasses;
358 if (filterCallback) {
359 // if user provided a callback, means some columns may not be in the viewport.
360 // the user will NOT provide a callback if we are talking about pinned areas,
361 // as pinned areas have no horizontal scroll and do not virtualise the columns.
362 // if lots of columns, that means column spanning, and we set filterPasses = true
363 // if one or more of the columns spanned pass the filter.
364 filterPasses = false;
365 columnsToCheckFilter.forEach(function (colForFilter) {
366 if (filterCallback(colForFilter))
367 filterPasses = true;
368 });
369 }
370 else {
371 filterPasses = true;
372 }
373 if (filterPasses) {
374 if (result.length === 0 && lastConsideredCol) {
375 var gapBeforeColumn = emptySpaceBeforeColumn ? emptySpaceBeforeColumn(col) : false;
376 if (gapBeforeColumn) {
377 result.push(lastConsideredCol);
378 }
379 }
380 result.push(col);
381 }
382 lastConsideredCol = col;
383 out_i_1 = i;
384 };
385 var out_i_1;
386 for (var i = 0; i < displayedColumns.length; i++) {
387 _loop_1(i);
388 i = out_i_1;
389 }
390 return result;
391 };
392 // + rowRenderer
393 // if we are not column spanning, this just returns back the virtual centre columns,
394 // however if we are column spanning, then different rows can have different virtual
395 // columns, so we have to work out the list for each individual row.
396 ColumnController.prototype.getAllDisplayedCenterVirtualColumnsForRow = function (rowNode) {
397 var _this = this;
398 if (!this.colSpanActive) {
399 return this.allDisplayedCenterVirtualColumns;
400 }
401 var emptySpaceBeforeColumn = function (col) { return col.getLeft() > _this.viewportLeft; };
402 // if doing column virtualisation, then we filter based on the viewport.
403 var filterCallback = this.suppressColumnVirtualisation ? null : this.isColumnInViewport.bind(this);
404 return this.getDisplayedColumnsForRow(rowNode, this.displayedCenterColumns, filterCallback, emptySpaceBeforeColumn);
405 };
406 ColumnController.prototype.isColumnInViewport = function (col) {
407 var columnLeft = col.getLeft();
408 var columnRight = col.getLeft() + col.getActualWidth();
409 var columnToMuchLeft = columnLeft < this.viewportLeft && columnRight < this.viewportLeft;
410 var columnToMuchRight = columnLeft > this.viewportRight && columnRight > this.viewportRight;
411 return !columnToMuchLeft && !columnToMuchRight;
412 };
413 // used by:
414 // + angularGrid -> setting pinned body width
415 // note: this should be cached
416 ColumnController.prototype.getPinnedLeftContainerWidth = function () {
417 return this.getWidthOfColsInList(this.displayedLeftColumns);
418 };
419 // note: this should be cached
420 ColumnController.prototype.getPinnedRightContainerWidth = function () {
421 return this.getWidthOfColsInList(this.displayedRightColumns);
422 };
423 ColumnController.prototype.updatePrimaryColumnList = function (keys, masterList, actionIsAdd, columnCallback, eventType, source) {
424 var _this = this;
425 if (source === void 0) { source = "api"; }
426 if (utils_1.Utils.missingOrEmpty(keys)) {
427 return;
428 }
429 var atLeastOne = false;
430 keys.forEach(function (key) {
431 var columnToAdd = _this.getPrimaryColumn(key);
432 if (!columnToAdd) {
433 return;
434 }
435 if (actionIsAdd) {
436 if (masterList.indexOf(columnToAdd) >= 0) {
437 return;
438 }
439 masterList.push(columnToAdd);
440 }
441 else {
442 if (masterList.indexOf(columnToAdd) < 0) {
443 return;
444 }
445 utils_1.Utils.removeFromArray(masterList, columnToAdd);
446 }
447 columnCallback(columnToAdd);
448 atLeastOne = true;
449 });
450 if (!atLeastOne) {
451 return;
452 }
453 if (this.autoGroupsNeedBuilding) {
454 this.updateGridColumns();
455 }
456 this.updateDisplayedColumns(source);
457 var event = {
458 type: eventType,
459 columns: masterList,
460 column: masterList.length === 1 ? masterList[0] : null,
461 api: this.gridApi,
462 columnApi: this.columnApi,
463 source: source
464 };
465 this.eventService.dispatchEvent(event);
466 };
467 ColumnController.prototype.setRowGroupColumns = function (colKeys, source) {
468 if (source === void 0) { source = "api"; }
469 this.autoGroupsNeedBuilding = true;
470 this.setPrimaryColumnList(colKeys, this.rowGroupColumns, events_1.Events.EVENT_COLUMN_ROW_GROUP_CHANGED, this.setRowGroupActive.bind(this), source);
471 };
472 ColumnController.prototype.setRowGroupActive = function (active, column, source) {
473 if (active === column.isRowGroupActive()) {
474 return;
475 }
476 column.setRowGroupActive(active, source);
477 if (!active && !this.gridOptionsWrapper.isSuppressMakeColumnVisibleAfterUnGroup()) {
478 column.setVisible(true, source);
479 }
480 };
481 ColumnController.prototype.addRowGroupColumn = function (key, source) {
482 if (source === void 0) { source = "api"; }
483 this.addRowGroupColumns([key], source);
484 };
485 ColumnController.prototype.addRowGroupColumns = function (keys, source) {
486 if (source === void 0) { source = "api"; }
487 this.autoGroupsNeedBuilding = true;
488 this.updatePrimaryColumnList(keys, this.rowGroupColumns, true, this.setRowGroupActive.bind(this, true), events_1.Events.EVENT_COLUMN_ROW_GROUP_CHANGED, source);
489 };
490 ColumnController.prototype.removeRowGroupColumns = function (keys, source) {
491 if (source === void 0) { source = "api"; }
492 this.autoGroupsNeedBuilding = true;
493 this.updatePrimaryColumnList(keys, this.rowGroupColumns, false, this.setRowGroupActive.bind(this, false), events_1.Events.EVENT_COLUMN_ROW_GROUP_CHANGED, source);
494 };
495 ColumnController.prototype.removeRowGroupColumn = function (key, source) {
496 if (source === void 0) { source = "api"; }
497 this.removeRowGroupColumns([key], source);
498 };
499 ColumnController.prototype.addPivotColumns = function (keys, source) {
500 if (source === void 0) { source = "api"; }
501 this.updatePrimaryColumnList(keys, this.pivotColumns, true, function (column) { return column.setPivotActive(true, source); }, events_1.Events.EVENT_COLUMN_PIVOT_CHANGED, source);
502 };
503 ColumnController.prototype.setPivotColumns = function (colKeys, source) {
504 if (source === void 0) { source = "api"; }
505 this.setPrimaryColumnList(colKeys, this.pivotColumns, events_1.Events.EVENT_COLUMN_PIVOT_CHANGED, function (added, column) {
506 column.setPivotActive(added, source);
507 }, source);
508 };
509 ColumnController.prototype.addPivotColumn = function (key, source) {
510 if (source === void 0) { source = "api"; }
511 this.addPivotColumns([key], source);
512 };
513 ColumnController.prototype.removePivotColumns = function (keys, source) {
514 if (source === void 0) { source = "api"; }
515 this.updatePrimaryColumnList(keys, this.pivotColumns, false, function (column) { return column.setPivotActive(false, source); }, events_1.Events.EVENT_COLUMN_PIVOT_CHANGED, source);
516 };
517 ColumnController.prototype.removePivotColumn = function (key, source) {
518 if (source === void 0) { source = "api"; }
519 this.removePivotColumns([key], source);
520 };
521 ColumnController.prototype.setPrimaryColumnList = function (colKeys, masterList, eventName, columnCallback, source) {
522 var _this = this;
523 masterList.length = 0;
524 if (utils_1.Utils.exists(colKeys)) {
525 colKeys.forEach(function (key) {
526 var column = _this.getPrimaryColumn(key);
527 masterList.push(column);
528 });
529 }
530 this.primaryColumns.forEach(function (column) {
531 var added = masterList.indexOf(column) >= 0;
532 columnCallback(added, column);
533 });
534 if (this.autoGroupsNeedBuilding) {
535 this.updateGridColumns();
536 }
537 this.updateDisplayedColumns(source);
538 var event = {
539 type: eventName,
540 columns: masterList,
541 column: masterList.length === 1 ? masterList[0] : null,
542 api: this.gridApi,
543 columnApi: this.columnApi,
544 source: source
545 };
546 this.eventService.dispatchEvent(event);
547 };
548 ColumnController.prototype.setValueColumns = function (colKeys, source) {
549 if (source === void 0) { source = "api"; }
550 this.setPrimaryColumnList(colKeys, this.valueColumns, events_1.Events.EVENT_COLUMN_VALUE_CHANGED, this.setValueActive.bind(this), source);
551 };
552 ColumnController.prototype.setValueActive = function (active, column, source) {
553 if (active === column.isValueActive()) {
554 return;
555 }
556 column.setValueActive(active, source);
557 if (active && !column.getAggFunc()) {
558 var defaultAggFunc = this.aggFuncService.getDefaultAggFunc(column);
559 column.setAggFunc(defaultAggFunc);
560 }
561 };
562 ColumnController.prototype.addValueColumns = function (keys, source) {
563 if (source === void 0) { source = "api"; }
564 this.updatePrimaryColumnList(keys, this.valueColumns, true, this.setValueActive.bind(this, true), events_1.Events.EVENT_COLUMN_VALUE_CHANGED, source);
565 };
566 ColumnController.prototype.addValueColumn = function (colKey, source) {
567 if (source === void 0) { source = "api"; }
568 this.addValueColumns([colKey], source);
569 };
570 ColumnController.prototype.removeValueColumn = function (colKey, source) {
571 if (source === void 0) { source = "api"; }
572 this.removeValueColumns([colKey], source);
573 };
574 ColumnController.prototype.removeValueColumns = function (keys, source) {
575 if (source === void 0) { source = "api"; }
576 this.updatePrimaryColumnList(keys, this.valueColumns, false, this.setValueActive.bind(this, false), events_1.Events.EVENT_COLUMN_VALUE_CHANGED, source);
577 };
578 // returns the width we can set to this col, taking into consideration min and max widths
579 ColumnController.prototype.normaliseColumnWidth = function (column, newWidth) {
580 if (newWidth < column.getMinWidth()) {
581 newWidth = column.getMinWidth();
582 }
583 if (column.isGreaterThanMax(newWidth)) {
584 newWidth = column.getMaxWidth();
585 }
586 return newWidth;
587 };
588 ColumnController.prototype.getPrimaryOrGridColumn = function (key) {
589 var column = this.getPrimaryColumn(key);
590 if (column) {
591 return column;
592 }
593 else {
594 return this.getGridColumn(key);
595 }
596 };
597 ColumnController.prototype.setColumnWidth = function (key, // @key - the column who's size we want to change
598 newWidth, // @newWidth - width in pixels
599 shiftKey, // @takeFromAdjacent - if user has 'shift' pressed, then pixels are taken from adjacent column
600 finished, // @finished - ends up in the event, tells the user if more events are to come
601 source) {
602 if (source === void 0) { source = "api"; }
603 var col = this.getPrimaryOrGridColumn(key);
604 if (!col) {
605 return;
606 }
607 var sets = [];
608 sets.push({
609 width: newWidth,
610 ratios: [1],
611 columns: [col]
612 });
613 // if user wants to do shift resize by default, then we invert the shift operation
614 var defaultIsShift = this.gridOptionsWrapper.getColResizeDefault() === 'shift';
615 if (defaultIsShift) {
616 shiftKey = !shiftKey;
617 }
618 if (shiftKey) {
619 var otherCol = this.getDisplayedColAfter(col);
620 if (!otherCol) {
621 return;
622 }
623 var widthDiff = col.getActualWidth() - newWidth;
624 var otherColWidth = otherCol.getActualWidth() + widthDiff;
625 sets.push({
626 width: otherColWidth,
627 ratios: [1],
628 columns: [otherCol]
629 });
630 }
631 this.resizeColumnSets(sets, finished, source);
632 };
633 ColumnController.prototype.checkMinAndMaxWidthsForSet = function (columnResizeSet) {
634 var columns = columnResizeSet.columns, width = columnResizeSet.width;
635 // every col has a min width, so sum them all up and see if we have enough room
636 // for all the min widths
637 var minWidthAccumulated = 0;
638 var maxWidthAccumulated = 0;
639 var maxWidthActive = true;
640 columns.forEach(function (col) {
641 minWidthAccumulated += col.getMinWidth();
642 if (col.getMaxWidth() > 0) {
643 maxWidthAccumulated += col.getMaxWidth();
644 }
645 else {
646 // if at least one columns has no max width, it means the group of columns
647 // then has no max width, as at least one column can take as much width as possible
648 maxWidthActive = false;
649 }
650 });
651 var minWidthPasses = width >= minWidthAccumulated;
652 var maxWidthPasses = !maxWidthActive || (width <= maxWidthAccumulated);
653 return minWidthPasses && maxWidthPasses;
654 };
655 // method takes sets of columns and resizes them. either all sets will be resized, or nothing
656 // be resized. this is used for example when user tries to resize a group and holds shift key,
657 // then both the current group (grows), and the adjacent group (shrinks), will get resized,
658 // so that's two sets for this method.
659 ColumnController.prototype.resizeColumnSets = function (resizeSets, finished, source) {
660 var passMinMaxCheck = utils_1.Utils.every(resizeSets, this.checkMinAndMaxWidthsForSet.bind(this));
661 if (!passMinMaxCheck) {
662 return;
663 }
664 var changedCols = [];
665 var allCols = [];
666 resizeSets.forEach(function (set) {
667 var width = set.width, columns = set.columns, ratios = set.ratios;
668 // keep track of pixels used, and last column gets the remaining,
669 // to cater for rounding errors, and min width adjustments
670 var newWidths = {};
671 var finishedCols = {};
672 columns.forEach(function (col) { return allCols.push(col); });
673 // the loop below goes through each col. if a col exceeds it's min/max width,
674 // it then gets set to its min/max width and the column is removed marked as 'finished'
675 // and the calculation is done again leaving this column out. take for example columns
676 // {A, width: 50, maxWidth: 100}
677 // {B, width: 50}
678 // {C, width: 50}
679 // and then the set is set to width 600 - on the first pass the grid tries to set each column
680 // to 200. it checks A and sees 200 > 100 and so sets the width to 100. col A is then marked
681 // as 'finished' and the calculation is done again with the remaining cols B and C, which end up
682 // splitting the remaining 500 pixels.
683 var finishedColsGrew = true;
684 var loopCount = 0;
685 var _loop_2 = function () {
686 loopCount++;
687 if (loopCount > 1000) {
688 // this should never happen, but in the future, someone might introduce a bug here,
689 // so we stop the browser from hanging and report bug properly
690 console.error('ag-Grid: infinite loop in resizeColumnSets');
691 return "break";
692 }
693 finishedColsGrew = false;
694 var subsetCols = [];
695 var subsetRatios = [];
696 var subsetRatioTotal = 0;
697 var pixelsToDistribute = width;
698 columns.forEach(function (col, index) {
699 var thisColFinished = finishedCols[col.getId()];
700 if (thisColFinished) {
701 pixelsToDistribute -= newWidths[col.getId()];
702 }
703 else {
704 subsetCols.push(col);
705 var ratioThisCol = ratios[index];
706 subsetRatioTotal += ratioThisCol;
707 subsetRatios.push(ratioThisCol);
708 }
709 });
710 // because we are not using all of the ratios (cols can be missing),
711 // we scale the ratio. if all columns are included, then subsetRatioTotal=1,
712 // and so the ratioScale will be 1.
713 var ratioScale = 1 / subsetRatioTotal;
714 subsetCols.forEach(function (col, index) {
715 var lastCol = index === (subsetCols.length - 1);
716 var colNewWidth;
717 if (lastCol) {
718 colNewWidth = pixelsToDistribute;
719 }
720 else {
721 colNewWidth = Math.round(ratios[index] * width * ratioScale);
722 pixelsToDistribute -= colNewWidth;
723 }
724 if (colNewWidth < col.getMinWidth()) {
725 colNewWidth = col.getMinWidth();
726 finishedCols[col.getId()] = true;
727 finishedColsGrew = true;
728 }
729 else if (col.getMaxWidth() > 0 && colNewWidth > col.getMaxWidth()) {
730 colNewWidth = col.getMaxWidth();
731 finishedCols[col.getId()] = true;
732 finishedColsGrew = true;
733 }
734 newWidths[col.getId()] = colNewWidth;
735 });
736 };
737 while (finishedColsGrew) {
738 var state_1 = _loop_2();
739 if (state_1 === "break")
740 break;
741 }
742 columns.forEach(function (col) {
743 var newWidth = newWidths[col.getId()];
744 if (col.getActualWidth() !== newWidth) {
745 col.setActualWidth(newWidth);
746 changedCols.push(col);
747 }
748 });
749 });
750 // if no cols changed, then no need to update more or send event.
751 var atLeastOneColChanged = changedCols.length > 0;
752 if (atLeastOneColChanged) {
753 this.setLeftValues(source);
754 this.updateBodyWidths();
755 this.checkDisplayedVirtualColumns();
756 }
757 // check for change first, to avoid unnecessary firing of events
758 // however we always fire 'finished' events. this is important
759 // when groups are resized, as if the group is changing slowly,
760 // eg 1 pixel at a time, then each change will fire change events
761 // in all the columns in the group, but only one with get the pixel.
762 if (atLeastOneColChanged || finished) {
763 var event_3 = {
764 type: events_1.Events.EVENT_COLUMN_RESIZED,
765 columns: allCols,
766 column: allCols.length === 1 ? allCols[0] : null,
767 finished: finished,
768 api: this.gridApi,
769 columnApi: this.columnApi,
770 source: source
771 };
772 this.eventService.dispatchEvent(event_3);
773 }
774 };
775 ColumnController.prototype.setColumnAggFunc = function (column, aggFunc, source) {
776 if (source === void 0) { source = "api"; }
777 column.setAggFunc(aggFunc);
778 var event = {
779 type: events_1.Events.EVENT_COLUMN_VALUE_CHANGED,
780 columns: [column],
781 column: column,
782 api: this.gridApi,
783 columnApi: this.columnApi,
784 source: source
785 };
786 this.eventService.dispatchEvent(event);
787 };
788 ColumnController.prototype.moveRowGroupColumn = function (fromIndex, toIndex, source) {
789 if (source === void 0) { source = "api"; }
790 var column = this.rowGroupColumns[fromIndex];
791 this.rowGroupColumns.splice(fromIndex, 1);
792 this.rowGroupColumns.splice(toIndex, 0, column);
793 var event = {
794 type: events_1.Events.EVENT_COLUMN_ROW_GROUP_CHANGED,
795 columns: this.rowGroupColumns,
796 column: this.rowGroupColumns.length === 1 ? this.rowGroupColumns[0] : null,
797 api: this.gridApi,
798 columnApi: this.columnApi,
799 source: source
800 };
801 this.eventService.dispatchEvent(event);
802 };
803 ColumnController.prototype.moveColumns = function (columnsToMoveKeys, toIndex, source) {
804 if (source === void 0) { source = "api"; }
805 this.columnAnimationService.start();
806 if (toIndex > this.gridColumns.length - columnsToMoveKeys.length) {
807 console.warn('ag-Grid: tried to insert columns in invalid location, toIndex = ' + toIndex);
808 console.warn('ag-Grid: remember that you should not count the moving columns when calculating the new index');
809 return;
810 }
811 // we want to pull all the columns out first and put them into an ordered list
812 var columnsToMove = this.getGridColumns(columnsToMoveKeys);
813 var failedRules = !this.doesMovePassRules(columnsToMove, toIndex);
814 if (failedRules) {
815 return;
816 }
817 utils_1.Utils.moveInArray(this.gridColumns, columnsToMove, toIndex);
818 this.updateDisplayedColumns(source);
819 var event = {
820 type: events_1.Events.EVENT_COLUMN_MOVED,
821 columns: columnsToMove,
822 column: columnsToMove.length === 1 ? columnsToMove[0] : null,
823 toIndex: toIndex,
824 api: this.gridApi,
825 columnApi: this.columnApi,
826 source: source
827 };
828 this.eventService.dispatchEvent(event);
829 this.columnAnimationService.finish();
830 };
831 ColumnController.prototype.doesMovePassRules = function (columnsToMove, toIndex) {
832 // make a copy of what the grid columns would look like after the move
833 var proposedColumnOrder = this.gridColumns.slice();
834 utils_1.Utils.moveInArray(proposedColumnOrder, columnsToMove, toIndex);
835 // then check that the new proposed order of the columns passes all rules
836 if (!this.doesMovePassMarryChildren(proposedColumnOrder)) {
837 return false;
838 }
839 if (!this.doesMovePassLockedPositions(proposedColumnOrder)) {
840 return false;
841 }
842 return true;
843 };
844 ColumnController.prototype.doesMovePassLockedPositions = function (proposedColumnOrder) {
845 var foundNonLocked = false;
846 var rulePassed = true;
847 // go though the cols, see if any non-locked appear before any locked
848 proposedColumnOrder.forEach(function (col) {
849 if (col.isLockPosition()) {
850 if (foundNonLocked) {
851 rulePassed = false;
852 }
853 }
854 else {
855 foundNonLocked = true;
856 }
857 });
858 return rulePassed;
859 };
860 ColumnController.prototype.doesMovePassMarryChildren = function (allColumnsCopy) {
861 var rulePassed = true;
862 this.columnUtils.depthFirstOriginalTreeSearch(this.gridBalancedTree, function (child) {
863 if (!(child instanceof originalColumnGroup_1.OriginalColumnGroup)) {
864 return;
865 }
866 var columnGroup = child;
867 var marryChildren = columnGroup.getColGroupDef() && columnGroup.getColGroupDef().marryChildren;
868 if (!marryChildren) {
869 return;
870 }
871 var newIndexes = [];
872 columnGroup.getLeafColumns().forEach(function (col) {
873 var newColIndex = allColumnsCopy.indexOf(col);
874 newIndexes.push(newColIndex);
875 });
876 var maxIndex = Math.max.apply(Math, newIndexes);
877 var minIndex = Math.min.apply(Math, newIndexes);
878 // spread is how far the first column in this group is away from the last column
879 var spread = maxIndex - minIndex;
880 var maxSpread = columnGroup.getLeafColumns().length - 1;
881 // if the columns
882 if (spread > maxSpread) {
883 rulePassed = false;
884 }
885 // console.log(`maxIndex = ${maxIndex}, minIndex = ${minIndex}, spread = ${spread}, maxSpread = ${maxSpread}, fail = ${spread > (count-1)}`)
886 // console.log(allColumnsCopy.map( col => col.getColDef().field).join(','));
887 });
888 return rulePassed;
889 };
890 ColumnController.prototype.moveColumn = function (key, toIndex, source) {
891 if (source === void 0) { source = "api"; }
892 this.moveColumns([key], toIndex, source);
893 };
894 ColumnController.prototype.moveColumnByIndex = function (fromIndex, toIndex, source) {
895 if (source === void 0) { source = "api"; }
896 var column = this.gridColumns[fromIndex];
897 this.moveColumn(column, toIndex, source);
898 };
899 // used by:
900 // + angularGrid -> for setting body width
901 // + rowController -> setting main row widths (when inserting and resizing)
902 // need to cache this
903 ColumnController.prototype.getBodyContainerWidth = function () {
904 return this.bodyWidth;
905 };
906 ColumnController.prototype.getContainerWidth = function (pinned) {
907 switch (pinned) {
908 case column_1.Column.PINNED_LEFT: return this.leftWidth;
909 case column_1.Column.PINNED_RIGHT: return this.rightWidth;
910 default: return this.bodyWidth;
911 }
912 };
913 // after setColumnWidth or updateGroupsAndDisplayedColumns
914 ColumnController.prototype.updateBodyWidths = function () {
915 var newBodyWidth = this.getWidthOfColsInList(this.displayedCenterColumns);
916 var newLeftWidth = this.getWidthOfColsInList(this.displayedLeftColumns);
917 var newRightWidth = this.getWidthOfColsInList(this.displayedRightColumns);
918 // this is used by virtual col calculation, for RTL only, as a change to body width can impact displayed
919 // columns, due to RTL inverting the y coordinates
920 this.bodyWidthDirty = this.bodyWidth !== newBodyWidth;
921 var atLeastOneChanged = this.bodyWidth !== newBodyWidth || this.leftWidth !== newLeftWidth || this.rightWidth !== newRightWidth;
922 if (atLeastOneChanged) {
923 this.bodyWidth = newBodyWidth;
924 this.leftWidth = newLeftWidth;
925 this.rightWidth = newRightWidth;
926 // when this fires, it is picked up by the gridPanel, which ends up in
927 // gridPanel calling setWidthAndScrollPosition(), which in turn calls setVirtualViewportPosition()
928 var event_4 = {
929 type: events_1.Events.EVENT_DISPLAYED_COLUMNS_WIDTH_CHANGED,
930 api: this.gridApi,
931 columnApi: this.columnApi
932 };
933 this.eventService.dispatchEvent(event_4);
934 }
935 };
936 // + rowController
937 ColumnController.prototype.getValueColumns = function () {
938 return this.valueColumns ? this.valueColumns : [];
939 };
940 // + rowController
941 ColumnController.prototype.getPivotColumns = function () {
942 return this.pivotColumns ? this.pivotColumns : [];
943 };
944 // + clientSideRowModel
945 ColumnController.prototype.isPivotActive = function () {
946 return this.pivotColumns && this.pivotColumns.length > 0 && this.pivotMode;
947 };
948 // + toolPanel
949 ColumnController.prototype.getRowGroupColumns = function () {
950 return this.rowGroupColumns ? this.rowGroupColumns : [];
951 };
952 // + rowController -> while inserting rows
953 ColumnController.prototype.getDisplayedCenterColumns = function () {
954 return this.displayedCenterColumns;
955 };
956 // + rowController -> while inserting rows
957 ColumnController.prototype.getDisplayedLeftColumns = function () {
958 return this.displayedLeftColumns;
959 };
960 ColumnController.prototype.getDisplayedRightColumns = function () {
961 return this.displayedRightColumns;
962 };
963 ColumnController.prototype.getDisplayedColumns = function (type) {
964 switch (type) {
965 case column_1.Column.PINNED_LEFT: return this.getDisplayedLeftColumns();
966 case column_1.Column.PINNED_RIGHT: return this.getDisplayedRightColumns();
967 default: return this.getDisplayedCenterColumns();
968 }
969 };
970 // used by:
971 // + clientSideRowController -> sorting, building quick filter text
972 // + headerRenderer -> sorting (clearing icon)
973 ColumnController.prototype.getAllPrimaryColumns = function () {
974 return this.primaryColumns;
975 };
976 ColumnController.prototype.getAllColumnsForQuickFilter = function () {
977 return this.columnsForQuickFilter;
978 };
979 // + moveColumnController
980 ColumnController.prototype.getAllGridColumns = function () {
981 return this.gridColumns;
982 };
983 ColumnController.prototype.isEmpty = function () {
984 return utils_1.Utils.missingOrEmpty(this.gridColumns);
985 };
986 ColumnController.prototype.isRowGroupEmpty = function () {
987 return utils_1.Utils.missingOrEmpty(this.rowGroupColumns);
988 };
989 ColumnController.prototype.setColumnVisible = function (key, visible, source) {
990 if (source === void 0) { source = "api"; }
991 this.setColumnsVisible([key], visible, source);
992 };
993 ColumnController.prototype.setColumnsVisible = function (keys, visible, source) {
994 var _this = this;
995 if (source === void 0) { source = "api"; }
996 this.columnAnimationService.start();
997 this.actionOnGridColumns(keys, function (column) {
998 if (column.isVisible() !== visible) {
999 column.setVisible(visible, source);
1000 return true;
1001 }
1002 else {
1003 return false;
1004 }
1005 }, source, function () {
1006 var event = {
1007 type: events_1.Events.EVENT_COLUMN_VISIBLE,
1008 visible: visible,
1009 column: null,
1010 columns: null,
1011 api: _this.gridApi,
1012 columnApi: _this.columnApi,
1013 source: source
1014 };
1015 return event;
1016 });
1017 this.columnAnimationService.finish();
1018 };
1019 ColumnController.prototype.setColumnPinned = function (key, pinned, source) {
1020 if (source === void 0) { source = "api"; }
1021 this.setColumnsPinned([key], pinned, source);
1022 };
1023 ColumnController.prototype.setColumnsPinned = function (keys, pinned, source) {
1024 var _this = this;
1025 if (source === void 0) { source = "api"; }
1026 this.columnAnimationService.start();
1027 var actualPinned;
1028 if (pinned === true || pinned === column_1.Column.PINNED_LEFT) {
1029 actualPinned = column_1.Column.PINNED_LEFT;
1030 }
1031 else if (pinned === column_1.Column.PINNED_RIGHT) {
1032 actualPinned = column_1.Column.PINNED_RIGHT;
1033 }
1034 else {
1035 actualPinned = null;
1036 }
1037 this.actionOnGridColumns(keys, function (col) {
1038 if (col.getPinned() !== actualPinned) {
1039 col.setPinned(actualPinned);
1040 return true;
1041 }
1042 else {
1043 return false;
1044 }
1045 }, source, function () {
1046 var event = {
1047 type: events_1.Events.EVENT_COLUMN_PINNED,
1048 pinned: actualPinned,
1049 column: null,
1050 columns: null,
1051 api: _this.gridApi,
1052 columnApi: _this.columnApi,
1053 source: source
1054 };
1055 return event;
1056 });
1057 this.columnAnimationService.finish();
1058 };
1059 // does an action on a set of columns. provides common functionality for looking up the
1060 // columns based on key, getting a list of effected columns, and then updated the event
1061 // with either one column (if it was just one col) or a list of columns
1062 // used by: autoResize, setVisible, setPinned
1063 ColumnController.prototype.actionOnGridColumns = function (// the column keys this action will be on
1064 keys,
1065 // the action to do - if this returns false, the column was skipped
1066 // and won't be included in the event
1067 action,
1068 // should return back a column event of the right type
1069 source, createEvent) {
1070 var _this = this;
1071 if (utils_1.Utils.missingOrEmpty(keys)) {
1072 return;
1073 }
1074 var updatedColumns = [];
1075 keys.forEach(function (key) {
1076 var column = _this.getGridColumn(key);
1077 if (!column) {
1078 return;
1079 }
1080 // need to check for false with type (ie !== instead of !=)
1081 // as not returning anything (undefined) would also be false
1082 var resultOfAction = action(column);
1083 if (resultOfAction !== false) {
1084 updatedColumns.push(column);
1085 }
1086 });
1087 if (updatedColumns.length === 0) {
1088 return;
1089 }
1090 this.updateDisplayedColumns(source);
1091 if (utils_1.Utils.exists(createEvent)) {
1092 var event_5 = createEvent();
1093 event_5.columns = updatedColumns;
1094 event_5.column = updatedColumns.length === 1 ? updatedColumns[0] : null;
1095 this.eventService.dispatchEvent(event_5);
1096 }
1097 };
1098 ColumnController.prototype.getDisplayedColBefore = function (col) {
1099 var allDisplayedColumns = this.getAllDisplayedColumns();
1100 var oldIndex = allDisplayedColumns.indexOf(col);
1101 if (oldIndex > 0) {
1102 return allDisplayedColumns[oldIndex - 1];
1103 }
1104 else {
1105 return null;
1106 }
1107 };
1108 // used by:
1109 // + rowRenderer -> for navigation
1110 ColumnController.prototype.getDisplayedColAfter = function (col) {
1111 var allDisplayedColumns = this.getAllDisplayedColumns();
1112 var oldIndex = allDisplayedColumns.indexOf(col);
1113 if (oldIndex < (allDisplayedColumns.length - 1)) {
1114 return allDisplayedColumns[oldIndex + 1];
1115 }
1116 else {
1117 return null;
1118 }
1119 };
1120 ColumnController.prototype.getDisplayedGroupAfter = function (columnGroup) {
1121 // pick one col in this group at random
1122 var col = columnGroup.getDisplayedLeafColumns()[0];
1123 var requiredLevel = columnGroup.getOriginalColumnGroup().getLevel();
1124 while (true) {
1125 // keep moving to the next col, until we get to another group
1126 col = this.getDisplayedColAfter(col);
1127 // if no col after, means no group after
1128 if (!col) {
1129 return null;
1130 }
1131 // get group at same level as the one we are looking for
1132 var groupPointer = col.getParent();
1133 while (groupPointer.getOriginalColumnGroup().getLevel() !== requiredLevel) {
1134 groupPointer = groupPointer.getParent();
1135 }
1136 if (groupPointer !== columnGroup) {
1137 return groupPointer;
1138 }
1139 }
1140 };
1141 ColumnController.prototype.isPinningLeft = function () {
1142 return this.displayedLeftColumns.length > 0;
1143 };
1144 ColumnController.prototype.isPinningRight = function () {
1145 return this.displayedRightColumns.length > 0;
1146 };
1147 ColumnController.prototype.getPrimaryAndSecondaryAndAutoColumns = function () {
1148 var result = this.primaryColumns ? this.primaryColumns.slice(0) : [];
1149 if (utils_1.Utils.exists(this.groupAutoColumns)) {
1150 this.groupAutoColumns.forEach(function (col) { return result.push(col); });
1151 }
1152 if (this.secondaryColumnsPresent) {
1153 this.secondaryColumns.forEach(function (column) { return result.push(column); });
1154 }
1155 return result;
1156 };
1157 ColumnController.prototype.createStateItemFromColumn = function (column) {
1158 var rowGroupIndex = column.isRowGroupActive() ? this.rowGroupColumns.indexOf(column) : null;
1159 var pivotIndex = column.isPivotActive() ? this.pivotColumns.indexOf(column) : null;
1160 var aggFunc = column.isValueActive() ? column.getAggFunc() : null;
1161 return {
1162 colId: column.getColId(),
1163 hide: !column.isVisible(),
1164 aggFunc: aggFunc,
1165 width: column.getActualWidth(),
1166 pivotIndex: pivotIndex,
1167 pinned: column.getPinned(),
1168 rowGroupIndex: rowGroupIndex
1169 };
1170 };
1171 ColumnController.prototype.getColumnState = function () {
1172 if (utils_1.Utils.missing(this.primaryColumns)) {
1173 return [];
1174 }
1175 var columnStateList = this.primaryColumns.map(this.createStateItemFromColumn.bind(this));
1176 if (!this.pivotMode) {
1177 this.orderColumnStateList(columnStateList);
1178 }
1179 return columnStateList;
1180 };
1181 ColumnController.prototype.orderColumnStateList = function (columnStateList) {
1182 var gridColumnIds = this.gridColumns.map(function (column) { return column.getColId(); });
1183 columnStateList.sort(function (itemA, itemB) {
1184 var posA = gridColumnIds.indexOf(itemA.colId);
1185 var posB = gridColumnIds.indexOf(itemB.colId);
1186 return posA - posB;
1187 });
1188 };
1189 ColumnController.prototype.resetColumnState = function (source) {
1190 if (source === void 0) { source = "api"; }
1191 // we can't use 'allColumns' as the order might of messed up, so get the primary ordered list
1192 var primaryColumns = this.getColumnsFromTree(this.primaryBalancedTree);
1193 var state = [];
1194 if (primaryColumns) {
1195 primaryColumns.forEach(function (column) {
1196 state.push({
1197 colId: column.getColId(),
1198 aggFunc: column.getColDef().aggFunc,
1199 hide: column.getColDef().hide,
1200 pinned: column.getColDef().pinned,
1201 rowGroupIndex: column.getColDef().rowGroupIndex,
1202 pivotIndex: column.getColDef().pivotIndex,
1203 width: column.getColDef().width
1204 });
1205 });
1206 }
1207 this.setColumnState(state, source);
1208 };
1209 ColumnController.prototype.setColumnState = function (columnState, source) {
1210 var _this = this;
1211 if (source === void 0) { source = "api"; }
1212 if (utils_1.Utils.missingOrEmpty(this.primaryColumns)) {
1213 return false;
1214 }
1215 this.autoGroupsNeedBuilding = true;
1216 // at the end below, this list will have all columns we got no state for
1217 var columnsWithNoState = this.primaryColumns.slice();
1218 this.rowGroupColumns = [];
1219 this.valueColumns = [];
1220 this.pivotColumns = [];
1221 var success = true;
1222 var rowGroupIndexes = {};
1223 var pivotIndexes = {};
1224 if (columnState) {
1225 columnState.forEach(function (stateItem) {
1226 var column = _this.getPrimaryColumn(stateItem.colId);
1227 if (!column) {
1228 console.warn('ag-grid: column ' + stateItem.colId + ' not found');
1229 success = false;
1230 }
1231 else {
1232 _this.syncColumnWithStateItem(column, stateItem, rowGroupIndexes, pivotIndexes, source);
1233 utils_1.Utils.removeFromArray(columnsWithNoState, column);
1234 }
1235 });
1236 }
1237 // anything left over, we got no data for, so add in the column as non-value, non-rowGroup and hidden
1238 columnsWithNoState.forEach(this.syncColumnWithNoState.bind(this));
1239 // sort the lists according to the indexes that were provided
1240 this.rowGroupColumns.sort(this.sortColumnListUsingIndexes.bind(this, rowGroupIndexes));
1241 this.pivotColumns.sort(this.sortColumnListUsingIndexes.bind(this, pivotIndexes));
1242 this.updateGridColumns();
1243 if (columnState) {
1244 var orderOfColIds_1 = columnState.map(function (stateItem) { return stateItem.colId; });
1245 this.gridColumns.sort(function (colA, colB) {
1246 var indexA = orderOfColIds_1.indexOf(colA.getId());
1247 var indexB = orderOfColIds_1.indexOf(colB.getId());
1248 return indexA - indexB;
1249 });
1250 }
1251 this.updateDisplayedColumns(source);
1252 var event = {
1253 type: events_1.Events.EVENT_COLUMN_EVERYTHING_CHANGED,
1254 api: this.gridApi,
1255 columnApi: this.columnApi,
1256 source: source
1257 };
1258 this.eventService.dispatchEvent(event);
1259 return success;
1260 };
1261 ColumnController.prototype.sortColumnListUsingIndexes = function (indexes, colA, colB) {
1262 var indexA = indexes[colA.getId()];
1263 var indexB = indexes[colB.getId()];
1264 return indexA - indexB;
1265 };
1266 ColumnController.prototype.syncColumnWithNoState = function (column, source) {
1267 column.setVisible(false, source);
1268 column.setAggFunc(null);
1269 column.setPinned(null);
1270 column.setRowGroupActive(false, source);
1271 column.setPivotActive(false, source);
1272 column.setValueActive(false, source);
1273 };
1274 ColumnController.prototype.syncColumnWithStateItem = function (column, stateItem, rowGroupIndexes, pivotIndexes, source) {
1275 // following ensures we are left with boolean true or false, eg converts (null, undefined, 0) all to true
1276 column.setVisible(!stateItem.hide, source);
1277 // sets pinned to 'left' or 'right'
1278 column.setPinned(stateItem.pinned);
1279 // if width provided and valid, use it, otherwise stick with the old width
1280 if (stateItem.width >= this.gridOptionsWrapper.getMinColWidth()) {
1281 column.setActualWidth(stateItem.width, source);
1282 }
1283 if (typeof stateItem.aggFunc === 'string') {
1284 column.setAggFunc(stateItem.aggFunc);
1285 column.setValueActive(true, source);
1286 this.valueColumns.push(column);
1287 }
1288 else {
1289 if (utils_1.Utils.exists(stateItem.aggFunc)) {
1290 console.warn('ag-Grid: stateItem.aggFunc must be a string. if using your own aggregation ' +
1291 'functions, register the functions first before using them in get/set state. This is because it is' +
1292 'intended for the column state to be stored and retrieved as simple JSON.');
1293 }
1294 column.setAggFunc(null);
1295 column.setValueActive(false, source);
1296 }
1297 if (typeof stateItem.rowGroupIndex === 'number') {
1298 this.rowGroupColumns.push(column);
1299 column.setRowGroupActive(true, source);
1300 rowGroupIndexes[column.getId()] = stateItem.rowGroupIndex;
1301 }
1302 else {
1303 column.setRowGroupActive(false, source);
1304 }
1305 if (typeof stateItem.pivotIndex === 'number') {
1306 this.pivotColumns.push(column);
1307 column.setPivotActive(true, source);
1308 pivotIndexes[column.getId()] = stateItem.pivotIndex;
1309 }
1310 else {
1311 column.setPivotActive(false, source);
1312 }
1313 };
1314 ColumnController.prototype.getGridColumns = function (keys) {
1315 return this.getColumns(keys, this.getGridColumn.bind(this));
1316 };
1317 ColumnController.prototype.getColumns = function (keys, columnLookupCallback) {
1318 var foundColumns = [];
1319 if (keys) {
1320 keys.forEach(function (key) {
1321 var column = columnLookupCallback(key);
1322 if (column) {
1323 foundColumns.push(column);
1324 }
1325 });
1326 }
1327 return foundColumns;
1328 };
1329 // used by growGroupPanel
1330 ColumnController.prototype.getColumnWithValidation = function (key) {
1331 var column = this.getPrimaryColumn(key);
1332 if (!column) {
1333 console.warn('ag-Grid: could not find column ' + column);
1334 }
1335 return column;
1336 };
1337 ColumnController.prototype.getPrimaryColumn = function (key) {
1338 return this.getColumn(key, this.primaryColumns);
1339 };
1340 ColumnController.prototype.getGridColumn = function (key) {
1341 return this.getColumn(key, this.gridColumns);
1342 };
1343 ColumnController.prototype.getColumn = function (key, columnList) {
1344 if (!key) {
1345 return null;
1346 }
1347 for (var i = 0; i < columnList.length; i++) {
1348 if (this.columnsMatch(columnList[i], key)) {
1349 return columnList[i];
1350 }
1351 }
1352 return this.getAutoColumn(key);
1353 };
1354 ColumnController.prototype.getAutoColumn = function (key) {
1355 var _this = this;
1356 if (!utils_1.Utils.exists(this.groupAutoColumns) || utils_1.Utils.missing(this.groupAutoColumns)) {
1357 return null;
1358 }
1359 return utils_1.Utils.find(this.groupAutoColumns, function (groupCol) {
1360 return _this.columnsMatch(groupCol, key);
1361 });
1362 };
1363 ColumnController.prototype.columnsMatch = function (column, key) {
1364 var columnMatches = column === key;
1365 var colDefMatches = column.getColDef() === key;
1366 var idMatches = column.getColId() == key;
1367 return columnMatches || colDefMatches || idMatches;
1368 };
1369 ColumnController.prototype.getDisplayNameForColumn = function (column, location, includeAggFunc) {
1370 if (includeAggFunc === void 0) { includeAggFunc = false; }
1371 var headerName = this.getHeaderName(column.getColDef(), column, null, null, location);
1372 if (includeAggFunc) {
1373 return this.wrapHeaderNameWithAggFunc(column, headerName);
1374 }
1375 else {
1376 return headerName;
1377 }
1378 };
1379 ColumnController.prototype.getDisplayNameForOriginalColumnGroup = function (columnGroup, originalColumnGroup, location) {
1380 var colGroupDef = originalColumnGroup.getColGroupDef();
1381 if (colGroupDef) {
1382 return this.getHeaderName(colGroupDef, null, columnGroup, originalColumnGroup, location);
1383 }
1384 else {
1385 return null;
1386 }
1387 };
1388 ColumnController.prototype.getDisplayNameForColumnGroup = function (columnGroup, location) {
1389 return this.getDisplayNameForOriginalColumnGroup(columnGroup, columnGroup.getOriginalColumnGroup(), location);
1390 };
1391 // location is where the column is going to appear, ie who is calling us
1392 ColumnController.prototype.getHeaderName = function (colDef, column, columnGroup, originalColumnGroup, location) {
1393 var headerValueGetter = colDef.headerValueGetter;
1394 if (headerValueGetter) {
1395 var params = {
1396 colDef: colDef,
1397 column: column,
1398 columnGroup: columnGroup,
1399 originalColumnGroup: originalColumnGroup,
1400 location: location,
1401 api: this.gridOptionsWrapper.getApi(),
1402 context: this.gridOptionsWrapper.getContext()
1403 };
1404 if (typeof headerValueGetter === 'function') {
1405 // valueGetter is a function, so just call it
1406 return headerValueGetter(params);
1407 }
1408 else if (typeof headerValueGetter === 'string') {
1409 // valueGetter is an expression, so execute the expression
1410 return this.expressionService.evaluate(headerValueGetter, params);
1411 }
1412 else {
1413 console.warn('ag-grid: headerValueGetter must be a function or a string');
1414 return '';
1415 }
1416 }
1417 else if (colDef.headerName != null) {
1418 return colDef.headerName;
1419 }
1420 else if (colDef.field) {
1421 return utils_1.Utils.camelCaseToHumanText(colDef.field);
1422 }
1423 else {
1424 return '';
1425 }
1426 };
1427 /*
1428 private getHeaderGroupName(columnGroup: ColumnGroup): string {
1429 let colGroupDef = columnGroup.getOriginalColumnGroup().getColGroupDef();
1430 let headerValueGetter = colGroupDef.headerValueGetter;
1431
1432 if (headerValueGetter) {
1433 let params = {
1434 columnGroup: columnGroup,
1435 colDef: colGroupDef,
1436 api: this.gridOptionsWrapper.getApi(),
1437 context: this.gridOptionsWrapper.getContext()
1438 };
1439
1440 if (typeof headerValueGetter === 'function') {
1441 // valueGetter is a function, so just call it
1442 return headerValueGetter(params);
1443 } else if (typeof headerValueGetter === 'string') {
1444 // valueGetter is an expression, so execute the expression
1445 return this.expressionService.evaluate(headerValueGetter, params);
1446 } else {
1447 console.warn('ag-grid: headerValueGetter must be a function or a string');
1448 return '';
1449 }
1450 } else {
1451 return colGroupDef.headerName;
1452 }
1453 }
1454 */
1455 ColumnController.prototype.wrapHeaderNameWithAggFunc = function (column, headerName) {
1456 if (this.gridOptionsWrapper.isSuppressAggFuncInHeader()) {
1457 return headerName;
1458 }
1459 // only columns with aggregation active can have aggregations
1460 var pivotValueColumn = column.getColDef().pivotValueColumn;
1461 var pivotActiveOnThisColumn = utils_1.Utils.exists(pivotValueColumn);
1462 var aggFunc = null;
1463 var aggFuncFound;
1464 // otherwise we have a measure that is active, and we are doing aggregation on it
1465 if (pivotActiveOnThisColumn) {
1466 aggFunc = pivotValueColumn.getAggFunc();
1467 aggFuncFound = true;
1468 }
1469 else {
1470 var measureActive = column.isValueActive();
1471 var aggregationPresent = this.pivotMode || !this.isRowGroupEmpty();
1472 if (measureActive && aggregationPresent) {
1473 aggFunc = column.getAggFunc();
1474 aggFuncFound = true;
1475 }
1476 else {
1477 aggFuncFound = false;
1478 }
1479 }
1480 if (aggFuncFound) {
1481 var aggFuncString = (typeof aggFunc === 'string') ? aggFunc : 'func';
1482 var localeTextFunc = this.gridOptionsWrapper.getLocaleTextFunc();
1483 var aggFuncStringTranslated = localeTextFunc(aggFuncString, aggFuncString);
1484 return aggFuncStringTranslated + "(" + headerName + ")";
1485 }
1486 else {
1487 return headerName;
1488 }
1489 };
1490 // returns the group with matching colId and instanceId. If instanceId is missing,
1491 // matches only on the colId.
1492 ColumnController.prototype.getColumnGroup = function (colId, instanceId) {
1493 if (!colId) {
1494 return null;
1495 }
1496 if (colId instanceof columnGroup_1.ColumnGroup) {
1497 return colId;
1498 }
1499 var allColumnGroups = this.getAllDisplayedColumnGroups();
1500 var checkInstanceId = typeof instanceId === 'number';
1501 var result = null;
1502 this.columnUtils.depthFirstAllColumnTreeSearch(allColumnGroups, function (child) {
1503 if (child instanceof columnGroup_1.ColumnGroup) {
1504 var columnGroup = child;
1505 var matched = void 0;
1506 if (checkInstanceId) {
1507 matched = colId === columnGroup.getGroupId() && instanceId === columnGroup.getInstanceId();
1508 }
1509 else {
1510 matched = colId === columnGroup.getGroupId();
1511 }
1512 if (matched) {
1513 result = columnGroup;
1514 }
1515 }
1516 });
1517 return result;
1518 };
1519 ColumnController.prototype.setColumnDefs = function (columnDefs, source) {
1520 if (source === void 0) { source = "api"; }
1521 // always invalidate cache on changing columns, as the column id's for the new columns
1522 // could overlap with the old id's, so the cache would return old values for new columns.
1523 this.valueCache.expire();
1524 // NOTE ==================
1525 // we should be destroying the existing columns and groups if they exist, for example, the original column
1526 // group adds a listener to the columns, it should be also removing the listeners
1527 this.autoGroupsNeedBuilding = true;
1528 var balancedTreeResult = this.balancedColumnTreeBuilder.createBalancedColumnGroups(columnDefs, true);
1529 this.primaryBalancedTree = balancedTreeResult.balancedTree;
1530 this.primaryHeaderRowCount = balancedTreeResult.treeDept + 1;
1531 this.primaryColumns = this.getColumnsFromTree(this.primaryBalancedTree);
1532 this.autoRowHeightColumns = this.primaryColumns.filter(function (col) { return col.getColDef().autoHeight; });
1533 this.extractRowGroupColumns(source);
1534 this.extractPivotColumns(source);
1535 this.createValueColumns(source);
1536 this.updateGridColumns();
1537 this.updateDisplayedColumns(source);
1538 this.checkDisplayedVirtualColumns();
1539 this.ready = true;
1540 var eventEverythingChanged = {
1541 type: events_1.Events.EVENT_COLUMN_EVERYTHING_CHANGED,
1542 api: this.gridApi,
1543 columnApi: this.columnApi,
1544 source: source
1545 };
1546 this.eventService.dispatchEvent(eventEverythingChanged);
1547 var newColumnsLoadedEvent = {
1548 type: events_1.Events.EVENT_NEW_COLUMNS_LOADED,
1549 api: this.gridApi,
1550 columnApi: this.columnApi
1551 };
1552 this.eventService.dispatchEvent(newColumnsLoadedEvent);
1553 };
1554 ColumnController.prototype.isReady = function () {
1555 return this.ready;
1556 };
1557 ColumnController.prototype.extractRowGroupColumns = function (source) {
1558 var _this = this;
1559 this.rowGroupColumns.forEach(function (column) { return column.setRowGroupActive(false, source); });
1560 this.rowGroupColumns = [];
1561 // pull out items with rowGroupIndex
1562 this.primaryColumns.forEach(function (column) {
1563 if (typeof column.getColDef().rowGroupIndex === 'number') {
1564 _this.rowGroupColumns.push(column);
1565 column.setRowGroupActive(true, source);
1566 }
1567 });
1568 // then sort them
1569 this.rowGroupColumns.sort(function (colA, colB) {
1570 return colA.getColDef().rowGroupIndex - colB.getColDef().rowGroupIndex;
1571 });
1572 // now just pull out items rowGroup, they will be added at the end
1573 // after the indexed ones, but in the order the columns appear
1574 this.primaryColumns.forEach(function (column) {
1575 if (column.getColDef().rowGroup) {
1576 // if user already specified rowGroupIndex then we skip it as this col already included
1577 if (_this.rowGroupColumns.indexOf(column) >= 0) {
1578 return;
1579 }
1580 _this.rowGroupColumns.push(column);
1581 column.setRowGroupActive(true, source);
1582 }
1583 });
1584 };
1585 ColumnController.prototype.extractPivotColumns = function (source) {
1586 var _this = this;
1587 this.pivotColumns.forEach(function (column) { return column.setPivotActive(false, source); });
1588 this.pivotColumns = [];
1589 // pull out items with pivotIndex
1590 this.primaryColumns.forEach(function (column) {
1591 if (typeof column.getColDef().pivotIndex === 'number') {
1592 _this.pivotColumns.push(column);
1593 column.setPivotActive(true, source);
1594 }
1595 });
1596 // then sort them
1597 this.pivotColumns.sort(function (colA, colB) {
1598 return colA.getColDef().pivotIndex - colB.getColDef().pivotIndex;
1599 });
1600 // now check the boolean equivalent
1601 this.primaryColumns.forEach(function (column) {
1602 if (column.getColDef().pivot) {
1603 // if user already specified pivotIndex then we skip it as this col already included
1604 if (_this.pivotColumns.indexOf(column) >= 0) {
1605 return;
1606 }
1607 _this.pivotColumns.push(column);
1608 column.setPivotActive(true, source);
1609 }
1610 });
1611 };
1612 ColumnController.prototype.resetColumnGroupState = function (source) {
1613 if (source === void 0) { source = "api"; }
1614 var stateItems = [];
1615 this.columnUtils.depthFirstOriginalTreeSearch(this.primaryBalancedTree, function (child) {
1616 if (child instanceof originalColumnGroup_1.OriginalColumnGroup) {
1617 var groupState = {
1618 groupId: child.getGroupId(),
1619 open: child.getColGroupDef().openByDefault
1620 };
1621 stateItems.push(groupState);
1622 }
1623 });
1624 this.setColumnGroupState(stateItems, source);
1625 };
1626 ColumnController.prototype.getColumnGroupState = function () {
1627 var columnGroupState = [];
1628 this.columnUtils.depthFirstOriginalTreeSearch(this.gridBalancedTree, function (node) {
1629 if (node instanceof originalColumnGroup_1.OriginalColumnGroup) {
1630 var originalColumnGroup = node;
1631 columnGroupState.push({
1632 groupId: originalColumnGroup.getGroupId(),
1633 open: originalColumnGroup.isExpanded()
1634 });
1635 }
1636 });
1637 return columnGroupState;
1638 };
1639 ColumnController.prototype.setColumnGroupState = function (stateItems, source) {
1640 var _this = this;
1641 if (source === void 0) { source = "api"; }
1642 this.columnAnimationService.start();
1643 var impactedGroups = [];
1644 stateItems.forEach(function (stateItem) {
1645 var groupKey = stateItem.groupId;
1646 var newValue = stateItem.open;
1647 var originalColumnGroup = _this.getOriginalColumnGroup(groupKey);
1648 if (!originalColumnGroup) {
1649 return;
1650 }
1651 if (originalColumnGroup.isExpanded() === newValue) {
1652 return;
1653 }
1654 _this.logger.log('columnGroupOpened(' + originalColumnGroup.getGroupId() + ',' + newValue + ')');
1655 originalColumnGroup.setExpanded(newValue);
1656 impactedGroups.push(originalColumnGroup);
1657 });
1658 this.updateGroupsAndDisplayedColumns(source);
1659 impactedGroups.forEach(function (originalColumnGroup) {
1660 var event = {
1661 type: events_1.Events.EVENT_COLUMN_GROUP_OPENED,
1662 columnGroup: originalColumnGroup,
1663 api: _this.gridApi,
1664 columnApi: _this.columnApi
1665 };
1666 _this.eventService.dispatchEvent(event);
1667 });
1668 this.columnAnimationService.finish();
1669 };
1670 // called by headerRenderer - when a header is opened or closed
1671 ColumnController.prototype.setColumnGroupOpened = function (key, newValue, source) {
1672 if (source === void 0) { source = "api"; }
1673 var keyAsString;
1674 if (key instanceof originalColumnGroup_1.OriginalColumnGroup) {
1675 keyAsString = key.getId();
1676 }
1677 else {
1678 keyAsString = key;
1679 }
1680 this.setColumnGroupState([{ groupId: keyAsString, open: newValue }], source);
1681 };
1682 ColumnController.prototype.getOriginalColumnGroup = function (key) {
1683 if (key instanceof originalColumnGroup_1.OriginalColumnGroup) {
1684 return key;
1685 }
1686 if (typeof key !== 'string') {
1687 console.error('ag-Grid: group key must be a string');
1688 }
1689 // otherwise, search for the column group by id
1690 var res = null;
1691 this.columnUtils.depthFirstOriginalTreeSearch(this.gridBalancedTree, function (node) {
1692 if (node instanceof originalColumnGroup_1.OriginalColumnGroup) {
1693 var originalColumnGroup = node;
1694 if (originalColumnGroup.getId() === key) {
1695 res = originalColumnGroup;
1696 }
1697 }
1698 });
1699 return res;
1700 };
1701 ColumnController.prototype.calculateColumnsForDisplay = function () {
1702 var _this = this;
1703 var columnsForDisplay;
1704 if (this.pivotMode && !this.secondaryColumnsPresent) {
1705 // pivot mode is on, but we are not pivoting, so we only
1706 // show columns we are aggregating on
1707 columnsForDisplay = utils_1.Utils.filter(this.gridColumns, function (column) {
1708 var isAutoGroupCol = _this.groupAutoColumns && _this.groupAutoColumns.indexOf(column) >= 0;
1709 var isValueCol = _this.valueColumns && _this.valueColumns.indexOf(column) >= 0;
1710 return isAutoGroupCol || isValueCol;
1711 });
1712 }
1713 else {
1714 // otherwise continue as normal. this can be working on the primary
1715 // or secondary columns, whatever the gridColumns are set to
1716 columnsForDisplay = utils_1.Utils.filter(this.gridColumns, function (column) {
1717 // keep col if a) it's auto-group or b) it's visible
1718 var isAutoGroupCol = _this.groupAutoColumns && _this.groupAutoColumns.indexOf(column) >= 0;
1719 return isAutoGroupCol || column.isVisible();
1720 });
1721 }
1722 return columnsForDisplay;
1723 };
1724 ColumnController.prototype.checkColSpanActiveInCols = function (columns) {
1725 var result = false;
1726 columns.forEach(function (col) {
1727 if (utils_1.Utils.exists(col.getColDef().colSpan)) {
1728 result = true;
1729 }
1730 });
1731 return result;
1732 };
1733 ColumnController.prototype.calculateColumnsForGroupDisplay = function () {
1734 var _this = this;
1735 this.groupDisplayColumns = [];
1736 var checkFunc = function (col) {
1737 var colDef = col.getColDef();
1738 if (colDef && utils_1.Utils.exists(colDef.showRowGroup)) {
1739 _this.groupDisplayColumns.push(col);
1740 }
1741 };
1742 this.gridColumns.forEach(checkFunc);
1743 if (this.groupAutoColumns) {
1744 this.groupAutoColumns.forEach(checkFunc);
1745 }
1746 };
1747 ColumnController.prototype.getGroupDisplayColumns = function () {
1748 return this.groupDisplayColumns;
1749 };
1750 ColumnController.prototype.updateDisplayedColumns = function (source) {
1751 var columnsForDisplay = this.calculateColumnsForDisplay();
1752 this.buildDisplayedTrees(columnsForDisplay);
1753 this.calculateColumnsForGroupDisplay();
1754 // this is also called when a group is opened or closed
1755 this.updateGroupsAndDisplayedColumns(source);
1756 this.setFirstRightAndLastLeftPinned(source);
1757 };
1758 ColumnController.prototype.isSecondaryColumnsPresent = function () {
1759 return this.secondaryColumnsPresent;
1760 };
1761 ColumnController.prototype.setSecondaryColumns = function (colDefs, source) {
1762 if (source === void 0) { source = "api"; }
1763 var newColsPresent = colDefs && colDefs.length > 0;
1764 // if not cols passed, and we had to cols anyway, then do nothing
1765 if (!newColsPresent && !this.secondaryColumnsPresent) {
1766 return;
1767 }
1768 if (newColsPresent) {
1769 this.processSecondaryColumnDefinitions(colDefs);
1770 var balancedTreeResult = this.balancedColumnTreeBuilder.createBalancedColumnGroups(colDefs, false);
1771 this.secondaryBalancedTree = balancedTreeResult.balancedTree;
1772 this.secondaryHeaderRowCount = balancedTreeResult.treeDept + 1;
1773 this.secondaryColumns = this.getColumnsFromTree(this.secondaryBalancedTree);
1774 this.secondaryColumnsPresent = true;
1775 }
1776 else {
1777 this.secondaryBalancedTree = null;
1778 this.secondaryHeaderRowCount = -1;
1779 this.secondaryColumns = null;
1780 this.secondaryColumnsPresent = false;
1781 }
1782 this.updateGridColumns();
1783 this.updateDisplayedColumns(source);
1784 };
1785 ColumnController.prototype.processSecondaryColumnDefinitions = function (colDefs) {
1786 var columnCallback = this.gridOptionsWrapper.getProcessSecondaryColDefFunc();
1787 var groupCallback = this.gridOptionsWrapper.getProcessSecondaryColGroupDefFunc();
1788 if (!columnCallback && !groupCallback) {
1789 return;
1790 }
1791 searchForColDefs(colDefs);
1792 function searchForColDefs(colDefs2) {
1793 colDefs2.forEach(function (abstractColDef) {
1794 var isGroup = utils_1.Utils.exists(abstractColDef.children);
1795 if (isGroup) {
1796 var colGroupDef = abstractColDef;
1797 if (groupCallback) {
1798 groupCallback(colGroupDef);
1799 }
1800 searchForColDefs(colGroupDef.children);
1801 }
1802 else {
1803 var colDef = abstractColDef;
1804 if (columnCallback) {
1805 columnCallback(colDef);
1806 }
1807 }
1808 });
1809 }
1810 };
1811 // called from: setColumnState, setColumnDefs, setSecondaryColumns
1812 ColumnController.prototype.updateGridColumns = function () {
1813 if (this.gridColsArePrimary) {
1814 this.lastPrimaryOrder = this.gridColumns;
1815 }
1816 if (this.secondaryColumns) {
1817 this.gridBalancedTree = this.secondaryBalancedTree.slice();
1818 this.gridHeaderRowCount = this.secondaryHeaderRowCount;
1819 this.gridColumns = this.secondaryColumns.slice();
1820 this.gridColsArePrimary = false;
1821 }
1822 else {
1823 this.gridBalancedTree = this.primaryBalancedTree.slice();
1824 this.gridHeaderRowCount = this.primaryHeaderRowCount;
1825 this.gridColumns = this.primaryColumns.slice();
1826 this.gridColsArePrimary = true;
1827 // updateGridColumns gets called after user adds a row group. we want to maintain the order of the columns
1828 // when this happens (eg if user moved a column) rather than revert back to the original column order.
1829 // likewise if changing in/out of pivot mode, we want to maintain the order of the primary cols
1830 this.orderGridColsLikeLastPrimary();
1831 }
1832 this.addAutoGroupToGridColumns();
1833 this.putFixedColumnsFirst();
1834 this.setupQuickFilterColumns();
1835 this.clearDisplayedColumns();
1836 this.colSpanActive = this.checkColSpanActiveInCols(this.gridColumns);
1837 var event = {
1838 type: events_1.Events.EVENT_GRID_COLUMNS_CHANGED,
1839 api: this.gridApi,
1840 columnApi: this.columnApi
1841 };
1842 this.eventService.dispatchEvent(event);
1843 };
1844 ColumnController.prototype.orderGridColsLikeLastPrimary = function () {
1845 var _this = this;
1846 if (utils_1.Utils.missing(this.lastPrimaryOrder)) {
1847 return;
1848 }
1849 // only do the sort if all columns are accounted for. columns will be not accounted for
1850 // if changing from secondary to primary columns
1851 var oneMissing = false;
1852 this.gridColumns.forEach(function (col) {
1853 if (_this.lastPrimaryOrder.indexOf(col) < 0) {
1854 oneMissing = true;
1855 }
1856 });
1857 if (oneMissing) {
1858 return;
1859 }
1860 this.gridColumns.sort(function (colA, colB) {
1861 var indexA = _this.lastPrimaryOrder.indexOf(colA);
1862 var indexB = _this.lastPrimaryOrder.indexOf(colB);
1863 return indexA - indexB;
1864 });
1865 };
1866 ColumnController.prototype.isPrimaryColumnGroupsPresent = function () {
1867 return this.primaryHeaderRowCount > 1;
1868 };
1869 // if we are using autoGroupCols, then they should be included for quick filter. this covers the
1870 // following scenarios:
1871 // a) user provides 'field' into autoGroupCol of normal grid, so now because a valid col to filter leafs on
1872 // b) using tree data and user depends on autoGroupCol for first col, and we also want to filter on this
1873 // (tree data is a bit different, as parent rows can be filtered on, unlike row grouping)
1874 ColumnController.prototype.setupQuickFilterColumns = function () {
1875 if (this.groupAutoColumns) {
1876 this.columnsForQuickFilter = this.primaryColumns.concat(this.groupAutoColumns);
1877 }
1878 else {
1879 this.columnsForQuickFilter = this.primaryColumns;
1880 }
1881 };
1882 ColumnController.prototype.putFixedColumnsFirst = function () {
1883 var locked = this.gridColumns.filter(function (c) { return c.isLockPosition(); });
1884 var unlocked = this.gridColumns.filter(function (c) { return !c.isLockPosition(); });
1885 this.gridColumns = locked.concat(unlocked);
1886 };
1887 ColumnController.prototype.addAutoGroupToGridColumns = function () {
1888 // add in auto-group here
1889 this.createGroupAutoColumnsIfNeeded();
1890 if (utils_1.Utils.missing(this.groupAutoColumns)) {
1891 return;
1892 }
1893 this.gridColumns = this.groupAutoColumns.concat(this.gridColumns);
1894 var autoColBalancedTree = this.balancedColumnTreeBuilder.createForAutoGroups(this.groupAutoColumns, this.gridBalancedTree);
1895 this.gridBalancedTree = autoColBalancedTree.concat(this.gridBalancedTree);
1896 };
1897 // gets called after we copy down grid columns, to make sure any part of the gui
1898 // that tries to draw, eg the header, it will get empty lists of columns rather
1899 // than stale columns. for example, the header will received gridColumnsChanged
1900 // event, so will try and draw, but it will draw successfully when it acts on the
1901 // virtualColumnsChanged event
1902 ColumnController.prototype.clearDisplayedColumns = function () {
1903 this.displayedLeftColumnTree = [];
1904 this.displayedRightColumnTree = [];
1905 this.displayedCentreColumnTree = [];
1906 this.displayedLeftHeaderRows = {};
1907 this.displayedRightHeaderRows = {};
1908 this.displayedCentreHeaderRows = {};
1909 this.displayedLeftColumns = [];
1910 this.displayedRightColumns = [];
1911 this.displayedCenterColumns = [];
1912 this.allDisplayedColumns = [];
1913 this.allDisplayedVirtualColumns = [];
1914 };
1915 ColumnController.prototype.updateGroupsAndDisplayedColumns = function (source) {
1916 this.updateOpenClosedVisibilityInColumnGroups();
1917 this.updateDisplayedColumnsFromTrees(source);
1918 this.updateVirtualSets();
1919 this.updateBodyWidths();
1920 // this event is picked up by the gui, headerRenderer and rowRenderer, to recalculate what columns to display
1921 var event = {
1922 type: events_1.Events.EVENT_DISPLAYED_COLUMNS_CHANGED,
1923 api: this.gridApi,
1924 columnApi: this.columnApi
1925 };
1926 this.eventService.dispatchEvent(event);
1927 };
1928 ColumnController.prototype.updateDisplayedColumnsFromTrees = function (source) {
1929 this.addToDisplayedColumns(this.displayedLeftColumnTree, this.displayedLeftColumns);
1930 this.addToDisplayedColumns(this.displayedCentreColumnTree, this.displayedCenterColumns);
1931 this.addToDisplayedColumns(this.displayedRightColumnTree, this.displayedRightColumns);
1932 this.setupAllDisplayedColumns();
1933 this.setLeftValues(source);
1934 };
1935 ColumnController.prototype.setupAllDisplayedColumns = function () {
1936 if (this.gridOptionsWrapper.isEnableRtl()) {
1937 this.allDisplayedColumns = this.displayedRightColumns
1938 .concat(this.displayedCenterColumns)
1939 .concat(this.displayedLeftColumns);
1940 }
1941 else {
1942 this.allDisplayedColumns = this.displayedLeftColumns
1943 .concat(this.displayedCenterColumns)
1944 .concat(this.displayedRightColumns);
1945 }
1946 };
1947 // sets the left pixel position of each column
1948 ColumnController.prototype.setLeftValues = function (source) {
1949 this.setLeftValuesOfColumns(source);
1950 this.setLeftValuesOfGroups();
1951 };
1952 ColumnController.prototype.setLeftValuesOfColumns = function (source) {
1953 var _this = this;
1954 // go through each list of displayed columns
1955 var allColumns = this.primaryColumns.slice(0);
1956 // let totalColumnWidth = this.getWidthOfColsInList()
1957 var doingRtl = this.gridOptionsWrapper.isEnableRtl();
1958 [this.displayedLeftColumns, this.displayedRightColumns, this.displayedCenterColumns].forEach(function (columns) {
1959 if (doingRtl) {
1960 // when doing RTL, we start at the top most pixel (ie RHS) and work backwards
1961 var left_1 = _this.getWidthOfColsInList(columns);
1962 columns.forEach(function (column) {
1963 left_1 -= column.getActualWidth();
1964 column.setLeft(left_1, source);
1965 });
1966 }
1967 else {
1968 // otherwise normal LTR, we start at zero
1969 var left_2 = 0;
1970 columns.forEach(function (column) {
1971 column.setLeft(left_2, source);
1972 left_2 += column.getActualWidth();
1973 });
1974 }
1975 utils_1.Utils.removeAllFromArray(allColumns, columns);
1976 });
1977 // items left in allColumns are columns not displayed, so remove the left position. this is
1978 // important for the rows, as if a col is made visible, then taken out, then made visible again,
1979 // we don't want the animation of the cell floating in from the old position, whatever that was.
1980 allColumns.forEach(function (column) {
1981 column.setLeft(null, source);
1982 });
1983 };
1984 ColumnController.prototype.setLeftValuesOfGroups = function () {
1985 // a groups left value is the lest left value of it's children
1986 [this.displayedLeftColumnTree, this.displayedRightColumnTree, this.displayedCentreColumnTree].forEach(function (columns) {
1987 columns.forEach(function (column) {
1988 if (column instanceof columnGroup_1.ColumnGroup) {
1989 var columnGroup = column;
1990 columnGroup.checkLeft();
1991 }
1992 });
1993 });
1994 };
1995 ColumnController.prototype.addToDisplayedColumns = function (displayedColumnTree, displayedColumns) {
1996 displayedColumns.length = 0;
1997 this.columnUtils.depthFirstDisplayedColumnTreeSearch(displayedColumnTree, function (child) {
1998 if (child instanceof column_1.Column) {
1999 displayedColumns.push(child);
2000 }
2001 });
2002 };
2003 ColumnController.prototype.updateDisplayedCenterVirtualColumns = function () {
2004 if (this.suppressColumnVirtualisation) {
2005 // no virtualisation, so don't filter
2006 this.allDisplayedCenterVirtualColumns = this.displayedCenterColumns;
2007 }
2008 else {
2009 // filter out what should be visible
2010 this.allDisplayedCenterVirtualColumns = this.filterOutColumnsWithinViewport();
2011 }
2012 this.allDisplayedVirtualColumns = this.allDisplayedCenterVirtualColumns
2013 .concat(this.displayedLeftColumns)
2014 .concat(this.displayedRightColumns);
2015 // return map of virtual col id's, for easy lookup when building the groups.
2016 // the map will be colId=>true, ie col id's mapping to 'true'.
2017 var result = {};
2018 this.allDisplayedVirtualColumns.forEach(function (col) {
2019 result[col.getId()] = true;
2020 });
2021 return result;
2022 };
2023 ColumnController.prototype.getVirtualHeaderGroupRow = function (type, dept) {
2024 var result;
2025 switch (type) {
2026 case column_1.Column.PINNED_LEFT:
2027 result = this.displayedLeftHeaderRows[dept];
2028 break;
2029 case column_1.Column.PINNED_RIGHT:
2030 result = this.displayedRightHeaderRows[dept];
2031 break;
2032 default:
2033 result = this.displayedCentreHeaderRows[dept];
2034 break;
2035 }
2036 if (utils_1.Utils.missing(result)) {
2037 result = [];
2038 }
2039 return result;
2040 };
2041 ColumnController.prototype.updateDisplayedVirtualGroups = function (virtualColIds) {
2042 // go through each group, see if any of it's cols are displayed, and if yes,
2043 // then this group is included
2044 this.displayedLeftHeaderRows = {};
2045 this.displayedRightHeaderRows = {};
2046 this.displayedCentreHeaderRows = {};
2047 testGroup(this.displayedLeftColumnTree, this.displayedLeftHeaderRows, 0);
2048 testGroup(this.displayedRightColumnTree, this.displayedRightHeaderRows, 0);
2049 testGroup(this.displayedCentreColumnTree, this.displayedCentreHeaderRows, 0);
2050 function testGroup(children, result, dept) {
2051 var returnValue = false;
2052 for (var i = 0; i < children.length; i++) {
2053 // see if this item is within viewport
2054 var child = children[i];
2055 var addThisItem = void 0;
2056 if (child instanceof column_1.Column) {
2057 // for column, test if column is included
2058 addThisItem = virtualColIds[child.getId()] === true;
2059 }
2060 else {
2061 // if group, base decision on children
2062 var columnGroup = child;
2063 addThisItem = testGroup(columnGroup.getDisplayedChildren(), result, dept + 1);
2064 }
2065 if (addThisItem) {
2066 returnValue = true;
2067 if (!result[dept]) {
2068 result[dept] = [];
2069 }
2070 result[dept].push(child);
2071 }
2072 }
2073 return returnValue;
2074 }
2075 };
2076 ColumnController.prototype.updateVirtualSets = function () {
2077 var virtualColIds = this.updateDisplayedCenterVirtualColumns();
2078 this.updateDisplayedVirtualGroups(virtualColIds);
2079 };
2080 ColumnController.prototype.filterOutColumnsWithinViewport = function () {
2081 return utils_1.Utils.filter(this.displayedCenterColumns, this.isColumnInViewport.bind(this));
2082 };
2083 // called from api
2084 ColumnController.prototype.sizeColumnsToFit = function (gridWidth, source) {
2085 var _this = this;
2086 if (source === void 0) { source = "api"; }
2087 // avoid divide by zero
2088 var allDisplayedColumns = this.getAllDisplayedColumns();
2089 if (gridWidth <= 0 || allDisplayedColumns.length === 0) {
2090 return;
2091 }
2092 var colsToNotSpread = utils_1.Utils.filter(allDisplayedColumns, function (column) {
2093 return column.getColDef().suppressSizeToFit === true;
2094 });
2095 var colsToSpread = utils_1.Utils.filter(allDisplayedColumns, function (column) {
2096 return column.getColDef().suppressSizeToFit !== true;
2097 });
2098 // make a copy of the cols that are going to be resized
2099 var colsToFireEventFor = colsToSpread.slice(0);
2100 var finishedResizing = false;
2101 while (!finishedResizing) {
2102 finishedResizing = true;
2103 var availablePixels = gridWidth - this.getWidthOfColsInList(colsToNotSpread);
2104 if (availablePixels <= 0) {
2105 // no width, set everything to minimum
2106 colsToSpread.forEach(function (column) {
2107 column.setMinimum(source);
2108 });
2109 }
2110 else {
2111 var scale = availablePixels / this.getWidthOfColsInList(colsToSpread);
2112 // we set the pixels for the last col based on what's left, as otherwise
2113 // we could be a pixel or two short or extra because of rounding errors.
2114 var pixelsForLastCol = availablePixels;
2115 // backwards through loop, as we are removing items as we go
2116 for (var i = colsToSpread.length - 1; i >= 0; i--) {
2117 var column = colsToSpread[i];
2118 var newWidth = Math.round(column.getActualWidth() * scale);
2119 if (newWidth < column.getMinWidth()) {
2120 column.setMinimum(source);
2121 moveToNotSpread(column);
2122 finishedResizing = false;
2123 }
2124 else if (column.isGreaterThanMax(newWidth)) {
2125 column.setActualWidth(column.getMaxWidth(), source);
2126 moveToNotSpread(column);
2127 finishedResizing = false;
2128 }
2129 else {
2130 var onLastCol = i === 0;
2131 if (onLastCol) {
2132 column.setActualWidth(pixelsForLastCol, source);
2133 }
2134 else {
2135 column.setActualWidth(newWidth, source);
2136 }
2137 }
2138 pixelsForLastCol -= newWidth;
2139 }
2140 }
2141 }
2142 this.setLeftValues(source);
2143 this.updateBodyWidths();
2144 colsToFireEventFor.forEach(function (column) {
2145 var event = {
2146 type: events_1.Events.EVENT_COLUMN_RESIZED,
2147 column: column,
2148 columns: [column],
2149 finished: true,
2150 api: _this.gridApi,
2151 columnApi: _this.columnApi,
2152 source: "sizeColumnsToFit"
2153 };
2154 _this.eventService.dispatchEvent(event);
2155 });
2156 function moveToNotSpread(column) {
2157 utils_1.Utils.removeFromArray(colsToSpread, column);
2158 colsToNotSpread.push(column);
2159 }
2160 };
2161 ColumnController.prototype.buildDisplayedTrees = function (visibleColumns) {
2162 var leftVisibleColumns = utils_1.Utils.filter(visibleColumns, function (column) {
2163 return column.getPinned() === 'left';
2164 });
2165 var rightVisibleColumns = utils_1.Utils.filter(visibleColumns, function (column) {
2166 return column.getPinned() === 'right';
2167 });
2168 var centerVisibleColumns = utils_1.Utils.filter(visibleColumns, function (column) {
2169 return column.getPinned() !== 'left' && column.getPinned() !== 'right';
2170 });
2171 var groupInstanceIdCreator = new groupInstanceIdCreator_1.GroupInstanceIdCreator();
2172 this.displayedLeftColumnTree = this.displayedGroupCreator.createDisplayedGroups(leftVisibleColumns, this.gridBalancedTree, groupInstanceIdCreator, this.displayedLeftColumnTree);
2173 this.displayedRightColumnTree = this.displayedGroupCreator.createDisplayedGroups(rightVisibleColumns, this.gridBalancedTree, groupInstanceIdCreator, this.displayedRightColumnTree);
2174 this.displayedCentreColumnTree = this.displayedGroupCreator.createDisplayedGroups(centerVisibleColumns, this.gridBalancedTree, groupInstanceIdCreator, this.displayedCentreColumnTree);
2175 };
2176 ColumnController.prototype.updateOpenClosedVisibilityInColumnGroups = function () {
2177 var allColumnGroups = this.getAllDisplayedColumnGroups();
2178 this.columnUtils.depthFirstAllColumnTreeSearch(allColumnGroups, function (child) {
2179 if (child instanceof columnGroup_1.ColumnGroup) {
2180 var columnGroup = child;
2181 columnGroup.calculateDisplayedColumns();
2182 }
2183 });
2184 };
2185 ColumnController.prototype.getGroupAutoColumns = function () {
2186 return this.groupAutoColumns;
2187 };
2188 ColumnController.prototype.createGroupAutoColumnsIfNeeded = function () {
2189 if (!this.autoGroupsNeedBuilding) {
2190 return;
2191 }
2192 this.autoGroupsNeedBuilding = false;
2193 // see if we need to insert the default grouping column
2194 var needAutoColumns = (this.rowGroupColumns.length > 0 || this.usingTreeData)
2195 && !this.gridOptionsWrapper.isGroupSuppressAutoColumn()
2196 && !this.gridOptionsWrapper.isGroupUseEntireRow()
2197 && !this.gridOptionsWrapper.isGroupSuppressRow();
2198 if (needAutoColumns) {
2199 this.groupAutoColumns = this.autoGroupColService.createAutoGroupColumns(this.rowGroupColumns);
2200 }
2201 else {
2202 this.groupAutoColumns = null;
2203 }
2204 };
2205 ColumnController.prototype.createValueColumns = function (source) {
2206 this.valueColumns.forEach(function (column) { return column.setValueActive(false, source); });
2207 this.valueColumns = [];
2208 // override with columns that have the aggFunc specified explicitly
2209 for (var i = 0; i < this.primaryColumns.length; i++) {
2210 var column = this.primaryColumns[i];
2211 if (column.getColDef().aggFunc) {
2212 column.setAggFunc(column.getColDef().aggFunc);
2213 this.valueColumns.push(column);
2214 column.setValueActive(true, source);
2215 }
2216 }
2217 };
2218 ColumnController.prototype.getWidthOfColsInList = function (columnList) {
2219 var result = 0;
2220 for (var i = 0; i < columnList.length; i++) {
2221 result += columnList[i].getActualWidth();
2222 }
2223 return result;
2224 };
2225 ColumnController.prototype.getGridBalancedTree = function () {
2226 return this.gridBalancedTree;
2227 };
2228 __decorate([
2229 context_1.Autowired('gridOptionsWrapper'),
2230 __metadata("design:type", gridOptionsWrapper_1.GridOptionsWrapper)
2231 ], ColumnController.prototype, "gridOptionsWrapper", void 0);
2232 __decorate([
2233 context_1.Autowired('expressionService'),
2234 __metadata("design:type", expressionService_1.ExpressionService)
2235 ], ColumnController.prototype, "expressionService", void 0);
2236 __decorate([
2237 context_1.Autowired('balancedColumnTreeBuilder'),
2238 __metadata("design:type", balancedColumnTreeBuilder_1.BalancedColumnTreeBuilder)
2239 ], ColumnController.prototype, "balancedColumnTreeBuilder", void 0);
2240 __decorate([
2241 context_1.Autowired('displayedGroupCreator'),
2242 __metadata("design:type", displayedGroupCreator_1.DisplayedGroupCreator)
2243 ], ColumnController.prototype, "displayedGroupCreator", void 0);
2244 __decorate([
2245 context_1.Autowired('autoWidthCalculator'),
2246 __metadata("design:type", autoWidthCalculator_1.AutoWidthCalculator)
2247 ], ColumnController.prototype, "autoWidthCalculator", void 0);
2248 __decorate([
2249 context_1.Autowired('eventService'),
2250 __metadata("design:type", eventService_1.EventService)
2251 ], ColumnController.prototype, "eventService", void 0);
2252 __decorate([
2253 context_1.Autowired('columnUtils'),
2254 __metadata("design:type", columnUtils_1.ColumnUtils)
2255 ], ColumnController.prototype, "columnUtils", void 0);
2256 __decorate([
2257 context_1.Autowired('context'),
2258 __metadata("design:type", context_1.Context)
2259 ], ColumnController.prototype, "context", void 0);
2260 __decorate([
2261 context_1.Autowired('columnAnimationService'),
2262 __metadata("design:type", columnAnimationService_1.ColumnAnimationService)
2263 ], ColumnController.prototype, "columnAnimationService", void 0);
2264 __decorate([
2265 context_1.Autowired('autoGroupColService'),
2266 __metadata("design:type", autoGroupColService_1.AutoGroupColService)
2267 ], ColumnController.prototype, "autoGroupColService", void 0);
2268 __decorate([
2269 context_1.Optional('aggFuncService'),
2270 __metadata("design:type", Object)
2271 ], ColumnController.prototype, "aggFuncService", void 0);
2272 __decorate([
2273 context_1.Optional('valueCache'),
2274 __metadata("design:type", valueCache_1.ValueCache)
2275 ], ColumnController.prototype, "valueCache", void 0);
2276 __decorate([
2277 context_1.Autowired('columnApi'),
2278 __metadata("design:type", columnApi_1.ColumnApi)
2279 ], ColumnController.prototype, "columnApi", void 0);
2280 __decorate([
2281 context_1.Autowired('gridApi'),
2282 __metadata("design:type", gridApi_1.GridApi)
2283 ], ColumnController.prototype, "gridApi", void 0);
2284 __decorate([
2285 context_1.PostConstruct,
2286 __metadata("design:type", Function),
2287 __metadata("design:paramtypes", []),
2288 __metadata("design:returntype", void 0)
2289 ], ColumnController.prototype, "init", null);
2290 __decorate([
2291 __param(0, context_1.Qualifier('loggerFactory')),
2292 __metadata("design:type", Function),
2293 __metadata("design:paramtypes", [logger_1.LoggerFactory]),
2294 __metadata("design:returntype", void 0)
2295 ], ColumnController.prototype, "setBeans", null);
2296 ColumnController = __decorate([
2297 context_1.Bean('columnController')
2298 ], ColumnController);
2299 return ColumnController;
2300}());
2301exports.ColumnController = ColumnController;