UNPKG

4.62 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};
17Object.defineProperty(exports, "__esModule", { value: true });
18var context_1 = require("../context/context");
19var beans_1 = require("./beans");
20var cellComp_1 = require("./cellComp");
21var columnController_1 = require("../columnController/columnController");
22var utils_1 = require("../utils");
23var AutoHeightCalculator = (function () {
24 function AutoHeightCalculator() {
25 }
26 AutoHeightCalculator.prototype.registerGridComp = function (gridPanel) {
27 this.gridPanel = gridPanel;
28 };
29 AutoHeightCalculator.prototype.getPreferredHeightForRow = function (rowNode) {
30 var _this = this;
31 if (!this.eDummyContainer) {
32 this.eDummyContainer = document.createElement('div');
33 // so any styles on row also get applied in dummy, otherwise
34 // the content in dummy may differ to the real
35 utils_1._.addCssClass(this.eDummyContainer, 'ag-row ag-row-no-focus');
36 }
37 // we put the dummy into the body container, so it will inherit all the
38 // css styles that the real cells are inheriting
39 var eBodyContainer = this.gridPanel.getBodyContainer();
40 eBodyContainer.appendChild(this.eDummyContainer);
41 var cellComps = [];
42 var cols = this.columnController.getAllAutoRowHeightCols();
43 console.log();
44 cols.forEach(function (col) {
45 var cellComp = new cellComp_1.CellComp(_this.$scope, _this.beans, col, rowNode, null, true);
46 cellComp.setParentRow(_this.eDummyContainer);
47 cellComps.push(cellComp);
48 });
49 var template = cellComps.map(function (cellComp) { return cellComp.getCreateTemplate(); }).join(' ');
50 this.eDummyContainer.innerHTML = template;
51 // this gets any cellComps that are using components to put the components in
52 cellComps.forEach(function (cellComp) { return cellComp.afterAttached(); });
53 // we should be able to just take the height of the row at this point, however
54 // the row isn't expanding to cover the cell heights, i don't know why, i couldn't
55 // figure it out so instead looking at the individual cells instead
56 var maxCellHeight = 0;
57 for (var i = 0; i < this.eDummyContainer.children.length; i++) {
58 var child = this.eDummyContainer.children[i];
59 if (child.offsetHeight > maxCellHeight) {
60 maxCellHeight = child.offsetHeight;
61 }
62 }
63 // we are finished with the dummy container, so get rid of it
64 eBodyContainer.removeChild(this.eDummyContainer);
65 cellComps.forEach(function (cellComp) {
66 // dunno why we need to detach first, doing it here to be consistent with code in RowComp
67 cellComp.detach();
68 cellComp.destroy();
69 });
70 // in case anything left over from last time
71 utils_1._.removeAllChildren(this.eDummyContainer);
72 return maxCellHeight;
73 };
74 __decorate([
75 context_1.Autowired('beans'),
76 __metadata("design:type", beans_1.Beans)
77 ], AutoHeightCalculator.prototype, "beans", void 0);
78 __decorate([
79 context_1.Autowired("$scope"),
80 __metadata("design:type", Object)
81 ], AutoHeightCalculator.prototype, "$scope", void 0);
82 __decorate([
83 context_1.Autowired("columnController"),
84 __metadata("design:type", columnController_1.ColumnController)
85 ], AutoHeightCalculator.prototype, "columnController", void 0);
86 AutoHeightCalculator = __decorate([
87 context_1.Bean('autoHeightCalculator')
88 ], AutoHeightCalculator);
89 return AutoHeightCalculator;
90}());
91exports.AutoHeightCalculator = AutoHeightCalculator;