all files / treegrid/actions/ freeze-column.js

93.44% Statements 57/61
92.11% Branches 35/38
100% Functions 13/13
93.44% Lines 57/61
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   52× 52× 52×   52× 52× 52×   55× 52×     24× 24× 24× 24× 24×   24× 80×     24× 24× 800×           24× 86× 86× 86× 52×   86× 86× 10×   86×   86× 21× 21× 756×       21×             25×       81× 561×   81×     55×   11395×        
define(["require", "exports", "@syncfusion/ej2-grids", "@syncfusion/ej2-grids", "@syncfusion/ej2-base"], function (require, exports, ej2_grids_1, ej2_grids_2, ej2_base_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var Freeze = (function () {
        function Freeze(parent) {
            ej2_grids_2.Grid.Inject(ej2_grids_2.Freeze);
            this.parent = parent;
            this.addEventListener();
        }
        Freeze.prototype.addEventListener = function () {
            this.parent.on('rowExpandCollapse', this.rowExpandCollapse, this);
            this.parent.on('dataBoundArg', this.dataBoundArg, this);
            this.parent.grid.on('dblclick', this.dblClickHandler, this);
        };
        Freeze.prototype.removeEventListener = function () {
            if (this.parent.isDestroyed) {
                return;
            }
            this.parent.off('rowExpandCollapse', this.rowExpandCollapse);
            this.parent.off('dataBoundArg', this.dataBoundArg);
            this.parent.grid.off('dblclick', this.dblClickHandler);
        };
        Freeze.prototype.rowExpandCollapse = function (args) {
            var movableRows = this.parent.getDataRows();
            var frozenrows = this.parent.getRows();
            var rows;
            var frozenRightRows;
            var freeze = (this.parent.getFrozenLeftColumnsCount() > 0 ||
                this.parent.getFrozenRightColumnsCount() > 0) ? true : false;
            if (freeze) {
                frozenRightRows = this.parent.getRows().filter(function (e) {
                    return e.querySelector('.e-gridrowindex' + args.record.index + 'level' + (args.record.level + 1));
                });
            }
            Eif (!args.detailrows.length) {
                rows = movableRows.filter(function (e) {
                    return e.querySelector('.e-gridrowindex' + args.record.index + 'level' + (args.record.level + 1));
                });
            }
            else {
                rows = args.detailrows;
            }
            for (var i = 0; i < rows.length; i++) {
                var row = rows[parseInt(i.toString(), 10)];
                var rData = this.parent.grid.getRowObjectFromUID(row.getAttribute('data-Uid')).data;
                if (!ej2_base_1.isNullOrUndefined(movableRows) && row.parentElement.firstElementChild.clientHeight > 0) {
                    row.style.height = row.parentElement.firstElementChild.clientHeight + 'px';
                }
                this.parent['toggleRowVisibility'](row, args.action);
                if (freeze && frozenRightRows.length) {
                    this.parent['toggleRowVisibility'](frozenRightRows[parseInt(i.toString(), 10)], args.action);
                }
                var queryselector = args.action === 'e-childrow-hidden' ? '.e-treecolumn-container .e-treegridcollapse'
                    : '.e-treecolumn-container .e-treegridexpand';
                if (frozenrows[row.rowIndex].querySelector(queryselector)) {
                    var cRow = [];
                    for (var i_1 = 0; i_1 < movableRows.length; i_1++) {
                        Iif (movableRows[parseInt(i_1.toString(), 10)].querySelector('.e-gridrowindex' + rData.index + 'level' + (rData.level + 1))) {
                            cRow.push(movableRows[parseInt(i_1.toString(), 10)]);
                        }
                    }
                    Iif (cRow.length) {
                        var data = this.parent.getCurrentViewRecords()[cRow[0].rowIndex];
                        this.rowExpandCollapse({ detailrows: cRow, action: args.action, record: data });
                    }
                }
            }
        };
        Freeze.prototype.dblClickHandler = function (e) {
            if (ej2_grids_1.parentsUntil(e.target, 'e-rowcell') &&
                this.parent.grid.editSettings.allowEditOnDblClick && this.parent.editSettings.mode !== 'Cell' && (!e.target['classList'].contains('e-treegridcollapse') && !e.target['classList'].contains('e-treegridexpand'))) {
                this.parent.startEdit(ej2_grids_1.parentsUntil(e.target, 'e-row'));
            }
        };
        Freeze.prototype.dataBoundArg = function () {
            var checkboxColumn = this.parent.getColumns().filter(function (e) {
                return e.showCheckbox;
            });
            if (checkboxColumn.length && this.parent.freezeModule && this.parent.initialRender) {
                ej2_base_1.addClass([this.parent.element.getElementsByClassName('e-grid')[0]], 'e-checkselection');
            }
        };
        Freeze.prototype.destroy = function () {
            this.removeEventListener();
        };
        Freeze.prototype.getModuleName = function () {
            return 'freeze';
        };
        return Freeze;
    }());
    exports.Freeze = Freeze;
});