all files / common/grouping-bar/ grouping-bar.js

91.69% Statements 320/349
74.25% Branches 222/299
95.24% Functions 20/21
91.69% Lines 320/349
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 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541   67× 67× 67× 67× 67× 67×       1847×   76× 76× 76× 76× 76×     76×     76×     76× 76× 76× 76× 76× 76× 76× 76× 76× 76× 76× 76× 76× 76× 76× 76× 76×   76× 76× 76× 76× 304× 304× 304×   304× 304×   76× 25× 25×       25× 25× 25× 25× 25×       18×   25×       23×   25×     51×   76× 10×     814× 814×     814× 814×   814×   814×   814× 814× 814× 747× 747× 1041× 1041×     814× 347× 346×     346× 346×                           814× 775×   775× 13× 13×   775× 775× 775× 775× 775× 56×       719×     775× 775× 775× 775× 775× 775×   775× 775×     775×     775× 775× 775× 775× 775× 775× 775× 775× 775× 701× 701×   775× 775×     775× 743×     775× 775× 1484×   775× 775× 1484× 1484× 1484× 1484× 8099× 8099×         39× 39×   814× 300×   300× 300× 300×           866× 864× 864× 864× 864× 864× 864× 864× 864× 103×   103× 103×     864× 864× 864× 864× 103×   103× 103×         1797× 827×     827×           827× 827× 165× 165×     1797× 1797×   1797×     1797×     1797× 1797× 1797× 1797× 1797× 1797× 790× 790×   1797× 1649× 1649× 1649×     1649× 1649×     1649×     1649× 1649×     1649× 1557×     1649× 1649× 3220×   1649× 1649× 3220× 3220× 3220× 3220× 18360× 18360× 12721×             390× 388× 388× 388× 333×     55×   388× 388× 388×                     1649× 1649× 1649× 1649× 1649× 1552× 1543× 1543× 1543×   1543× 1543× 1543× 1543× 1543× 1543× 1543× 1543× 1543×     1543× 1543× 134×       1409×       1543× 5499× 3956× 3213×     743× 743×   743× 743×                       1543× 1543× 1543× 1543× 1511× 1511× 1511× 1511× 1511× 1511× 1511×                 97× 97×     97×   1649× 1649×     304× 304×   304× 304×   10×                                                                   67×     67× 67×   133× 57×   76× 76×   133× 133× 67× 67×   133×   133×       133× 67×   133× 80×          
define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-base", "@syncfusion/ej2-base", "../../common/base/constant", "../../common/base/css-constant", "./axis-field-renderer", "@syncfusion/ej2-navigations"], function (require, exports, ej2_base_1, ej2_base_2, ej2_base_3, events, cls, axis_field_renderer_1, ej2_navigations_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var GroupingBar = (function () {
        function GroupingBar(parent) {
            this.parent = parent;
            this.parent.groupingBarModule = this;
            this.resColWidth = (this.parent.isAdaptive ? 180 : 249);
            this.addEventListener();
            this.parent.axisFieldModule = new axis_field_renderer_1.AxisFields(this.parent);
            this.touchObj = new ej2_base_2.Touch(this.parent.element, {
                tapHold: this.tapHoldHandler.bind(this)
            });
        }
        GroupingBar.prototype.getModuleName = function () {
            return 'groupingBar';
        };
        GroupingBar.prototype.renderLayout = function () {
            this.groupingTable = ej2_base_1.createElement('div', { className: cls.GROUPING_BAR_CLASS });
            var leftAxisPanel = ej2_base_1.createElement('div', { className: cls.LEFT_AXIS_PANEL_CLASS });
            this.rightAxisPanel = ej2_base_1.createElement('div', { className: cls.RIGHT_AXIS_PANEL_CLASS });
            var rowAxisPanel = ej2_base_1.createElement('div', { className: cls.AXIS_ROW_CLASS + ' ' + cls.AXIS_ICON_CLASS + 'container' });
            var columnAxisPanel = ej2_base_1.createElement('div', {
                className: cls.AXIS_COLUMN_CLASS + ' ' + cls.AXIS_ICON_CLASS + 'container'
            });
            var valueAxisPanel = ej2_base_1.createElement('div', {
                className: cls.AXIS_VALUE_CLASS + ' ' + cls.AXIS_ICON_CLASS + 'container'
            });
            var filterAxisPanel = ej2_base_1.createElement('div', {
                className: cls.AXIS_FILTER_CLASS + ' ' + cls.AXIS_ICON_CLASS + 'container'
            });
            this.rowPanel = ej2_base_1.createElement('div', { className: cls.GROUP_ROW_CLASS + ' ' + cls.ROW_AXIS_CLASS });
            var columnPanel = ej2_base_1.createElement('div', { className: cls.GROUP_COLUMN_CLASS + ' ' + cls.COLUMN_AXIS_CLASS });
            var valuePanel = ej2_base_1.createElement('div', { className: cls.GROUP_VALUE_CLASS + ' ' + cls.VALUE_AXIS_CLASS });
            var filterPanel = ej2_base_1.createElement('div', { className: cls.GROUP_FILTER_CLASS + ' ' + cls.FILTER_AXIS_CLASS });
            rowAxisPanel.appendChild(this.rowPanel);
            columnAxisPanel.appendChild(columnPanel);
            valueAxisPanel.appendChild(valuePanel);
            filterAxisPanel.appendChild(filterPanel);
            this.rowAxisPanel = rowAxisPanel;
            leftAxisPanel.appendChild(valueAxisPanel);
            leftAxisPanel.appendChild(rowAxisPanel);
            this.rightAxisPanel.appendChild(filterAxisPanel);
            this.rightAxisPanel.appendChild(columnAxisPanel);
            this.groupingTable.appendChild(ej2_base_1.createElement('div', { styles: 'display:flex;' }));
            this.groupingTable.firstElementChild.appendChild(leftAxisPanel);
            this.groupingTable.firstElementChild.appendChild(this.rightAxisPanel);
            if (this.parent.dataType === 'pivot' && this.parent.groupingBarSettings != null && this.parent.groupingBarSettings.showFieldsPanel) {
                this.gridPanel = this.createToolbarUI(this.groupingTable);
            }
            this.groupingTable.classList.add(cls.GRID_GROUPING_BAR_CLASS);
            this.groupingTable.querySelector('.' + cls.GROUP_ROW_CLASS).classList.add(cls.GROUP_PIVOT_ROW);
            var axisPanels = [this.rowPanel, columnPanel, valuePanel, filterPanel];
            for (var _i = 0, axisPanels_1 = axisPanels; _i < axisPanels_1.length; _i++) {
                var element = axisPanels_1[_i];
                Eif (this.parent.groupingBarSettings.allowDragAndDrop) {
                    new ej2_base_1.Droppable(element, {});
                }
                this.unWireEvent(element);
                this.wireEvent(element);
            }
            if (this.parent.displayOption.view !== 'Table' && this.parent.groupingBarSettings.displayMode !== 'Table') {
                this.groupingChartTable = this.groupingTable.cloneNode(true);
                Iif (ej2_base_1.select('#' + this.parent.element.id + '_AllFields', this.groupingChartTable)) {
                    ej2_base_1.select('#' + this.parent.element.id + '_AllFields', this.groupingChartTable).remove();
                    this.chartPanel = this.createToolbarUI(this.groupingChartTable);
                }
                this.groupingChartTable.classList.add(cls.CHART_GROUPING_BAR_CLASS);
                this.groupingChartTable.classList.remove(cls.GRID_GROUPING_BAR_CLASS);
                this.groupingChartTable.querySelector('.' + cls.GROUP_ROW_CLASS).classList.add(cls.GROUP_CHART_ROW);
                this.groupingChartTable.querySelector('.' + cls.GROUP_ROW_CLASS).classList.remove(cls.GROUP_PIVOT_ROW);
                if (this.parent.chartSettings.enableMultipleAxis && this.parent.chartSettings.chartSeries &&
                    ['Pie', 'Pyramid', 'Doughnut', 'Funnel'].indexOf(this.parent.chartSettings.chartSeries.type) < 0) {
                    this.groupingChartTable.querySelector('.' + cls.GROUP_VALUE_CLASS).classList.add(cls.GROUP_CHART_MULTI_VALUE);
                }
                else {
                    this.groupingChartTable.querySelector('.' + cls.GROUP_VALUE_CLASS).classList.add(cls.GROUP_CHART_VALUE);
                }
                if (this.parent.chartSettings.chartSeries &&
                    ['Pie', 'Pyramid', 'Doughnut', 'Funnel'].indexOf(this.parent.chartSettings.chartSeries.type) > -1) {
                    this.groupingChartTable.querySelector('.' + cls.GROUP_COLUMN_CLASS).classList.add(cls.GROUP_CHART_COLUMN);
                }
                else {
                    this.groupingChartTable.querySelector('.' + cls.GROUP_COLUMN_CLASS).classList.add(cls.GROUP_CHART_ACCUMULATION_COLUMN);
                }
                this.groupingChartTable.querySelector('.' + cls.GROUP_FILTER_CLASS).classList.add(cls.GROUP_CHART_FILTER);
            }
            else {
                this.groupingChartTable = undefined;
            }
            if (this.parent.displayOption.view === 'Chart' || this.parent.groupingBarSettings.displayMode === 'Chart') {
                this.groupingTable = undefined;
            }
        };
        GroupingBar.prototype.appendToElement = function () {
            var element = this.groupingTable ? this.groupingTable : this.groupingChartTable;
            Iif (ej2_base_2.isNullOrUndefined(element)) {
                return;
            }
            var leftAxisPanel = element.getElementsByClassName(cls.LEFT_AXIS_PANEL_CLASS)[0];
            var filterPanel = element.getElementsByClassName(cls.GROUP_FILTER_CLASS + ' ' +
                cls.FILTER_AXIS_CLASS)[0];
            var columnPanel = element.getElementsByClassName(cls.GROUP_COLUMN_CLASS + ' ' +
                cls.COLUMN_AXIS_CLASS)[0];
            var valuePanel = element.getElementsByClassName(cls.GROUP_VALUE_CLASS + ' ' +
                cls.VALUE_AXIS_CLASS)[0];
            Eif (this.parent.element.querySelector('.' + cls.GRID_CLASS) || this.parent.element.querySelector('.' + cls.PIVOTCHART)) {
                Eif (this.parent.showGroupingBar) {
                    if (this.parent.element.querySelector('.' + cls.GROUPING_BAR_CLASS)) {
                        var elements = this.parent.element.querySelectorAll('.' + cls.GROUPING_BAR_CLASS);
                        for (var i = 0; i < elements.length; i++) {
                            var element_1 = elements[i];
                            ej2_base_1.remove(element_1);
                        }
                    }
                    if (this.groupingChartTable) {
                        if (ej2_base_1.select('#' + this.parent.element.id + '_chart', this.parent.element)) {
                            ej2_base_1.setStyleAttribute(this.groupingChartTable, {
                                width: ej2_base_3.formatUnit(this.parent.grid ? this.parent.getGridWidthAsNumber() : this.parent.getWidthAsNumber())
                            });
                            this.parent.element.insertBefore(this.groupingChartTable, ej2_base_1.select('#' + this.parent.element.id + '_chart', this.parent.element));
                            Iif (this.groupingChartTable.querySelector('.' + cls.ALL_FIELDS_PANEL_CLASS) && this.chartPanel != null && !this.chartPanel.isDestroyed) {
                                var chartPanelWidth = this.parent.grid ? (this.parent.getGridWidthAsNumber() - 2) :
                                    (this.parent.getWidthAsNumber() - 2);
                                this.chartPanel.width = chartPanelWidth < 400 ? '398px' : chartPanelWidth;
                                this.chartPanel.refreshOverflow();
                                if (this.parent.showFieldList && this.parent.pivotFieldListModule && this.parent.pivotFieldListModule.element) {
                                    clearTimeout(this.timeOutObj);
                                    this.timeOutObj = setTimeout(this.alignIcon.bind(this));
                                }
                            }
                        }
                        else {
                            this.groupingChartTable = undefined;
                        }
                    }
                    if (this.parent.displayOption.view !== 'Chart' && this.groupingTable) {
                        if (this.parent.isAdaptive) {
                            leftAxisPanel.style.minWidth = '180px';
                            valuePanel.style.minWidth = '180px';
                        }
                        if (this.parent.firstColWidth) {
                            leftAxisPanel.style.minWidth = 'auto';
                            valuePanel.style.minWidth = 'auto';
                        }
                        filterPanel.removeAttribute('style');
                        columnPanel.removeAttribute('style');
                        this.rowPanel.removeAttribute('style');
                        var emptyRowCount = void 0;
                        if (this.parent.dataType === 'olap') {
                            emptyRowCount = this.parent.olapEngineModule.headerContent ?
                                Object.keys(this.parent.olapEngineModule.headerContent).length : 0;
                        }
                        else {
                            emptyRowCount = this.parent.engineModule.headerContent ?
                                Object.keys(this.parent.engineModule.headerContent).length : 0;
                        }
                        Eif (!ej2_base_2.isNullOrUndefined(emptyRowCount)) {
                            var emptyHeader = this.parent.element.querySelector('.' + cls.HEADERCONTENT).querySelector('.e-columnheader');
                            emptyHeader.removeAttribute('style');
                            ej2_base_3.addClass([emptyHeader.querySelector('.' + cls.HEADERCELL)], 'e-group-row');
                            emptyHeader.querySelector('.e-group-row').querySelector('.e-headercelldiv').style.display = 'none';
                            emptyHeader.querySelector('.e-group-row').querySelector('.e-sortfilterdiv').style.display = 'none';
                        }
                        this.parent.element.insertBefore(this.groupingTable, this.parent.element.querySelector('.' + cls.GRID_CLASS));
                        ej2_base_1.setStyleAttribute(this.groupingTable, {
                            width: ej2_base_3.formatUnit(this.parent.grid ? this.parent.getGridWidthAsNumber() : this.parent.getWidthAsNumber())
                        });
                        if (this.groupingTable && this.groupingTable.querySelector('.' + cls.ALL_FIELDS_PANEL_CLASS) && this.gridPanel != null && !this.gridPanel.isDestroyed) {
                            var gridPanelWidth = this.parent.grid ? (this.parent.getGridWidthAsNumber() - 2) :
                                (this.parent.getWidthAsNumber() - 2);
                            this.gridPanel.width = gridPanelWidth < 400 ? '398px' : gridPanelWidth;
                            this.gridPanel.refreshOverflow();
                        }
                        this.groupingTable.style.minWidth = '400px';
                        this.parent.axisFieldModule.render();
                        this.setGridRowWidth();
                        var colGroupElement = this.parent.element.querySelector('.' + cls.HEADERCONTENT).querySelector('colgroup').children[0];
                        var rightAxisPanelWidth = ej2_base_3.formatUnit(this.groupingTable.offsetWidth - parseInt(colGroupElement.style.width, 10));
                        ej2_base_1.setStyleAttribute(valuePanel, { width: colGroupElement.style.width });
                        ej2_base_1.setStyleAttribute(this.rightAxisPanel, { width: rightAxisPanelWidth });
                        var rightPanelHeight = (valuePanel.offsetHeight / 2);
                        if (rightPanelHeight > columnPanel.offsetHeight) {
                            ej2_base_1.setStyleAttribute(filterPanel, { height: ej2_base_3.formatUnit(rightPanelHeight) });
                            ej2_base_1.setStyleAttribute(columnPanel, { height: ej2_base_3.formatUnit(rightPanelHeight + 2) });
                        }
                        var topLeftHeight = this.parent.element.querySelector('.' + cls.HEADERCONTENT).offsetHeight;
                        ej2_base_1.setStyleAttribute(this.rowPanel, {
                            height: topLeftHeight + 'px'
                        });
                        if (this.parent.element.querySelector('.' + cls.HEADERCONTENT).querySelector('.e-rhandler')) {
                            this.parent.element.querySelector('.' + cls.HEADERCONTENT).querySelector('.e-rhandler').style.height =
                                topLeftHeight + 'px';
                        }
                        var colRows = [].slice.call(this.parent.element.querySelector('.' + cls.HEADERCONTENT).querySelector('thead').querySelectorAll('tr'));
                        var columnRows = colRows.filter(function (trCell) {
                            return (trCell.childNodes.length > 0);
                        });
                        var colHeight = topLeftHeight / columnRows.length;
                        for (var _i = 0, columnRows_1 = columnRows; _i < columnRows_1.length; _i++) {
                            var element_2 = columnRows_1[_i];
                            ej2_base_1.setStyleAttribute(element_2, { 'height': colHeight + 'px' });
                            var rowHeader = [].slice.call(element_2.querySelectorAll('.e-rhandler'));
                            for (var _a = 0, rowHeader_1 = rowHeader; _a < rowHeader_1.length; _a++) {
                                var rhElement = rowHeader_1[_a];
                                ej2_base_1.setStyleAttribute(rhElement, { 'height': colHeight + 'px' });
                            }
                        }
                    }
                    else {
                        this.parent.axisFieldModule.render();
                        this.updateChartAxisHeight();
                    }
                    if (this.parent.showToolbar && this.parent.displayOption.view === 'Both') {
                        var groupingBarSelector = this.parent.currentView === 'Table' ? '.e-chart-grouping-bar'
                            : '.e-pivot-grouping-bar';
                        var groupingBar = this.parent.element.querySelector(groupingBarSelector);
                        Eif (groupingBar) {
                            groupingBar.style.display = 'none';
                        }
                    }
                }
            }
        };
        GroupingBar.prototype.updateChartAxisHeight = function () {
            if (this.groupingChartTable && ej2_base_1.select('#' + this.parent.element.id + '_chart', this.parent.element)) {
                var rowPanel = this.groupingChartTable.querySelector('.' + cls.GROUP_ROW_CLASS);
                var valuePanel = this.groupingChartTable.querySelector('.' + cls.GROUP_VALUE_CLASS);
                var filterPanel = this.groupingChartTable.querySelector('.' + cls.GROUP_FILTER_CLASS);
                var columnPanel = this.groupingChartTable.querySelector('.' + cls.GROUP_COLUMN_CLASS);
                Eif (rowPanel && columnPanel) {
                    rowPanel.style.height = 'auto';
                    columnPanel.style.height = 'auto';
                    if (rowPanel.offsetHeight > 0 && columnPanel.offsetHeight > 0) {
                        var maxHeight = rowPanel.offsetHeight > columnPanel.offsetHeight ? rowPanel.offsetHeight :
                            columnPanel.offsetHeight;
                        ej2_base_1.setStyleAttribute(rowPanel, { height: ej2_base_3.formatUnit(maxHeight) });
                        ej2_base_1.setStyleAttribute(columnPanel, { height: ej2_base_3.formatUnit(maxHeight) });
                    }
                }
                Eif (valuePanel && filterPanel) {
                    valuePanel.style.height = 'auto';
                    filterPanel.style.height = 'auto';
                    if (valuePanel.offsetHeight > 0 && filterPanel.offsetHeight > 0) {
                        var maxHeight = valuePanel.offsetHeight > filterPanel.offsetHeight ? valuePanel.offsetHeight :
                            filterPanel.offsetHeight;
                        ej2_base_1.setStyleAttribute(valuePanel, { height: ej2_base_3.formatUnit(maxHeight) });
                        ej2_base_1.setStyleAttribute(filterPanel, { height: ej2_base_3.formatUnit(maxHeight) });
                    }
                }
            }
        };
        GroupingBar.prototype.refreshUI = function () {
            if (this.groupingChartTable) {
                ej2_base_1.setStyleAttribute(this.groupingChartTable, {
                    width: ej2_base_3.formatUnit(this.parent.grid ? this.parent.getGridWidthAsNumber() : this.parent.getWidthAsNumber())
                });
                Iif (this.groupingChartTable.querySelector('.' + cls.ALL_FIELDS_PANEL_CLASS) && this.chartPanel != null && !this.chartPanel.isDestroyed) {
                    var chartPanelWidth = this.parent.grid ? (this.parent.getGridWidthAsNumber() - 2) :
                        (this.parent.getWidthAsNumber() - 2);
                    this.chartPanel.width = chartPanelWidth < 400 ? '398px' : chartPanelWidth;
                    this.chartPanel.refreshOverflow();
                }
                this.updateChartAxisHeight();
                if (this.parent.showFieldList && this.parent.pivotFieldListModule && this.parent.pivotFieldListModule.element) {
                    clearTimeout(this.timeOutObj);
                    this.timeOutObj = setTimeout(this.alignIcon.bind(this));
                }
            }
            Eif (this.groupingTable) {
                var valuePanel = this.groupingTable.getElementsByClassName(cls.GROUP_VALUE_CLASS + ' ' +
                    cls.VALUE_AXIS_CLASS)[0];
                ej2_base_1.setStyleAttribute(this.groupingTable, {
                    width: ej2_base_3.formatUnit(this.parent.grid ? this.parent.getGridWidthAsNumber() : this.parent.getWidthAsNumber())
                });
                if (this.groupingTable && this.groupingTable.querySelector('.' + cls.ALL_FIELDS_PANEL_CLASS) && this.gridPanel != null && !this.gridPanel.isDestroyed) {
                    var gridPanelWidth = this.parent.grid ? (this.parent.getGridWidthAsNumber() - 2) :
                        (this.parent.getWidthAsNumber() - 2);
                    this.gridPanel.width = gridPanelWidth < 400 ? '398px' : gridPanelWidth;
                    this.gridPanel.refreshOverflow();
                }
                this.groupingTable.style.minWidth = '400px';
                var colGroupElement = this.parent.element.querySelector('.' + cls.HEADERCONTENT).querySelector('colgroup').children[0];
                var rightAxisWidth = ej2_base_3.formatUnit(this.groupingTable.offsetWidth - parseInt(colGroupElement.style.width, 10));
                ej2_base_1.setStyleAttribute(valuePanel, { width: colGroupElement.style.width });
                ej2_base_1.setStyleAttribute(this.rightAxisPanel, { width: rightAxisWidth });
                if (this.parent.showFieldList && this.parent.pivotFieldListModule && this.parent.pivotFieldListModule.element) {
                    clearTimeout(this.timeOutObj);
                    this.timeOutObj = setTimeout(this.alignIcon.bind(this));
                }
                if (!this.parent.grid.element.querySelector('.e-group-row')) {
                    var emptyRowHeader = this.parent.element.querySelector('.' + cls.HEADERCONTENT).querySelector('.e-columnheader');
                    ej2_base_3.addClass([emptyRowHeader.querySelector('.' + cls.HEADERCELL)], 'e-group-row');
                    ej2_base_1.setStyleAttribute(this.rowPanel, {
                        height: this.parent.element.querySelector('.' + cls.HEADERCONTENT).offsetHeight + 'px'
                    });
                    emptyRowHeader.querySelector('.e-group-row').appendChild(this.rowAxisPanel);
                    ej2_base_1.setStyleAttribute(emptyRowHeader.querySelector('.e-group-row').querySelector('.e-headercelldiv'), {
                        display: 'none'
                    });
                    ej2_base_1.setStyleAttribute(emptyRowHeader.querySelector('.e-group-row').querySelector('.e-sortfilterdiv'), {
                        display: 'none'
                    });
                    var groupHeight = this.parent.element.querySelector('.' + cls.HEADERCONTENT).offsetHeight;
                    ej2_base_1.setStyleAttribute(this.rowPanel, {
                        height: groupHeight + 'px'
                    });
                    if (this.parent.element.querySelector('.' + cls.HEADERCONTENT).querySelector('.e-rhandler')) {
                        this.parent.element.querySelector('.' + cls.HEADERCONTENT).querySelector('.e-rhandler').style.height =
                            groupHeight + 'px';
                    }
                    var colRowElements = [].slice.call(this.parent.element.querySelector('.' + cls.HEADERCONTENT).querySelector('thead').querySelectorAll('tr'));
                    var columnRows = colRowElements.filter(function (trCell) {
                        return (trCell.childNodes.length > 0);
                    });
                    var colHeight = groupHeight / columnRows.length;
                    for (var _i = 0, columnRows_2 = columnRows; _i < columnRows_2.length; _i++) {
                        var element = columnRows_2[_i];
                        ej2_base_1.setStyleAttribute(element, { 'height': colHeight + 'px' });
                        var rowHeader = [].slice.call(element.querySelectorAll('.e-rhandler'));
                        for (var _a = 0, rowHeader_2 = rowHeader; _a < rowHeader_2.length; _a++) {
                            var handlerElement = rowHeader_2[_a];
                            if (!handlerElement.parentElement.parentElement.querySelector('.' + cls.FREEZED_CELL)) {
                                ej2_base_1.setStyleAttribute(handlerElement, { 'height': colHeight + 'px' });
                            }
                        }
                    }
                }
            }
        };
        GroupingBar.prototype.alignIcon = function () {
            if (this.parent.pivotFieldListModule) {
                var element = this.parent.pivotFieldListModule.element;
                var currentWidth = void 0;
                if (this.parent.currentView === 'Table') {
                    currentWidth = this.parent.grid ? this.parent.grid.element.offsetWidth : currentWidth;
                }
                else {
                    currentWidth = this.parent.chart ? this.parent.pivotChartModule.getCalulatedWidth() : currentWidth;
                }
                Eif (currentWidth) {
                    var actWidth = currentWidth < 400 ? 400 : currentWidth;
                    ej2_base_1.setStyleAttribute(element.querySelector('.' + cls.TOGGLE_FIELD_LIST_CLASS), {
                        left: ej2_base_3.formatUnit(this.parent.enableRtl ?
                            -Math.abs((actWidth) -
                                element.querySelector('.' + cls.TOGGLE_FIELD_LIST_CLASS).offsetWidth) :
                            (actWidth) -
                                element.querySelector('.' + cls.TOGGLE_FIELD_LIST_CLASS).offsetWidth),
                        top: this.parent.element.querySelector('.' + cls.FIELD_PANEL_SCROLL_CLASS) ? this.parent.element.querySelector('.' + cls.TOGGLE_FIELD_LIST_CLASS).offsetHeight.toString() + 'px' : ''
                    });
                }
            }
        };
        GroupingBar.prototype.setGridRowWidth = function () {
            var emptyRowHeader = this.parent.element.querySelector('.' + cls.HEADERCONTENT).querySelector('.e-columnheader');
            ej2_base_3.addClass([emptyRowHeader.querySelector('.' + cls.HEADERCELL)], 'e-group-row');
            emptyRowHeader.querySelector('.e-group-row').appendChild(this.rowAxisPanel);
            var colGroupElement = this.parent.element.querySelector('.' + cls.HEADERCONTENT).querySelector('colgroup').children[0];
            if (this.rowPanel.querySelector('.' + cls.PIVOT_BUTTON_CLASS)) {
                if (!this.parent.isAdaptive) {
                    var pivotButtons = [].slice.call(this.rowPanel.querySelectorAll('.' + cls.PIVOT_BUTTON_WRAPPER_CLASS));
                    var lastButton = pivotButtons[pivotButtons.length - 1];
                    var lastButtonWidth = (lastButton.querySelector('.' + cls.PIVOT_BUTTON_CLASS).offsetWidth +
                        lastButton.querySelector('.e-indent-div').offsetWidth + 20);
                    var buttonWidth = ej2_base_3.formatUnit(lastButtonWidth < this.resColWidth ? this.resColWidth : lastButtonWidth);
                    var rowHeaderTable = this.parent.element.querySelector('.' + cls.HEADERCONTENT).querySelector('.' + cls.HEADERCELL);
                    var rowContentTable = this.parent.element.querySelector('.' + cls.CONTENT_CLASS).querySelector('tbody').querySelector('.' + cls.FREEZED_CELL);
                    var rowContent = this.parent.element.querySelector('.' + cls.CONTENT_CLASS).querySelector('colgroup').children[0];
                    var colwidth = parseInt(buttonWidth, 10);
                    var hasPivotColumns = this.parent.pivotColumns.length > 0;
                    var gridColumn = this.parent.grid.columns;
                    Eif (gridColumn && gridColumn.length > 0) {
                        gridColumn[0].width = gridColumn[0].autoFit ?
                            gridColumn[0].width : (colwidth > this.resColWidth ? colwidth : this.resColWidth);
                    }
                    var valueColWidth = void 0;
                    if (this.parent.dataType === 'olap') {
                        valueColWidth = this.parent.renderModule.calculateColWidth(this.parent.olapEngineModule.pivotValues.length > 0 ?
                            this.parent.olapEngineModule.pivotValues[0].length : 2);
                    }
                    else {
                        valueColWidth = this.parent.renderModule.calculateColWidth((this.parent.dataSourceSettings.values.length > 0 &&
                            this.parent.engineModule.pivotValues.length > 0) ?
                            this.parent.engineModule.pivotValues[0].length : 2);
                    }
                    for (var cCnt = 0; cCnt < gridColumn.length; cCnt++) {
                        if (cCnt !== 0) {
                            if (gridColumn[cCnt].columns) {
                                this.parent.setCommonColumnsWidth(this.parent.renderModule.pivotColumns[cCnt].columns, valueColWidth);
                            }
                            else {
                                Eif (gridColumn[cCnt].width !== 'auto') {
                                    var levelName = gridColumn[cCnt].customAttributes ?
                                        gridColumn[cCnt].customAttributes.cell.valueSort.levelName : '';
                                    var columnWidth = this.parent.renderModule.setSavedWidth(levelName, valueColWidth);
                                    gridColumn[cCnt].width = (gridColumn[cCnt].autoFit || (hasPivotColumns
                                        && this.parent.pivotColumns[cCnt].autoFit)) ? gridColumn[cCnt].width :
                                        ((this.parent.renderModule.lastColumn &&
                                            this.parent.renderModule.lastColumn.field === gridColumn[cCnt].field) ?
                                            (columnWidth - 3) : columnWidth);
                                }
                                else {
                                    gridColumn[cCnt].minWidth = valueColWidth;
                                }
                            }
                        }
                    }
                    this.parent.posCount = 0;
                    this.parent.setGridColumns(this.parent.grid.columns);
                    this.parent.grid.headerModule.refreshUI();
                    if (!this.parent.firstColWidth) {
                        buttonWidth = gridColumn[0].autoFit ? gridColumn[0].width.toString() : buttonWidth;
                        colGroupElement.style.width = buttonWidth;
                        rowContent.style.width = buttonWidth;
                        rowHeaderTable.style.width = buttonWidth;
                        rowContentTable.style.width = buttonWidth;
                        ej2_base_1.setStyleAttribute(rowHeaderTable, { 'width': buttonWidth });
                        ej2_base_1.setStyleAttribute(rowContentTable, { 'width': buttonWidth });
                    }
                }
                else {
                    Eif (!this.parent.firstColWidth) {
                        var gridColumn = this.parent.grid.columns;
                        Eif (gridColumn && gridColumn.length > 0) {
                            gridColumn[0].width = this.resColWidth;
                        }
                        this.parent.posCount = 0;
                        this.parent.grid.headerModule.refreshUI();
                    }
                }
            }
            else {
                Eif (this.parent.grid.columns && this.parent.grid.columns.length > 0) {
                    this.parent.grid.columns[0].width = this.parent.grid.columns[0].width > this.resColWidth
                        ? this.parent.grid.columns[0].width : this.resColWidth;
                }
                this.parent.grid.headerModule.refreshUI();
            }
            Eif (this.groupingTable || this.groupingChartTable) {
                this.refreshUI();
            }
        };
        GroupingBar.prototype.wireEvent = function (element) {
            ej2_base_2.EventHandler.add(element, 'mouseover', this.dropIndicatorUpdate, this);
            ej2_base_2.EventHandler.add(element, 'mouseleave', this.dropIndicatorUpdate, this);
        };
        GroupingBar.prototype.unWireEvent = function (element) {
            ej2_base_2.EventHandler.remove(element, 'mouseover', this.dropIndicatorUpdate);
            ej2_base_2.EventHandler.remove(element, 'mouseleave', this.dropIndicatorUpdate);
        };
        GroupingBar.prototype.dropIndicatorUpdate = function (e) {
            if ((this.parent.isDragging && e.target.classList.contains(cls.DROPPABLE_CLASS) && e.type === 'mouseover') ||
                (!this.parent.isDragging || (!e.target.classList.contains(cls.DROPPABLE_CLASS) && e.type === 'mouseleave'))) {
                ej2_base_1.removeClass([].slice.call(this.parent.element.querySelectorAll('.' + cls.DROP_INDICATOR_CLASS)), cls.INDICATOR_HOVER_CLASS);
                ej2_base_1.removeClass([].slice.call(this.parent.element.querySelectorAll('.' + cls.DROP_INDICATOR_CLASS + '-last')), cls.INDICATOR_HOVER_CLASS);
            }
        };
        GroupingBar.prototype.tapHoldHandler = function (e) {
            var target = ej2_base_2.closest(e.originalEvent.target, '.' + cls.PIVOT_BUTTON_CLASS);
            if (!ej2_base_2.isNullOrUndefined(target) && this.parent.isAdaptive) {
                var pos = target.getBoundingClientRect();
                this.parent.contextMenuModule.fieldElement = target;
                this.parent.contextMenuModule.menuObj.open(pos.top, pos.left);
                return;
            }
        };
        GroupingBar.prototype.RefreshFieldsPanel = function () {
            if (this.parent.dataType === 'pivot' && this.parent.groupingBarSettings != null) {
                if (ej2_base_1.selectAll('#' + this.parent.element.id + '_AllFields', this.parent.element).length > 0) {
                    for (var _i = 0, _a = ej2_base_1.selectAll('#' + this.parent.element.id + '_AllFields', this.parent.element); _i < _a.length; _i++) {
                        var element = _a[_i];
                        element.remove();
                    }
                }
                if (this.parent.groupingBarSettings.showFieldsPanel) {
                    if (this.groupingChartTable && this.parent.displayOption.view !== 'Table' && this.parent.groupingBarSettings.displayMode !== 'Table') {
                        this.chartPanel = this.createToolbarUI(this.groupingChartTable);
                    }
                    if (this.groupingTable) {
                        this.gridPanel = this.createToolbarUI(this.groupingTable);
                    }
                    this.parent.axisFieldModule.render();
                    this.refreshUI();
                }
            }
        };
        GroupingBar.prototype.createToolbarUI = function (element) {
            Iif (ej2_base_1.select('#' + this.parent.element.id + '_AllFields', element)) {
                ej2_base_1.select('#' + this.parent.element.id + '_AllFields', element).remove();
            }
            element.prepend(ej2_base_1.createElement('div', { id: this.parent.element.id + '_AllFields' }));
            var toolbarObj = new ej2_navigations_1.Toolbar({
                cssClass: cls.ALL_FIELDS_PANEL_CLASS + (this.parent.cssClass ? (' ' + this.parent.cssClass) : ''),
                enableRtl: this.parent.enableRtl, enableHtmlSanitizer: this.parent.enableHtmlSanitizer,
                items: [{ template: '<div class=' + cls.GROUP_ALL_FIELDS_CLASS + '></div>' }],
                allowKeyboard: false,
                width: this.parent.grid ? (this.parent.getGridWidthAsNumber() - 2) : (this.parent.getWidthAsNumber() - 2)
            });
            toolbarObj.appendTo(ej2_base_1.select('#' + this.parent.element.id + '_AllFields', element));
            return toolbarObj;
        };
        GroupingBar.prototype.addEventListener = function () {
            Iif (this.parent.isDestroyed) {
                return;
            }
            this.parent.on(events.initSubComponent, this.renderLayout, this);
            this.parent.on(events.uiUpdate, this.appendToElement, this);
        };
        GroupingBar.prototype.removeEventListener = function () {
            if (this.parent.isDestroyed) {
                return;
            }
            this.parent.off(events.uiUpdate, this.appendToElement);
            this.parent.off(events.initSubComponent, this.renderLayout);
        };
        GroupingBar.prototype.destroy = function () {
            this.removeEventListener();
            if (this.parent.pivotButtonModule) {
                this.parent.pivotButtonModule.destroy();
                this.parent.pivotButtonModule = null;
            }
            if (this.groupingTable && this.groupingTable.querySelector('.' + cls.ALL_FIELDS_PANEL_CLASS) && this.gridPanel != null && !this.gridPanel.isDestroyed) {
                this.gridPanel.destroy();
                this.gridPanel = null;
            }
            Iif (this.groupingChartTable && this.groupingChartTable.querySelector('.' + cls.ALL_FIELDS_PANEL_CLASS) && this.chartPanel != null && !this.chartPanel.isDestroyed) {
                this.chartPanel.destroy();
                this.chartPanel = null;
            }
            if (this.touchObj && !this.touchObj.isDestroyed) {
                this.touchObj.destroy();
            }
            if (this.parent.element.querySelector('.' + cls.GROUPING_BAR_CLASS)) {
                ej2_base_1.remove(this.parent.element.querySelector('.' + cls.GROUPING_BAR_CLASS));
            }
        };
        return GroupingBar;
    }());
    exports.GroupingBar = GroupingBar;
});