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 | 1×
1×
1×
1×
545×
1×
11746×
11746×
11746×
176862×
11746×
1×
177844×
177844×
143×
177844×
1×
177844×
177844×
177844×
177844×
177844×
177844×
177844×
177844×
177844×
177844×
177844×
177844×
177844×
177844×
177844×
177844×
1×
177892×
284×
1×
177924×
177924×
177924×
177924×
894596×
177924×
1×
897629×
897629×
895286×
897629×
1×
3×
3×
48×
48×
3×
1×
1×
| define(["require", "exports", "@syncfusion/ej2-base", "../models/row", "../base/enum", "../models/cell", "../base/util", "../../grid/base/util"], function (require, exports, ej2_base_1, row_1, enum_1, cell_1, util_1, util_2) {
"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.startIndex : 0;
for (var i = 0, len = Object.keys(data).length; i < len; i++, startIndex++) {
rows[i] = this.generateRow(data[i], startIndex);
}
return rows;
};
RowModelGenerator.prototype.ensureColumns = function () {
var cols = [];
if (this.parent.detailTemplate || this.parent.childGrid) {
cols.push(this.generateCell({}, null, enum_1.CellType.DetailExpand));
}
return cols;
};
RowModelGenerator.prototype.generateRow = function (data, index, cssClass, indent) {
var options = {};
options.foreignKeyData = {};
options.uid = util_1.getUid('grid-row');
options.data = data;
options.index = index;
options.indent = indent;
options.isDataRow = true;
options.isExpand = false;
options.cssClass = cssClass;
options.isAltRow = this.parent.enableAltRow ? index % 2 !== 0 : false;
options.isSelected = this.parent.getSelectedRowIndexes().indexOf(index) > -1;
this.refreshForeignKeyRow(options);
var cells = this.ensureColumns();
var row = new row_1.Row(options);
row.cells = cells.concat(this.generateCells(options));
return row;
};
RowModelGenerator.prototype.refreshForeignKeyRow = function (options) {
this.parent.getForeignKeyColumns().forEach(function (col) {
ej2_base_1.setValue(col.field, util_2.getForeignData(col, options.data), options.foreignKeyData);
});
};
RowModelGenerator.prototype.generateCells = function (options) {
var _this = this;
var dummies = this.parent.getColumns();
var tmp = [];
dummies.forEach(function (dummy, index) {
return tmp.push(_this.generateCell(dummy, options.uid, ej2_base_1.isNullOrUndefined(dummy.commands) ? undefined : enum_1.CellType.CommandColumn, null, index, 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.index = this.parent.getColumnIndexByField(column.field);
}
return new cell_1.Cell(opt);
};
RowModelGenerator.prototype.refreshRows = function (input) {
var _this = this;
input.forEach(function (row) {
_this.refreshForeignKeyRow(row);
row.cells = _this.generateCells(row);
});
return input;
};
return RowModelGenerator;
}());
exports.RowModelGenerator = RowModelGenerator;
});
|