| 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 | 1×
1×
1×
1×
3316×
1×
1923×
1923×
1923×
1923×
1×
1923×
8×
1923×
34695×
1923×
1×
8×
8×
8×
22×
22×
8×
1×
22×
22×
22×
22×
1×
44049×
44049×
674×
674×
674×
44049×
435×
44049×
1×
44049×
44049×
44049×
44049×
44049×
44049×
44049×
44049×
44049×
44049×
44049×
9334×
44049×
154×
14×
140×
2×
44049×
44049×
44049×
44049×
44049×
44049×
44049×
22×
44049×
44049×
44049×
1×
44710×
44710×
1005×
1×
44793×
44793×
44793×
222935×
44793×
1×
255839×
255837×
236225×
255837×
1×
21×
661×
661×
21×
1×
122×
1×
1×
| define(["require", "exports", "@syncfusion/ej2-base", "../models/row", "../base/enum", "../models/cell", "../base/util", "../../grid/base/util", "../base/constant"], function (require, exports, ej2_base_1, row_1, enum_1, cell_1, util_1, util_2, events) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var RowModelGenerator = (function () {
function RowModelGenerator(parent) {
this.parent = parent;
}
RowModelGenerator.prototype.generateRows = function (data, args) {
var rows = [];
var startIndex = this.parent.enableVirtualization && args ? args.startIndex : 0;
startIndex = this.parent.enableInfiniteScrolling && args ? this.getInfiniteIndex(args) : startIndex;
if (this.parent.enableImmutableMode && args && args.startIndex) {
startIndex = args.startIndex;
}
if (!this.parent.enableVirtualization && this.parent.pinnedTopRowModels.length && args && args.requestType !== 'infiniteScroll') {
startIndex = this.parent.pinnedTopRowModels.length;
}
for (var i = 0, len = Object.keys(data).length; i < len; i++, startIndex++) {
rows[parseInt(i.toString(), 10)] = this.generateRow(data[parseInt(i.toString(), 10)], startIndex);
}
return rows;
};
RowModelGenerator.prototype.generatePinnedTopRows = function (data) {
var rows = [];
var startIndex = 0;
for (var i = 0, len = Object.keys(data).length; i < len; i++, startIndex++) {
rows[parseInt(i.toString(), 10)] = this.generateRow(data[parseInt(i.toString(), 10)], startIndex);
for (var j = 0; j < this.parent.groupSettings.columns.length; j++) {
if (this.parent.enableColumnVirtualization) {
continue;
}
else {
rows[parseInt(i.toString(), 10)].cells.unshift(this.generateCell({}, null, enum_1.CellType.HeaderIndent));
}
}
}
return rows;
};
RowModelGenerator.prototype.ensurePinnedColumns = function () {
var cols = [];
Iif (this.parent.detailTemplate || this.parent.childGrid) {
cols.push(this.generateCell({}, null, enum_1.CellType.HeaderIndent));
}
Iif (this.parent.isRowDragable()) {
cols.push(this.generateCell({}, null, enum_1.CellType.HeaderIndent));
}
return cols;
};
RowModelGenerator.prototype.ensureColumns = function () {
var cols = [];
if (this.parent.detailTemplate || this.parent.childGrid) {
var args = {};
this.parent.notify(events.detailIndentCellInfo, args);
cols.push(this.generateCell(args, null, enum_1.CellType.DetailExpand));
}
if (this.parent.isRowDragable()) {
cols.push(this.generateCell({}, null, enum_1.CellType.RowDragIcon));
}
return cols;
};
RowModelGenerator.prototype.generateRow = function (data, index, cssClass, indent, pid, tIndex, parentUid, groupDataIndex) {
var options = {};
options.foreignKeyData = {};
options.uid = util_1.getUid('grid-row');
options.data = data;
options.index = index;
options.indent = indent;
options.tIndex = tIndex;
options.isDataRow = true;
options.parentGid = pid;
options.parentUid = parentUid;
if (this.parent.allowGrouping && this.parent.groupSettings.columns.length) {
options.groupDataIndex = groupDataIndex;
}
if (this.parent.isPrinting) {
if (this.parent.hierarchyPrintMode === 'All') {
options.isExpand = true;
}
else if (this.parent.hierarchyPrintMode === 'Expanded' && this.parent.expandedRows && this.parent.expandedRows[parseInt(index.toString(), 10)]) {
options.isExpand = this.parent.expandedRows[parseInt(index.toString(), 10)].isExpand;
}
}
options.cssClass = cssClass;
options.isAltRow = this.parent.enableAltRow ? index % 2 !== 0 : false;
options.isAltRow = this.parent.enableAltRow ? index % 2 !== 0 : false;
options.isSelected = this.parent.getSelectedRowIndexes().indexOf(index) > -1;
this.refreshForeignKeyRow(options);
var cells = this.ensureColumns();
if (this.parent.pinnedTopRecords.length && index < this.parent.pinnedTopRecords.length) {
cells = this.ensurePinnedColumns();
}
var row = new row_1.Row(options, this.parent);
row.cells = this.parent.getFrozenMode() === 'Right' ? this.generateCells(options).concat(cells)
: cells.concat(this.generateCells(options));
return row;
};
RowModelGenerator.prototype.refreshForeignKeyRow = function (options) {
var foreignKeyColumns = this.parent.getForeignKeyColumns();
for (var i = 0; i < foreignKeyColumns.length; i++) {
ej2_base_1.setValue(foreignKeyColumns[parseInt(i.toString(), 10)].field, util_2.getForeignData(foreignKeyColumns[parseInt(i.toString(), 10)], options.data), options.foreignKeyData);
}
};
RowModelGenerator.prototype.generateCells = function (options) {
var dummies = this.parent.getColumns();
var tmp = [];
for (var i = 0; i < dummies.length; i++) {
tmp.push(this.generateCell(dummies[parseInt(i.toString(), 10)], options.uid, ej2_base_1.isNullOrUndefined(dummies[parseInt(i.toString(), 10)].commands) ? undefined : enum_1.CellType.CommandColumn, null, i, options.foreignKeyData));
}
return tmp;
};
RowModelGenerator.prototype.generateCell = function (column, rowId, cellType, colSpan, oIndex, foreignKeyData) {
var opt = {
'visible': column.visible,
'isDataCell': !ej2_base_1.isNullOrUndefined(column.field || column.template),
'isTemplate': !ej2_base_1.isNullOrUndefined(column.template),
'rowID': rowId,
'column': column,
'cellType': !ej2_base_1.isNullOrUndefined(cellType) ? cellType : enum_1.CellType.Data,
'colSpan': colSpan,
'commands': column.commands,
'isForeignKey': column.isForeignColumn && column.isForeignColumn(),
'foreignKeyData': column.isForeignColumn && column.isForeignColumn() && ej2_base_1.getValue(column.field, foreignKeyData)
};
if (opt.isDataCell || opt.column.type === 'checkbox' || opt.commands) {
opt.index = oIndex;
}
return new cell_1.Cell(opt);
};
RowModelGenerator.prototype.refreshRows = function (input) {
for (var i = 0; i < input.length; i++) {
this.refreshForeignKeyRow(input[parseInt(i.toString(), 10)]);
input[parseInt(i.toString(), 10)].cells = this.generateCells(input[parseInt(i.toString(), 10)]);
}
return input;
};
RowModelGenerator.prototype.getInfiniteIndex = function (args) {
return args.requestType === 'infiniteScroll' || args.requestType === 'delete' || args.action === 'add'
? (ej2_base_1.isNullOrUndefined(args.startIndex) ? args['index'] : args.startIndex) : 0;
};
return RowModelGenerator;
}());
exports.RowModelGenerator = RowModelGenerator;
});
|