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 | 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 258× 258× 258× 258× 258× 258× 258× 1× 235× 155× 80× 80× 80× 418× 80× 80× 1× 1232× 1232× 616× 512× 104× 198× 616× 616× 616× 616× 86× 1232× 1× 650× 650× 650× 650× 650× 650× 25000× 650× 650× 650× 616× 240× 616× 650× 650× 62× 62× 62× 246× 188× 62× 14× 62× 12× 62× 650× 650× 650× 800× 800× 16× 800× 800× 800× 650× 650× 1× 650× 650× 650× 650× 650× 618× 650× 650× 650× 650× 650× 650× 650× 1× 650× 650× 650× 18× 1× 512× 512× 512× 982× 982× 1234× 1234× 982× 512× 1× 1474× 1× 6× 6× 6× 66× 32× 32× 32× 32× 34× 34× 6× 1× 1× | /* istanbul ignore next */ var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); define(["require", "exports", "../models/row", "@syncfusion/ej2-base", "../base/enum", "../services/row-model-generator", "../services/summary-model-generator", "../../grid/base/util"], function (require, exports, row_1, ej2_base_1, enum_1, row_model_generator_1, summary_model_generator_1, util_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var GroupModelGenerator = (function (_super) { __extends(GroupModelGenerator, _super); function GroupModelGenerator(parent) { var _this = _super.call(this, parent) || this; _this.rows = []; _this.index = 0; _this.parent = parent; _this.summaryModelGen = new summary_model_generator_1.GroupSummaryModelGenerator(parent); _this.captionModelGen = new summary_model_generator_1.CaptionSummaryModelGenerator(parent); return _this; } GroupModelGenerator.prototype.generateRows = function (data, args) { if (this.parent.groupSettings.columns.length === 0) { return _super.prototype.generateRows.call(this, data, args); } this.rows = []; this.index = this.parent.enableVirtualization ? args.startIndex : 0; for (var i = 0, len = data.length; i < len; i++) { this.getGroupedRecords(0, data[i], data.level); } this.index = 0; return this.rows; }; GroupModelGenerator.prototype.getGroupedRecords = function (index, data, raw) { var level = raw; if (ej2_base_1.isNullOrUndefined(data.items)) { if (ej2_base_1.isNullOrUndefined(data.GroupGuid)) { this.rows = this.rows.concat(this.generateDataRows(data, index)); } else { for (var j = 0, len = data.length; j < len; j++) { this.getGroupedRecords(index, data[j], data.level); } } } else { this.rows = this.rows.concat(this.generateCaptionRow(data, index)); Eif (data.items && data.items.length) { this.getGroupedRecords(index + 1, data.items, data.items.level); } if (this.parent.aggregates.length) { (_a = this.rows).push.apply(_a, this.summaryModelGen.generateRows(data, { level: level })); } } var _a; }; GroupModelGenerator.prototype.getCaptionRowCells = function (field, indent, data) { var _this = this; var cells = []; var visibles = []; var column = this.parent.getColumnByField(field); var indexes = this.parent.getColumnIndexesInView(); if (this.parent.enableColumnVirtualization) { column = this.parent.columns.filter(function (c) { return c.field === field; })[0]; } var groupedLen = this.parent.groupSettings.columns.length; var gObj = this.parent; if (!this.parent.enableColumnVirtualization || indexes.indexOf(indent) !== -1) { for (var i = 0; i < indent; i++) { cells.push(this.generateIndentCell()); } cells.push(this.generateCell({}, null, enum_1.CellType.Expand)); } indent = this.parent.enableColumnVirtualization ? 1 : (this.parent.getVisibleColumns().length + groupedLen + (gObj.detailTemplate || gObj.childGrid ? 1 : 0) - indent + (this.parent.getVisibleColumns().length ? -1 : 0)); if (this.parent.aggregates.length && !this.captionModelGen.isEmpty()) { var captionCells = this.captionModelGen.generateRows(data)[0]; ej2_base_1.extend(data, captionCells.data); var cIndex_1 = 0; captionCells.cells.some(function (cell, index) { cIndex_1 = index; return cell.visible && cell.isDataCell; }); visibles = captionCells.cells.slice(cIndex_1).filter(function (cell) { return cell.visible; }); if (captionCells.visible && visibles[0].column.field === this.parent.getVisibleColumns()[0].field) { visibles = visibles.slice(1); } if (this.parent.getVisibleColumns().length === 1) { visibles = []; } indent = indent - visibles.length; } var cols = (!this.parent.enableColumnVirtualization ? [column] : this.parent.getColumns()); var wFlag = true; cols.forEach(function (col, index) { var tmpFlag = wFlag && indexes.indexOf(indent) !== -1; if (tmpFlag) { wFlag = false; } var cellType = !_this.parent.enableColumnVirtualization || tmpFlag ? enum_1.CellType.GroupCaption : enum_1.CellType.GroupCaptionEmpty; indent = _this.parent.enableColumnVirtualization && cellType === enum_1.CellType.GroupCaption ? indent + groupedLen : indent; cells.push(_this.generateCell(column, null, cellType, indent)); }); cells.push.apply(cells, visibles); return cells; }; GroupModelGenerator.prototype.generateCaptionRow = function (data, indent) { var options = {}; var tmp = []; var col = this.parent.getColumnByField(data.field); options.data = ej2_base_1.extend({}, data); if (col) { options.data.field = data.field; } options.isDataRow = false; options.uid = util_1.getUid('grid-row'); var row = new row_1.Row(options); row.indent = indent; this.getForeignKeyData(row); row.cells = this.getCaptionRowCells(data.field, indent, row.data); return row; }; GroupModelGenerator.prototype.getForeignKeyData = function (row) { var data = row.data; var col = this.parent.getColumnByField(data.field); if (col && col.isForeignColumn && col.isForeignColumn()) { ej2_base_1.setValue('foreignKey', col.valueAccessor(col.foreignKeyValue, util_1.getForeignData(col, {}, data.key)[0], col), row.data); } }; GroupModelGenerator.prototype.generateDataRows = function (data, indent) { var rows = []; var indexes = this.parent.getColumnIndexesInView(); for (var i = 0, len = data.length; i < len; i++) { rows[i] = this.generateRow(data[i], this.index, i ? undefined : 'e-firstchildrow', indent); for (var j = 0; j < indent; j++) { Iif (this.parent.enableColumnVirtualization && indexes.indexOf(indent) === -1) { continue; } rows[i].cells.unshift(this.generateIndentCell()); } this.index++; } return rows; }; GroupModelGenerator.prototype.generateIndentCell = function () { return this.generateCell({}, null, enum_1.CellType.Indent); }; GroupModelGenerator.prototype.refreshRows = function (input) { var _this = this; var indexes = this.parent.getColumnIndexesInView(); input.forEach(function (row) { if (row.isDataRow) { row.cells = _this.generateCells(row); for (var j = 0; j < row.indent; j++) { Eif (_this.parent.enableColumnVirtualization && indexes.indexOf(row.indent) === -1) { continue; } row.cells.unshift(_this.generateIndentCell()); } } else { var cRow = _this.generateCaptionRow(row.data, row.indent); row.cells = cRow.cells; } }); return input; }; return GroupModelGenerator; }(row_model_generator_1.RowModelGenerator)); exports.GroupModelGenerator = GroupModelGenerator; }); |