| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164 | 1×
 
1×
1×
1×
1005×
 
1×
17901×
17901×
17901×
17901×
17901×
232×
144×
2×
2×
 
142×
 
 
17901×
21×
 
17901×
89671×
 
 
1×
89911×
89911×
89911×
788×
788×
50×
 
788×
 
 
1×
788×
 
 
 
788×
788×
788×
788×
788×
788×
788×
31×
 
 
757×
 
788×
788×
 
788×
788×
39×
 
 
 
749×
 
788×
788×
 
788×
788×
 
 
 
 
 
1×
5×
5×
5×
 
1×
10×
10×
10×
10×
89×
9×
 
23×
 
10×
 
1×
90403×
28×
 
90403×
89128×
 
1275×
1275×
2×
 
1273×
2×
 
 
1271×
 
 
1×
135×
135×
470×
470×
470×
464×
 
 
135×
 
1×
41×
41×
41×
41×
41×
 
1×
41×
41×
41×
41×
41×
 
 
41×
 
 
1×
52×
52×
41×
41×
 
 
11×
 
 
11×
11×
 
52×
52×
 
 
 
1×
 
1×
 
  | define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-base", "../base/constant", "../models/column"], function (require, exports, ej2_base_1, ej2_base_2, constant_1, column_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var ColumnWidthService = (function () {
        function ColumnWidthService(parent) {
            this.parent = parent;
        }
        ColumnWidthService.prototype.setWidthToColumns = function () {
            var _this = this;
            var i = 0;
            var indexes = this.parent.getColumnIndexesInView();
            var wFlag = true;
            if (this.parent.allowGrouping) {
                for (var len = this.parent.groupSettings.columns.length; i < len; i++) {
                    if (this.parent.enableColumnVirtualization && indexes.indexOf(i) === -1) {
                        wFlag = false;
                        continue;
                    }
                    this.setColumnWidth(new column_1.Column({ width: '30px' }), i);
                }
            }
            if (this.parent.detailTemplate || this.parent.childGrid) {
                this.setColumnWidth(new column_1.Column({ width: '30px' }), i);
            }
            this.parent.getColumns().forEach(function (column, index) {
                _this.setColumnWidth(column, wFlag ? undefined : index);
            });
        };
        ColumnWidthService.prototype.setColumnWidth = function (column, index, module) {
            var columnIndex = ej2_base_1.isNullOrUndefined(index) ? this.parent.getNormalizedColumnIndex(column.uid) : index;
            var cWidth = this.getWidth(column);
            if (cWidth !== null) {
                this.setWidth(cWidth, columnIndex);
                if ((this.parent.allowResizing && module === 'resize') || (this.parent.getFrozenColumns() && this.parent.allowResizing)) {
                    this.setWidthToTable();
                }
                this.parent.notify(constant_1.columnWidthChanged, { index: columnIndex, width: cWidth, column: column, module: module });
            }
        };
        ColumnWidthService.prototype.setWidth = function (width, index) {
            Iif (typeof (width) === 'string' && width.indexOf('%') !== -1) {
                var elementWidth = this.parent.element.offsetWidth;
                width = parseInt(width, 10) / 100 * (elementWidth);
            }
            var header = this.parent.getHeaderTable();
            var content = this.parent.getContentTable();
            var fWidth = ej2_base_2.formatUnit(width);
            var headerCol;
            var frzCols = this.parent.getFrozenColumns();
            var mHdr = this.parent.getHeaderContent().querySelector('.e-movableheader');
            if (frzCols && index >= frzCols && mHdr && mHdr.querySelector('colgroup')) {
                headerCol = mHdr.querySelector('colgroup').children[index - frzCols];
            }
            else {
                headerCol = header.querySelector('colgroup').children[index];
            }
            Eif (headerCol) {
                headerCol.style.width = fWidth;
            }
            var contentCol;
            if (frzCols && index >= frzCols) {
                contentCol = this.parent.getContent().querySelector('.e-movablecontent')
                    .querySelector('colgroup').children[index - frzCols];
            }
            else {
                contentCol = content.querySelector('colgroup').children[index];
            }
            Eif (contentCol) {
                contentCol.style.width = fWidth;
            }
            var edit = content.querySelector('.e-table.e-inline-edit');
            Iif (edit) {
                if (edit.querySelector('colgroup').children[index]) {
                    edit.querySelector('colgroup').children[index].style.width = fWidth;
                }
            }
        };
        ColumnWidthService.prototype.getSiblingsHeight = function (element) {
            var previous = this.getHeightFromDirection(element, 'previous');
            var next = this.getHeightFromDirection(element, 'next');
            return previous + next;
        };
        ColumnWidthService.prototype.getHeightFromDirection = function (element, direction) {
            var sibling = element[direction + 'ElementSibling'];
            var result = 0;
            var classList = ['e-gridheader', 'e-gridfooter', 'e-groupdroparea', 'e-gridpager', 'e-toolbar'];
            while (sibling) {
                if (classList.some(function (value) { return sibling.classList.contains(value); })) {
                    result += sibling.offsetHeight;
                }
                sibling = sibling[direction + 'ElementSibling'];
            }
            return result;
        };
        ColumnWidthService.prototype.getWidth = function (column) {
            if (ej2_base_1.isNullOrUndefined(column.width) && this.parent.allowResizing) {
                column.width = 200;
            }
            if (!column.width) {
                return null;
            }
            var width = parseInt(column.width.toString(), 10);
            if (column.minWidth && width < parseInt(column.minWidth.toString(), 10)) {
                return column.minWidth;
            }
            else if ((column.maxWidth && width > parseInt(column.maxWidth.toString(), 10))) {
                return column.maxWidth;
            }
            else {
                return column.width;
            }
        };
        ColumnWidthService.prototype.getTableWidth = function (columns) {
            var tWidth = 0;
            for (var _i = 0, columns_1 = columns; _i < columns_1.length; _i++) {
                var column = columns_1[_i];
                var cWidth = this.getWidth(column);
                if (column.visible !== false && cWidth !== null) {
                    tWidth += parseInt(cWidth.toString(), 10);
                }
            }
            return tWidth;
        };
        ColumnWidthService.prototype.setWidthToFrozenTable = function () {
            var columns = this.parent.getColumns();
            columns.splice(this.parent.getFrozenColumns(), columns.length);
            var freezeWidth = ej2_base_2.formatUnit(this.getTableWidth(columns));
            this.parent.getHeaderTable().style.width = freezeWidth;
            this.parent.getContentTable().style.width = freezeWidth;
        };
        ColumnWidthService.prototype.setWidthToMovableTable = function () {
            var columns = this.parent.getColumns();
            columns.splice(0, this.parent.getFrozenColumns());
            var movableWidth = ej2_base_2.formatUnit(this.getTableWidth(columns));
            Eif (this.parent.getHeaderContent().querySelector('.e-movableheader').firstElementChild) {
                this.parent.getHeaderContent().querySelector('.e-movableheader').firstElementChild.style.width
                    = movableWidth;
            }
            this.parent.getContent().querySelector('.e-movablecontent').firstElementChild.style.width =
                movableWidth;
        };
        ColumnWidthService.prototype.setWidthToTable = function () {
            var tWidth = ej2_base_2.formatUnit(this.getTableWidth(this.parent.getColumns()));
            if (this.parent.getFrozenColumns()) {
                this.setWidthToFrozenTable();
                this.setWidthToMovableTable();
            }
            else {
                Iif (this.parent.detailTemplate || this.parent.childGrid) {
                    this.setColumnWidth(new column_1.Column({ width: '30px' }));
                }
                this.parent.getHeaderTable().style.width = tWidth;
                this.parent.getContentTable().style.width = tWidth;
            }
            var edit = this.parent.element.querySelector('.e-table.e-inline-edit');
            Iif (edit) {
                edit.style.width = tWidth;
            }
        };
        return ColumnWidthService;
    }());
    exports.ColumnWidthService = ColumnWidthService;
});
  |