all files / treegrid/actions/ detail-row.js

90.54% Statements 67/74
88.24% Branches 15/17
100% Functions 15/15
90.41% Lines 66/73
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   17× 17× 17×   11279×   17× 17× 17× 17× 17× 17×   17× 17×                 356× 356×   29× 338×   29× 338× 338× 338× 338×   330×       74× 74×     24×     24× 66×     338× 338× 338× 338× 338× 1095× 338× 338× 338× 338×     136×     17×        
define(["require", "exports", "@syncfusion/ej2-grids", "@syncfusion/ej2-grids", "@syncfusion/ej2-base", "../utils"], function (require, exports, ej2_grids_1, ej2_grids_2, ej2_base_1, utils_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var DetailRow = (function () {
        function DetailRow(parent) {
            ej2_grids_1.Grid.Inject(ej2_grids_2.DetailRow);
            this.parent = parent;
            this.addEventListener();
        }
        DetailRow.prototype.getModuleName = function () {
            return 'detailRow';
        };
        DetailRow.prototype.addEventListener = function () {
            this.parent.on('dataBoundArg', this.dataBoundArg, this);
            this.parent.on('detaildataBound', this.detaildataBound, this);
            this.parent.grid.on('detail-indentcell-info', this.setIndentVisibility, this);
            this.parent.on('childRowExpand', this.childRowExpand, this);
            this.parent.on('rowExpandCollapse', this.rowExpandCollapse, this);
            this.parent.on('actioncomplete', this.actioncomplete, this);
        };
        DetailRow.prototype.removeEventListener = function () {
            Eif (this.parent.isDestroyed) {
                return;
            }
            this.parent.off('dataBoundArg', this.dataBoundArg);
            this.parent.off('detaildataBound', this.detaildataBound);
            this.parent.off('childRowExpand', this.childRowExpand);
            this.parent.off('rowExpandCollapse', this.rowExpandCollapse);
            this.parent.off('actioncomplete', this.actioncomplete);
            this.parent.grid.off('detail-indentcell-info', this.setIndentVisibility);
        };
        DetailRow.prototype.setIndentVisibility = function (args) {
            var visible = 'visible';
            args["" + visible] = false;
        };
        DetailRow.prototype.dataBoundArg = function () {
            var detailele = this.parent.getRows().filter(function (e) {
                return !e.classList.contains('e-detailrow');
            });
            for (var i = 0; i < detailele.length; i++) {
                var elements = detailele[parseInt(i.toString(), 10)].getElementsByClassName('e-detailrowcollapse');
                var detailData = this.parent.grid.getRowObjectFromUID(detailele[parseInt(i.toString(), 10)].getAttribute('data-Uid'));
                var parentItem = ej2_grids_1.getObject('parentItem', this.parent.grid.getCurrentViewRecords()[parseInt(i.toString(), 10)]);
                if (ej2_base_1.isNullOrUndefined(parentItem) || !ej2_base_1.isNullOrUndefined(parentItem) &&
                    utils_1.getExpandStatus(this.parent, detailData.data, this.parent.grid.getCurrentViewRecords())) {
                    this.parent.grid.detailRowModule.expand(elements[0]);
                }
            }
        };
        DetailRow.prototype.childRowExpand = function (args) {
            var detailRowElement = args.row.getElementsByClassName('e-detailrowcollapse');
            if (!ej2_base_1.isNullOrUndefined(detailRowElement[0])) {
                this.parent.grid.detailRowModule.expand(detailRowElement[0]);
            }
        };
        DetailRow.prototype.rowExpandCollapse = function (args) {
            Iif (utils_1.isRemoteData(this.parent)) {
                return;
            }
            for (var i = 0; i < args.detailrows.length; i++) {
                this.parent['toggleRowVisibility'](args.detailrows[parseInt(i.toString(), 10)], args.action);
            }
        };
        DetailRow.prototype.detaildataBound = function (args) {
            var data = args.data;
            var row = args.detailElement.parentElement.previousSibling;
            var index = !ej2_base_1.isNullOrUndefined(data.parentItem) ? data.parentItem.index : data.index;
            var expandClass = 'e-gridrowindex' + index + 'level' + data.level;
            var classlist = row.querySelector('.' + expandClass).classList;
            var gridClas = [].slice.call(classlist).filter(function (gridclass) { return (gridclass === expandClass); });
            var newNo = gridClas[0].length;
            var slicedclas = gridClas.toString().slice(6, newNo);
            var detailClass = 'e-griddetail' + slicedclas;
            ej2_base_1.addClass([args.detailElement.parentElement], detailClass);
        };
        DetailRow.prototype.actioncomplete = function (args) {
            if (args.requestType === 'beginEdit' || args.requestType === 'add') {
                var spann = (args.row.querySelectorAll('.e-editcell')[0].getAttribute('colSpan'));
                var colum = parseInt(spann, 10) - 1;
                var updtdcolum = colum.toString();
                args.row.querySelectorAll('.e-editcell')[0].setAttribute('colSpan', updtdcolum);
            }
            var focusElement = this.parent.grid.contentModule.getRows();
            for (var i = 0; i < focusElement.length; i++) {
                focusElement[parseInt(i.toString(), 10)].cells[0].visible = false;
            }
            var focusModule = ej2_grids_1.getObject('focusModule', this.parent.grid);
            var matrix = 'refreshMatrix';
            focusModule["" + matrix](true)({ rows: this.parent.grid.contentModule.getRows() });
        };
        DetailRow.prototype.destroy = function () {
            this.removeEventListener();
        };
        return DetailRow;
    }());
    exports.DetailRow = DetailRow;
});