| 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 | 1×
 
1×
1×
1×
394×
394×
394×
394×
394×
394×
 
 
 
394×
11801×
11801×
11795×
11795×
17×
 
11778×
11778×
93×
 
11778×
11778×
11730×
11730×
31×
 
 
11778×
11778×
11778×
11777×
7×
7×
 
 
11777×
11729×
 
 
 
394×
394×
394×
394×
394×
 
 
394×
394×
394×
 
1×
336×
336×
336×
 
 
336×
336×
336×
336×
 
1×
337×
337×
337×
337×
 
 
337×
337×
26×
 
 
1×
360×
360×
 
 
 
 
 
360×
360×
360×
360×
360×
 
1×
11803×
98×
49×
49×
 
 
49×
 
 
 
1×
11803×
11803×
11803×
11803×
 
 
11803×
11803×
11803×
11803×
11803×
11803×
11803×
11803×
11803×
11803×
11803×
11803×
11803×
11803×
11803×
 
 
11803×
11803×
 
 
11803×
8×
8×
 
11803×
49×
 
 
11754×
 
11803×
178463×
178433×
178433×
176×
 
 
178257×
 
 
 
30×
30×
15×
15×
15×
15×
 
 
15×
 
 
 
15×
 
 
 
15×
 
 
 
15×
 
 
 
178463×
178463×
177789×
177789×
177759×
 
177789×
 
178463×
 
11803×
11803×
89×
 
87×
87×
 
11801×
6×
 
11801×
49×
 
11801×
11801×
11801×
11801×
11794×
11794×
11777×
11777×
 
11794×
96×
96×
50×
50×
 
 
46×
 
 
46×
46×
46×
46×
46×
 
 
 
11698×
 
11793×
49×
 
11791×
 
 
1×
11682×
11682×
 
1×
66836×
 
1×
360×
 
1×
252531×
 
1×
361×
 
1×
25822×
 
1×
445×
 
1×
1083×
 
1×
240×
 
1×
46×
 
1×
35582×
 
1×
17949×
 
1×
11106×
11106×
11106×
11106×
7×
7×
7×
7×
7×
95×
95×
95×
285×
 
95×
 
 
 
11099×
 
11106×
11106×
11107×
11106×
11107×
11106×
11106×
17410×
17410×
17410×
17390×
 
20×
20×
8×
6×
 
 
2×
2×
 
 
 
12×
 
 
11106×
 
1×
17567×
17566×
17566×
17566×
 
 
1×
337×
337×
 
 
 
 
1×
17410×
 
 
 
1×
360×
 
1×
375×
375×
29×
 
 
1×
1214×
4850×
 
14524×
 
7488×
41355×
 
 
1×
1911×
 
1×
6×
 
1×
261×
 
1×
63×
4×
 
 
1×
 
1×
 
  | define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-base", "@syncfusion/ej2-base", "../base/util", "../base/constant", "./row-renderer", "./cell-merge-renderer", "../services/row-model-generator", "../services/group-model-generator", "../base/util"], function (require, exports, ej2_base_1, ej2_base_2, ej2_base_3, util_1, events, row_renderer_1, cell_merge_renderer_1, row_model_generator_1, group_model_generator_1, util_2) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var ContentRender = (function () {
        function ContentRender(parent, serviceLocator) {
            var _this = this;
            this.rows = [];
            this.freezeRows = [];
            this.movableRows = [];
            this.isLoaded = true;
            this.drop = function (e) {
                _this.parent.notify(events.columnDrop, { target: e.target, droppedElement: e.droppedElement });
                ej2_base_3.remove(e.droppedElement);
            };
            this.rafCallback = function (args) {
                var arg = args;
                return function () {
                    _this.ariaService.setBusy(_this.getPanel().firstChild, false);
                    if (_this.parent.isDestroyed) {
                        return;
                    }
                    var rows = _this.rows.slice(0);
                    if (_this.parent.getFrozenColumns() !== 0) {
                        rows = args.isFrozen ? _this.freezeRows : _this.movableRows;
                    }
                    _this.parent.notify(events.contentReady, { rows: rows, args: arg });
                    if (_this.isLoaded) {
                        _this.parent.trigger(events.dataBound, {});
                        if (_this.parent.allowTextWrap) {
                            _this.parent.notify(events.freezeRender, { case: 'textwrap' });
                        }
                    }
                    Eif (arg) {
                        var action = (arg.requestType || '').toLowerCase() + '-complete';
                        _this.parent.notify(action, arg);
                        if (args.requestType === 'batchsave') {
                            args.cancel = false;
                            _this.parent.trigger(events.actionComplete, args);
                        }
                    }
                    if (_this.isLoaded) {
                        _this.parent.hideSpinner();
                    }
                };
            };
            this.parent = parent;
            this.serviceLocator = serviceLocator;
            this.ariaService = this.serviceLocator.getService('ariaService');
            this.generator = this.getModelGenerator();
            Iif (this.parent.isDestroyed) {
                return;
            }
            this.parent.on(events.columnVisibilityChanged, this.setVisible, this);
            this.parent.on(events.colGroupRefresh, this.colGroupRefresh, this);
            this.parent.on(events.uiUpdate, this.enableAfterRender, this);
        }
        ContentRender.prototype.renderPanel = function () {
            var gObj = this.parent;
            var div = ej2_base_3.createElement('div', { className: 'e-gridcontent' });
            var innerDiv = ej2_base_3.createElement('div', {
                className: 'e-content'
            });
            this.ariaService.setOptions(innerDiv, { busy: false });
            div.appendChild(innerDiv);
            this.setPanel(div);
            gObj.element.appendChild(div);
        };
        ContentRender.prototype.renderTable = function () {
            var contentDiv = this.getPanel();
            contentDiv.appendChild(this.createContentTable('_content_table'));
            this.setTable(contentDiv.querySelector('.e-table'));
            this.ariaService.setOptions(this.getTable(), {
                multiselectable: this.parent.selectionSettings.type === 'Multiple'
            });
            this.initializeContentDrop();
            if (this.parent.frozenRows) {
                this.parent.getHeaderContent().classList.add('e-frozenhdrcont');
            }
        };
        ContentRender.prototype.createContentTable = function (id) {
            var innerDiv = this.getPanel().firstChild;
            var table = ej2_base_3.createElement('table', {
                className: 'e-table', attrs: {
                    cellspacing: '0.25px', role: 'grid',
                    id: this.parent.element.id + id
                }
            });
            this.setColGroup(this.parent.element.querySelector('.e-gridheader').querySelector('colgroup').cloneNode(true));
            table.appendChild(this.getColGroup());
            table.appendChild(ej2_base_3.createElement('tbody'));
            innerDiv.appendChild(table);
            return innerDiv;
        };
        ContentRender.prototype.splitRows = function (idx) {
            if (this.parent.getFrozenColumns()) {
                if (idx === 0) {
                    this.freezeRows = this.rows;
                    this.freezeRowElements = this.rowElements;
                }
                else {
                    this.movableRows = this.rows;
                }
            }
        };
        ContentRender.prototype.refreshContentRows = function (args) {
            var _this = this;
            if (args === void 0) { args = {}; }
            var gObj = this.parent;
            Iif (gObj.currentViewData.length === 0) {
                return;
            }
            var dataSource = gObj.currentViewData;
            var frag = document.createDocumentFragment();
            var hdrfrag = document.createDocumentFragment();
            var columns = gObj.getColumns();
            var tr;
            var hdrTbody;
            var frzCols = gObj.getFrozenColumns();
            var row = new row_renderer_1.RowRenderer(this.serviceLocator, null, this.parent);
            this.rowElements = [];
            this.rows = [];
            var fCont = this.getPanel().querySelector('.e-frozencontent');
            var mCont = this.getPanel().querySelector('.e-movablecontent');
            var cont = this.getPanel().querySelector('.e-content');
            var modelData = this.generator.generateRows(dataSource, args);
            Iif (ej2_base_2.isNullOrUndefined(modelData[0].cells[0])) {
                mCont.querySelector('tbody').innerHTML = '';
            }
            var idx = modelData[0].cells[0].index;
            Iif (this.parent.registeredTemplate && this.parent.registeredTemplate.template) {
                this.parent.destroyTemplate(['template']);
            }
            if (this.parent.enableColumnVirtualization) {
                var cellMerge = new cell_merge_renderer_1.CellMergeRender(this.serviceLocator, this.parent);
                cellMerge.updateVirtualCells(modelData);
            }
            if (frzCols && idx >= frzCols) {
                this.tbody = mCont.querySelector('tbody');
            }
            else {
                this.tbody = this.getTable().querySelector('tbody');
            }
            for (var i = 0, len = modelData.length; i < len; i++) {
                if (!gObj.rowTemplate) {
                    tr = row.render(modelData[i], columns);
                    if (gObj.frozenRows && i < gObj.frozenRows) {
                        hdrfrag.appendChild(tr);
                    }
                    else {
                        frag.appendChild(tr);
                    }
                }
                else {
                    var elements = gObj.getRowTemplate()(ej2_base_2.extend({ index: i }, dataSource[i]), gObj, 'rowTemplate');
                    if (elements[0].tagName === 'TBODY') {
                        for (var j = 0; j < elements.length; j++) {
                            var isTR = elements[j].nodeName.toLowerCase() === 'tr';
                            Eif (isTR || (elements[j].querySelectorAll && elements[j].querySelectorAll('tr').length)) {
                                tr = isTR ? elements[j] : elements[j].querySelector('tr');
                            }
                        }
                        Iif (gObj.frozenRows && i < gObj.frozenRows) {
                            hdrfrag.appendChild(tr);
                        }
                        else {
                            frag.appendChild(tr);
                        }
                    }
                    else {
                        Iif (gObj.frozenRows && i < gObj.frozenRows) {
                            tr = util_1.appendChildren(hdrfrag, elements);
                        }
                        else {
                            tr = util_1.appendChildren(frag, elements);
                        }
                    }
                }
                this.rows.push(modelData[i]);
                if (modelData[i].isDataRow) {
                    var td = tr.querySelectorAll('.e-rowcell:not(.e-hide)')[0];
                    if (td) {
                        td.classList.add('e-detailrowvisible');
                    }
                    this.rowElements.push(tr);
                }
                this.ariaService.setOptions(this.getTable(), { colcount: gObj.getColumns().length.toString() });
            }
            this.splitRows(idx);
            if (gObj.frozenRows) {
                hdrTbody = frzCols ? gObj.getHeaderContent().querySelector(idx === 0 ? '.e-frozenheader'
                    : '.e-movableheader').querySelector('tbody') : gObj.getHeaderTable().querySelector('tbody');
                hdrTbody.innerHTML = '';
                hdrTbody.appendChild(hdrfrag);
            }
            if (gObj.frozenRows && idx === 0 && cont.offsetHeight === Number(gObj.height)) {
                cont.style.height = (cont.offsetHeight - hdrTbody.offsetHeight) + 'px';
            }
            if (frzCols && idx === 0) {
                this.getPanel().firstChild.style.overflowY = 'hidden';
            }
            args.rows = this.rows.slice(0);
            args.isFrozen = this.parent.getFrozenColumns() !== 0 && !args.isFrozen;
            this.index = idx;
            util_1.getUpdateUsingRaf(function () {
                _this.parent.notify(events.beforeFragAppend, args);
                if (!_this.parent.enableVirtualization) {
                    ej2_base_3.remove(_this.tbody);
                    _this.tbody = ej2_base_3.createElement('tbody');
                }
                if (frzCols) {
                    _this.tbody.appendChild(frag);
                    if (_this.index === 0) {
                        _this.isLoaded = false;
                        fCont.querySelector('table').appendChild(_this.tbody);
                    }
                    else {
                        Iif (_this.tbody.childElementCount < 1) {
                            _this.tbody.appendChild(ej2_base_3.createElement('tr').appendChild(ej2_base_3.createElement('td')));
                        }
                        _this.isLoaded = true;
                        mCont.querySelector('table').appendChild(_this.tbody);
                        fCont.style.height = ((mCont.offsetHeight) - util_2.getScrollBarWidth()) + 'px';
                        mCont.style.overflowY = _this.parent.height !== 'auto' ? 'scroll' : 'auto';
                        fCont.style.borderRightWidth = '1px';
                    }
                }
                else {
                    _this.appendContent(_this.tbody, frag, args);
                }
                if (frzCols && idx === 0) {
                    _this.refreshContentRows(ej2_base_2.extend({}, args));
                }
                frag = null;
            }, this.rafCallback(ej2_base_2.extend({}, args)));
        };
        ContentRender.prototype.appendContent = function (tbody, frag, args) {
            tbody.appendChild(frag);
            this.getTable().appendChild(tbody);
        };
        ContentRender.prototype.getPanel = function () {
            return this.contentPanel;
        };
        ContentRender.prototype.setPanel = function (panel) {
            this.contentPanel = panel;
        };
        ContentRender.prototype.getTable = function () {
            return this.contentTable;
        };
        ContentRender.prototype.setTable = function (table) {
            this.contentTable = table;
        };
        ContentRender.prototype.getRows = function () {
            return this.parent.getFrozenColumns() ? this.freezeRows : this.rows;
        };
        ContentRender.prototype.getMovableRows = function () {
            return this.movableRows;
        };
        ContentRender.prototype.getRowElements = function () {
            return this.parent.getFrozenColumns() ? this.freezeRowElements : this.rowElements;
        };
        ContentRender.prototype.getMovableRowElements = function () {
            return this.rowElements;
        };
        ContentRender.prototype.setRowElements = function (elements) {
            this.rowElements = elements;
        };
        ContentRender.prototype.getColGroup = function () {
            return this.colgroup;
        };
        ContentRender.prototype.setColGroup = function (colGroup) {
            return this.colgroup = colGroup;
        };
        ContentRender.prototype.setVisible = function (columns) {
            var gObj = this.parent;
            var frzCols = gObj.getFrozenColumns();
            var rows = [];
            if (frzCols) {
                var fRows = this.freezeRows;
                var mRows = this.movableRows;
                var rowLen = fRows.length;
                var cellLen = void 0;
                for (var i = 0, row = void 0; i < rowLen; i++) {
                    cellLen = mRows[i].cells.length;
                    row = fRows[i].clone();
                    for (var j = 0; j < cellLen; j++) {
                        row.cells.push(mRows[i].cells[j]);
                    }
                    rows.push(row);
                }
            }
            else {
                rows = this.getRows();
            }
            var element;
            var testRow;
            rows.some(function (r) { if (r.isDataRow) {
                testRow = r;
            } return r.isDataRow; });
            var tasks = [];
            for (var c = 0, clen = columns.length; c < clen; c++) {
                var column = columns[c];
                var idx = this.parent.getNormalizedColumnIndex(column.uid);
                if (this.canSkip(column, testRow, idx)) {
                    continue;
                }
                var displayVal = column.visible === true ? '' : 'none';
                if (frzCols) {
                    if (idx < frzCols) {
                        ej2_base_3.setStyleAttribute(this.getColGroup().childNodes[idx], { 'display': displayVal });
                    }
                    else {
                        var mTable = gObj.getContent().querySelector('.e-movablecontent').querySelector('colgroup');
                        ej2_base_3.setStyleAttribute(mTable.childNodes[idx - frzCols], { 'display': displayVal });
                    }
                }
                else {
                    ej2_base_3.setStyleAttribute(this.getColGroup().childNodes[idx], { 'display': displayVal });
                }
            }
            this.refreshContentRows({ requestType: 'refresh' });
        };
        ContentRender.prototype.colGroupRefresh = function () {
            if (this.getColGroup()) {
                var colGroup = this.parent.element.querySelector('.e-gridheader').querySelector('colgroup').cloneNode(true);
                this.getTable().replaceChild(colGroup, this.getColGroup());
                this.setColGroup(colGroup);
            }
        };
        ContentRender.prototype.initializeContentDrop = function () {
            var gObj = this.parent;
            var drop = new ej2_base_1.Droppable(gObj.getContent(), {
                accept: '.e-dragclone',
                drop: this.drop
            });
        };
        ContentRender.prototype.canSkip = function (column, row, index) {
            return ej2_base_2.isNullOrUndefined(row) ||
                ej2_base_2.isNullOrUndefined(column.visible) ||
                row.cells[index].visible === column.visible;
        };
        ContentRender.prototype.getModelGenerator = function () {
            return this.generator = this.parent.allowGrouping ? new group_model_generator_1.GroupModelGenerator(this.parent) : new row_model_generator_1.RowModelGenerator(this.parent);
        };
        ContentRender.prototype.renderEmpty = function (tbody) {
            this.getTable().appendChild(tbody);
            if (this.parent.frozenRows) {
                this.parent.getHeaderContent().querySelector('tbody').innerHTML = '';
            }
        };
        ContentRender.prototype.setSelection = function (uid, set, clearAll) {
            if (this.parent.getFrozenColumns()) {
                this.getMovableRows().filter(function (row) { return clearAll || uid === row.uid; }).forEach(function (row) { return row.isSelected = set; });
            }
            this.getRows().filter(function (row) { return clearAll || uid === row.uid; })
                .forEach(function (row) {
                row.isSelected = set;
                row.cells.forEach(function (cell) { return cell.isSelected = set; });
            });
        };
        ContentRender.prototype.getRowByIndex = function (index) {
            return this.parent.getDataRows()[index];
        };
        ContentRender.prototype.getVirtualRowIndex = function (index) {
            return index;
        };
        ContentRender.prototype.getMovableRowByIndex = function (index) {
            return this.parent.getMovableDataRows()[index];
        };
        ContentRender.prototype.enableAfterRender = function (e) {
            if (e.module === 'group' && e.enable) {
                this.generator = this.getModelGenerator();
            }
        };
        return ContentRender;
    }());
    exports.ContentRender = ContentRender;
});
  |