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

94.23% Statements 294/312
87.38% Branches 187/214
97.14% Functions 34/35
94.17% Lines 291/309
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   89× 89× 89× 89× 89× 89×   90×   89× 89× 89× 89× 89× 89× 89× 89× 89× 89×   32×     32×         169× 169× 169× 169× 169× 169× 169× 169×   13×   156× 156× 156× 156× 156× 156× 100× 100×     93× 93× 93× 93× 93× 93×   93× 93×             93× 93×   93× 93× 93× 93× 93× 93× 45×   45×   45× 45× 45×             45×       48× 48× 48× 48× 48×   48×               48×   47×       48×     48×   48× 17× 17× 17×   48× 48× 48× 48×     48×       48× 48×   93× 93× 93×         93× 93× 93× 93×   11× 11×         88×   93× 93×   93×   100× 100× 100× 100×           100× 100×     56× 56× 56×     56× 56× 56×       56× 56× 56× 56×   156× 108× 108×   156×             100× 100×       94×   94×   100×   34× 34× 17× 17× 17×     156×   178× 178×   94×   84× 84× 84× 84× 84× 84× 84× 84× 84× 84×       158×   158× 82×     61×   61× 52×         95× 95× 45×     50×       33× 33× 33×               33×         14× 14× 10× 10× 10×         14×                   158× 158×         52×               14×                   154× 154× 773×   154× 41× 41×     154×   81× 81× 18× 274× 18× 30×     301×     30×           21051×        
define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-base", "../base/grid", "../base/util", "../base/constant", "../services/aria-service", "../models/row", "../models/cell", "../base/enum", "../base/string-literals"], function (require, exports, ej2_base_1, ej2_base_2, grid_1, util_1, events, aria_service_1, row_1, cell_1, enum_1, literals) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var DetailRow = (function () {
        function DetailRow(parent, locator) {
            this.aria = new aria_service_1.AriaService();
            this.childRefs = [];
            this.parent = parent;
            this.serviceLocator = locator;
            this.focus = locator.getService('focus');
            this.addEventListener();
        }
        DetailRow.prototype.addEventListener = function () {
            if (this.parent.isDestroyed) {
                return;
            }
            ej2_base_1.EventHandler.add(this.parent.element, 'auxclick', this.auxilaryclickHandler, this);
            this.parent.on(events.click, this.clickHandler, this);
            this.parent.on(events.destroy, this.destroy, this);
            this.parent.on(events.keyPressed, this.keyPressHandler, this);
            this.parent.on(events.expandChildGrid, this.expand, this);
            this.parent.on(events.columnVisibilityChanged, this.refreshColSpan, this);
            this.parent.on(events.destroy, this.destroyChildGrids, this);
            this.parent.on(events.destroyChildGrid, this.destroyChildGrids, this);
            this.parent.on(events.destroy, this.detachDetailTemplate, this);
            this.parent.on(events.detachDetailTemplate, this.detachDetailTemplate, this);
        };
        DetailRow.prototype.clickHandler = function (e) {
            if ((e.target.classList.contains('e-icon-grightarrow') || e.target.classList.contains('e-icon-gdownarrow'))
                && !this.parent.allowGrouping) {
                e.preventDefault();
            }
            this.toogleExpandcollapse(ej2_base_2.closest(e.target, 'td'));
        };
        DetailRow.prototype.auxilaryclickHandler = function (e) {
            if ((e.target.classList.contains('e-icon-grightarrow') || e.target.classList.contains('e-icon-gdownarrow'))
                && !this.parent.allowGrouping && (e.button === 1)) {
                e.preventDefault();
            }
        };
        DetailRow.prototype.toogleExpandcollapse = function (target) {
            this.l10n = this.serviceLocator.getService('localization');
            var gObj = this.parent;
            var table = this.parent.getContentTable();
            var lastrowIdx = this.parent.getCurrentViewRecords().length - 1;
            var parent = 'parentDetails';
            var childGrid;
            var isExpanded = target && target.classList.contains('e-detailrowcollapse');
            if (!(target && (target.classList.contains('e-detailrowcollapse') || target.classList.contains('e-detailrowexpand')))
                || (target && target.classList.contains('e-masked-cell'))) {
                return;
            }
            var tr = target.parentElement;
            var uid = tr.getAttribute('data-uid');
            var rowObj = gObj.getRowObjectFromUID(uid);
            var needToRefresh = false;
            var nextRow = this.parent.getContentTable().querySelector(literals.tbody).children[tr.rowIndex + 1];
            if (target.classList.contains('e-detailrowcollapse')) {
                var data_1 = rowObj.data;
                if (this.isDetailRow(nextRow)) {
                    nextRow.style.display = '';
                    gObj.notify(events.detailStateChange, { data: data_1,
                        childGrid: gObj.childGrid, detailElement: target, isExpanded: isExpanded });
                    needToRefresh = true;
                }
                else Eif (gObj.getDetailTemplate() || gObj.childGrid) {
                    var rowId = util_1.getUid('grid-row');
                    var detailRow = this.parent.createElement('tr', { className: 'e-detailrow', attrs: { 'data-uid': rowId, role: 'row' } });
                    var detailCell_1 = this.parent.createElement('th', { className: 'e-detailcell', attrs: { 'scope': 'col', role: 'columnheader' } });
                    var colSpan = this.parent.getVisibleColumns().length;
                    if (this.parent.allowRowDragAndDrop) {
                        colSpan++;
                    }
                    detailCell_1.setAttribute('colspan', colSpan.toString());
                    var row = new row_1.Row({
                        isDataRow: true,
                        isExpand: true,
                        uid: rowId,
                        isDetailRow: true,
                        cells: [new cell_1.Cell({ cellType: enum_1.CellType.Indent }), new cell_1.Cell({ isDataCell: true, visible: true })]
                    });
                    row.parentUid = rowObj.uid;
                    for (var i = 0, len = gObj.groupSettings.columns.length; i < len; i++) {
                        detailRow.appendChild(this.parent.createElement('td', { className: 'e-indentcell' }));
                        row.cells.unshift(new cell_1.Cell({ cellType: enum_1.CellType.Indent }));
                    }
                    detailRow.appendChild(this.parent.createElement('th', { className: 'e-detailindentcell', attrs: { 'scope': 'col' } }));
                    detailRow.appendChild(detailCell_1);
                    tr.parentNode.insertBefore(detailRow, tr.nextSibling);
                    var isReactCompiler = void 0;
                    var isReactChild = void 0;
                    if (gObj.detailTemplate) {
                        isReactCompiler = this.parent.isReact && typeof (gObj.detailTemplate) !== 'string' &&
                            !(gObj.detailTemplate.prototype && gObj.detailTemplate.prototype.CSPTemplate);
                        isReactChild = this.parent.parentDetails && this.parent.parentDetails.parentInstObj &&
                            this.parent.parentDetails.parentInstObj.isReact;
                        var isReactPrintGrid = this.parent.printGridParent && this.parent.printGridParent.isReact;
                        var detailTemplateID = gObj.element.id + 'detailTemplate';
                        Iif (isReactCompiler || isReactChild || isReactPrintGrid) {
                            gObj.getDetailTemplate()(data_1, gObj, 'detailTemplate', detailTemplateID, null, null, detailCell_1);
                            this.parent.renderTemplates(function () {
                                gObj.trigger(events.detailDataBound, { detailElement: detailCell_1, data: data_1, childGrid: childGrid });
                            });
                        }
                        else {
                            util_1.appendChildren(detailCell_1, gObj.getDetailTemplate()(data_1, gObj, 'detailTemplate', detailTemplateID, undefined, undefined, undefined, this.parent['root']));
                        }
                    }
                    else {
                        childGrid = new grid_1.Grid(this.getGridModel(gObj, rowObj, gObj.printMode));
                        childGrid.height = gObj.enableInfiniteScrolling && childGrid.height === 'auto' ? 300 : childGrid.height;
                        childGrid.root = gObj.root ? gObj.root : gObj;
                        this.childRefs.push(childGrid);
                        if (childGrid.query) {
                            childGrid.query = childGrid.query.clone();
                        }
                        childGrid["" + parent] = {
                            parentID: gObj.element.id,
                            parentPrimaryKeys: gObj.getPrimaryKeyFieldNames(),
                            parentKeyField: gObj.childGrid.queryString,
                            parentKeyFieldValue: gObj.childGrid.queryString && util_1.isComplexField(gObj.childGrid.queryString) ?
                                util_1.getObject(gObj.childGrid.queryString, data_1) : data_1[gObj.childGrid.queryString],
                            parentRowData: data_1
                        };
                        if (gObj.isReact || gObj.isVue) {
                            childGrid.parentDetails.parentInstObj = gObj;
                        }
                        else Iif (gObj.parentDetails && gObj.parentDetails.parentInstObj && (gObj.parentDetails.parentInstObj.isReact
                            || gObj.parentDetails.parentInstObj.isVue)) {
                            childGrid.parentDetails.parentInstObj = gObj.parentDetails.parentInstObj;
                        }
                        Iif (gObj.printGridParent && gObj.printGridParent.isReact) {
                            childGrid.printGridParent = gObj.printGridParent;
                        }
                        childGrid.isLegacyTemplate = gObj.isReact
                            || gObj.isLegacyTemplate;
                        if (gObj.isPrinting) {
                            childGrid.isPrinting = true;
                            childGrid.on(events.contentReady, this.promiseResolve(childGrid), this);
                            childGrid.on(events.onEmpty, this.promiseResolve(childGrid), this);
                        }
                        rowObj.childGrid = childGrid;
                        var modules = childGrid.getInjectedModules();
                        var injectedModues = gObj.getInjectedModules();
                        Iif (!modules || modules.length !== injectedModues.length) {
                            childGrid.setInjectedModules(injectedModues);
                        }
                        var gridElem = this.parent.createElement('div', {
                            id: 'child' + util_1.parents(tr, 'e-grid').length +
                                '_grid' + tr.rowIndex + util_1.getUid(''), className: 'e-childgrid'
                        });
                        detailCell_1.appendChild(gridElem);
                        childGrid.appendTo(gridElem);
                    }
                    detailRow.appendChild(detailCell_1);
                    Eif (tr.nextSibling) {
                        tr.parentNode.insertBefore(detailRow, tr.nextSibling);
                    }
                    else {
                        tr.parentNode.appendChild(detailRow);
                    }
                    var rowElems = gObj.getRows();
                    var rowObjs = gObj.getRowsObject();
                    rowElems.splice(rowElems.indexOf(tr) + 1, 0, detailRow);
                    if (gObj.enableInfiniteScrolling && gObj.infiniteScrollSettings.enableCache) {
                        var infiniteCache = gObj.contentModule
                            .infiniteCache;
                        var keys = Object.keys(infiniteCache);
                        for (var i = 0; i < keys.length; i++) {
                            var cacheIndex = infiniteCache[parseInt(keys[parseInt(i.toString(), 10)], 10)].indexOf(rowObj);
                            if (cacheIndex !== -1) {
                                infiniteCache[parseInt(keys[parseInt(i.toString(), 10)], 10)].splice(cacheIndex + 1, 0, row);
                                break;
                            }
                        }
                    }
                    else {
                        rowObjs.splice(rowObjs.indexOf(rowObj) + 1, 0, row);
                    }
                    Eif (!isReactCompiler || !isReactChild) {
                        gObj.trigger(events.detailDataBound, { detailElement: detailCell_1, data: data_1, childGrid: childGrid });
                    }
                    gObj.notify(events.detailDataBound, { rows: rowObjs });
                }
                ej2_base_2.classList(target, ['e-detailrowexpand'], ['e-detailrowcollapse']);
                ej2_base_2.classList(target.firstElementChild, ['e-dtdiagonaldown', 'e-icon-gdownarrow'], ['e-dtdiagonalright', 'e-icon-grightarrow']);
                rowObj.isExpand = true;
                Iif (target.classList.contains('e-lastrowcell') && this.parent.getContent().clientHeight > table.scrollHeight) {
                    ej2_base_1.removeClass(target.parentElement.querySelectorAll('td'), 'e-lastrowcell');
                    var detailrowIdx = table.querySelector(literals.tbody).getElementsByClassName('e-detailrow').length - 1;
                    ej2_base_1.addClass(table.querySelector(literals.tbody).getElementsByClassName('e-detailrow')[parseInt(detailrowIdx.toString(), 10)].childNodes, ['e-lastrowcell']);
                    this.lastrowcell = true;
                }
                this.aria.setExpand(target, true);
                target.firstElementChild.setAttribute('title', this.l10n.getConstant('Expanded'));
            }
            else {
                Eif (this.isDetailRow(nextRow)) {
                    nextRow.style.display = 'none';
                    gObj.notify(events.detailStateChange, { data: rowObj.data,
                        childGrid: gObj.childGrid, detailElement: target, isExpanded: isExpanded });
                }
                ej2_base_2.classList(target, ['e-detailrowcollapse'], ['e-detailrowexpand']);
                ej2_base_2.classList(target.firstElementChild, ['e-dtdiagonalright', 'e-icon-grightarrow'], ['e-dtdiagonaldown', 'e-icon-gdownarrow']);
                Iif (parseInt(tr.getAttribute(literals.ariaRowIndex), 10) - 1 === lastrowIdx && this.lastrowcell) {
                    ej2_base_1.addClass(target.parentElement.querySelectorAll('td'), 'e-lastrowcell');
                    this.lastrowcell = false;
                }
                rowObj.isExpand = false;
                needToRefresh = true;
                this.aria.setExpand(target, false);
                target.firstElementChild.setAttribute('title', this.l10n.getConstant('Collapsed'));
            }
            if (!ej2_base_2.isNullOrUndefined(gObj.detailTemplate) || (gObj.childGrid && needToRefresh)) {
                gObj.updateVisibleExpandCollapseRows();
                gObj.notify(events.refreshExpandandCollapse, { rows: gObj.getRowsObject() });
            }
            if (this.parent.allowTextWrap && this.parent.height === 'auto') {
                Iif (this.parent.getContentTable().scrollHeight > this.parent.getContent().clientHeight) {
                    this.parent.scrollModule.setPadding();
                }
                else {
                    this.parent.scrollModule.removePadding();
                }
            }
        };
        DetailRow.prototype.getGridModel = function (gObj, rowObj, printMode) {
            var gridModel;
            if (gObj.isPrinting && rowObj.isExpand && gObj.expandedRows &&
                gObj.expandedRows[rowObj.index] && gObj.expandedRows[rowObj.index].gridModel) {
                gObj.expandedRows[rowObj.index].gridModel.hierarchyPrintMode = gObj.childGrid.hierarchyPrintMode;
                gridModel = ej2_base_1.extend({}, gObj.expandedRows[rowObj.index].gridModel, gObj.childGrid, true);
            }
            else {
                if (gObj.isPrinting && gObj.childGrid.allowPaging) {
                    gObj.childGrid.allowPaging = printMode === 'CurrentPage';
                }
                gridModel = ej2_base_1.extend({}, {}, gObj.childGrid, true);
            }
            return gridModel;
        };
        DetailRow.prototype.promiseResolve = function (grid) {
            var _this = this;
            return function () {
                grid.off(events.contentReady, _this.promiseResolve);
                grid.off(events.onEmpty, _this.promiseResolve);
                grid.notify(events.hierarchyPrint, {});
            };
        };
        DetailRow.prototype.isDetailRow = function (row) {
            return row && row.classList.contains('e-detailrow');
        };
        DetailRow.prototype.destroy = function () {
            var gridElement = this.parent.element;
            if (this.parent.isDestroyed || !gridElement || (!gridElement.querySelector('.' + literals.gridHeader) &&
                !gridElement.querySelector('.' + literals.gridContent))) {
                return;
            }
            ej2_base_1.EventHandler.remove(this.parent.element, 'auxclick', this.auxilaryclickHandler);
            this.parent.off(events.click, this.clickHandler);
            this.parent.off(events.destroy, this.destroy);
            this.parent.off(events.keyPressed, this.keyPressHandler);
            this.parent.off(events.expandChildGrid, this.expand);
            this.parent.off(events.columnVisibilityChanged, this.refreshColSpan);
            this.parent.off(events.destroy, this.destroyChildGrids);
            this.parent.off(events.destroyChildGrid, this.destroyChildGrids);
            this.parent.off(events.destroy, this.detachDetailTemplate);
            this.parent.off(events.detachDetailTemplate, this.detachDetailTemplate);
        };
        DetailRow.prototype.getTDfromIndex = function (index, className) {
            var tr = !ej2_base_2.isNullOrUndefined(index) ? this.parent.getDataRows()[parseInt(index.toString(), 10)] : undefined;
            if (tr && tr.querySelector(className)) {
                return tr.querySelector(className);
            }
            return null;
        };
        DetailRow.prototype.expand = function (target) {
            if (!isNaN(target)) {
                target = this.getTDfromIndex(target, '.e-detailrowcollapse');
            }
            if (target && target.classList.contains('e-detailrowcollapse')) {
                this.toogleExpandcollapse(target);
            }
        };
        DetailRow.prototype.collapse = function (target) {
            if (!isNaN(target)) {
                target = this.getTDfromIndex(target, '.e-detailrowexpand');
            }
            if (target && target.classList.contains('e-detailrowexpand')) {
                this.toogleExpandcollapse(target);
            }
        };
        DetailRow.prototype.expandAll = function () {
            this.expandCollapse(true);
            this.parent.trigger(events.actionComplete, { requestType: 'expandAllComplete', type: events.actionComplete, moduleObj: this });
        };
        DetailRow.prototype.collapseAll = function () {
            this.expandCollapse(false);
            this.parent.trigger(events.actionComplete, { requestType: 'collapseAllComplete', type: events.actionComplete, moduleObj: this });
        };
        DetailRow.prototype.expandCollapse = function (isExpand) {
            var td;
            var rows = this.parent.getDataRows();
            for (var i = 0, len = rows.length; i < len; i++) {
                td = rows[parseInt(i.toString(), 10)].querySelector('.e-detailrowcollapse, .e-detailrowexpand');
                if (isExpand) {
                    this.expand(td);
                }
                else {
                    this.collapse(td);
                }
            }
        };
        DetailRow.prototype.keyPressHandler = function (e) {
            var gObj = this.parent;
            var isMacLike = /(Mac)/i.test(navigator.platform);
            Iif (isMacLike && e.metaKey) {
                if (e.action === 'downArrow') {
                    e.action = 'ctrlDownArrow';
                }
                else if (e.action === 'upArrow') {
                    e.action = 'ctrlUpArrow';
                }
            }
            switch (e.action) {
                case 'ctrlDownArrow':
                    this.expandAll();
                    break;
                case 'ctrlUpArrow':
                    this.collapseAll();
                    break;
                case 'altUpArrow':
                case 'altDownArrow':
                    var selected = gObj.allowSelection ? gObj.getSelectedRowIndexes() : [];
                    if (selected.length) {
                        var dataRow = gObj.getDataRows()[selected[selected.length - 1]];
                        var td = dataRow.querySelector('.e-detailrowcollapse, .e-detailrowexpand');
                        if (e.action === 'altDownArrow') {
                            this.expand(td);
                        }
                        else {
                            this.collapse(td);
                        }
                    }
                    break;
                case 'enter':
                    if (this.parent.isEdit) {
                        return;
                    }
                    var element = this.focus.getFocusedElement();
                    if (element && (element.classList.contains('e-icon-grightarrow') || element.classList.contains('e-icon-gdownarrow'))) {
                        element = element.parentElement;
                    }
                    if (element && !element.classList.contains('e-detailrowcollapse') &&
                        !element.classList.contains('e-detailrowexpand')) {
                        break;
                    }
                    this.toogleExpandcollapse(element);
                    break;
            }
        };
        DetailRow.prototype.refreshColSpan = function () {
            var detailrows = this.parent.contentModule.getTable().querySelectorAll('tr.e-detailrow');
            var colSpan = this.parent.getVisibleColumns().length;
            for (var i = 0; i < detailrows.length; i++) {
                detailrows[parseInt(i.toString(), 10)].querySelector('.e-detailcell').setAttribute('colspan', colSpan + '');
            }
        };
        DetailRow.prototype.destroyChildGrids = function (args) {
            var gObj = this.parent;
            if (gObj.enableInfiniteScrolling && (gObj.childGrid || gObj.detailTemplate) && args.requestType === 'infiniteScroll'
                && gObj.infiniteScrollSettings.enableCache) {
                var cacheIndex = args.direction === 'down'
                    ? args.currentPage - gObj.infiniteScrollSettings.initialBlocks
                    : args.currentPage + gObj.infiniteScrollSettings.initialBlocks;
                var infiniteCache_1 = gObj.contentModule
                    .infiniteCache[parseInt(cacheIndex.toString(), 10)];
                var detailRows_1 = infiniteCache_1.filter(function (data) { return data.isDetailRow && data.parentUid; });
                if (gObj.childGrid) {
                    var _loop_1 = function (i) {
                        var detailRow = gObj.getContentTable()
                            .querySelector('[data-uid="' + detailRows_1[parseInt(i.toString(), 10)].uid + '"]');
                        var childGridElement = detailRow.querySelector('.e-childgrid');
                        var childGridIndex = this_1.childRefs.findIndex(function (grid) { return grid.element.id === childGridElement.id; });
                        Eif (!this_1.childRefs[parseInt(childGridIndex.toString(), 10)].isDestroyed) {
                            this_1.childRefs[parseInt(childGridIndex.toString(), 10)].destroy();
                            this_1.childRefs.splice(childGridIndex, 1);
                        }
                        var detailRowIndex = infiniteCache_1.indexOf(detailRows_1[parseInt(i.toString(), 10)]);
                        infiniteCache_1.splice(detailRowIndex, 1);
                        infiniteCache_1[detailRowIndex - 1].childGrid = null;
                        infiniteCache_1[detailRowIndex - 1].isExpand = false;
                        detailRow.remove();
                    };
                    var this_1 = this;
                    for (var i = 0; i < detailRows_1.length; i++) {
                        _loop_1(i);
                    }
                }
                if (gObj.detailTemplate && detailRows_1.length) {
                    var args_1 = [];
                    var _loop_2 = function (i) {
                        args_1.push({
                            detailRow: gObj.getContentTable().querySelector('[data-uid="' + detailRows_1[parseInt(i.toString(), 10)].uid + '"]'),
                            detailRowObject: detailRows_1[parseInt(i.toString(), 10)],
                            parentRowObject: infiniteCache_1.find(function (parent) { return detailRows_1[parseInt(i.toString(), 10)]
                                .parentUid === parent.uid; })
                        });
                    };
                    for (var i = 0; i < detailRows_1.length; i++) {
                        _loop_2(i);
                    }
                    this.parent.trigger(events.beforeDetailTemplateDetach, args_1, function () {
                        for (var i = 0; i < detailRows_1.length; i++) {
                            var detailRow = gObj.getContentTable()
                                .querySelector('[data-uid="' + detailRows_1[parseInt(i.toString(), 10)].uid + '"]');
                            var detailRowIndex = infiniteCache_1.indexOf(detailRows_1[parseInt(i.toString(), 10)]);
                            infiniteCache_1.splice(detailRowIndex, 1);
                            infiniteCache_1[detailRowIndex - 1].isExpand = false;
                            detailRow.remove();
                        }
                    });
                }
                return;
            }
            var rows = this.parent.getRowsObject();
            for (var i = 0; i < rows.length; i++) {
                rows[parseInt(i.toString(), 10)].childGrid = null;
            }
            for (var i = 0; i < this.childRefs.length; i++) {
                Eif (!this.childRefs[parseInt(i.toString(), 10)].isDestroyed) {
                    this.childRefs[parseInt(i.toString(), 10)].destroy();
                }
            }
            this.childRefs = [];
        };
        DetailRow.prototype.detachDetailTemplate = function () {
            var gObj = this.parent;
            if (gObj.detailTemplate) {
                var rowsObject_1 = gObj.getRowsObject();
                var detailRows_2 = rowsObject_1.filter(function (data) { return data.isDetailRow && data.parentUid; });
                if (detailRows_2.length) {
                    var args_2 = [];
                    detailRows_2.map(function (data) {
                        args_2.push({
                            detailRow: gObj.getContentTable().querySelector('[data-uid="' + data.uid + '"]'),
                            detailRowObject: data,
                            parentRowObject: rowsObject_1.find(function (parent) { return data.parentUid === parent.uid; })
                        });
                    });
                    gObj.trigger(events.beforeDetailTemplateDetach, args_2, function () {
                        detailRows_2.map(function (data) {
                            gObj.getContentTable().querySelector('[data-uid="' + data.uid + '"]').remove();
                        });
                    });
                }
            }
        };
        DetailRow.prototype.getModuleName = function () {
            return 'detailRow';
        };
        return DetailRow;
    }());
    exports.DetailRow = DetailRow;
});