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 | 1×
1×
1×
1×
171×
171×
171×
171×
71×
1×
43×
43×
43×
1×
136×
136×
1×
126×
126×
126×
126×
124×
492×
492×
492×
492×
119×
63×
56×
2×
492×
492×
492×
124×
126×
1×
492×
492×
35×
35×
52×
492×
2309×
2309×
492×
1×
44×
44×
44×
44×
44×
1×
2×
2×
1×
1×
2×
44×
1×
120×
10×
110×
120×
120×
120×
128×
128×
120×
120×
120×
1×
8×
8×
1×
136×
136×
557×
557×
557×
541×
525×
16×
16×
16×
16×
136×
1×
120×
120×
525×
525×
120×
1×
557×
525×
32×
16×
16×
16×
16×
16×
32×
16×
32×
557×
1×
2893×
2893×
2885×
2893×
1×
244×
244×
244×
244×
620×
114×
7×
7×
244×
1×
96×
32×
64×
64×
60×
96×
1×
100×
805×
100×
48×
1×
52×
52×
1×
52×
52×
52×
52×
52×
52×
52×
52×
52×
52×
52×
1×
120×
120×
525×
525×
120×
1×
123×
1×
1×
1×
1×
51×
51×
1×
70×
70×
1×
1117×
1117×
53×
3×
53×
1064×
1×
1063×
70×
8×
70×
70×
70×
70×
1×
69×
69×
70×
993×
985×
8×
1×
1×
| define(["require", "exports", "./../models/row", "../base/enum", "@syncfusion/ej2-base", "../models/cell", "./../services/value-formatter", "@syncfusion/ej2-data", "../base/util", "../base/grid"], function (require, exports, row_1, enum_1, ej2_base_1, cell_1, value_formatter_1, ej2_data_1, util_1, grid_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var ExportHelper = (function () {
function ExportHelper(parent, foreignKeyData) {
this.hideColumnInclude = false;
this.foreignKeyData = {};
this.parent = parent;
if (!parent.parentDetails && foreignKeyData) {
this.foreignKeyData = foreignKeyData;
}
}
ExportHelper.getQuery = function (parent, data) {
var query = data.generateQuery(true).requiresCount();
Iif (data.isRemote()) {
if (parent.groupSettings.enableLazyLoading && parent.groupSettings.columns.length) {
query.lazyLoad = [];
}
else {
query.take(parent.pageSettings.totalRecordsCount);
}
}
return query;
};
ExportHelper.prototype.getFData = function (value, column) {
var foreignKeyData = util_1.getForeignData(column, {}, value, this.foreignKeyData[column.field])[0];
return foreignKeyData;
};
ExportHelper.prototype.getGridRowModel = function (columns, dataSource, gObj, startIndex) {
Iif (startIndex === void 0) { startIndex = 0; }
var rows = [];
var length = dataSource.length;
if (length) {
for (var i = 0; i < length; i++, startIndex++) {
var options = { isExpand: false };
options.data = dataSource[parseInt(i.toString(), 10)];
options.index = startIndex;
if (gObj.childGrid || gObj.detailTemplate) {
if (gObj.hierarchyPrintMode === 'All') {
options.isExpand = true;
}
else if (gObj.hierarchyPrintMode === 'Expanded' &&
this.parent.expandedRows && this.parent.expandedRows[parseInt(startIndex.toString(), 10)]) {
options.isExpand = gObj.expandedRows[parseInt(startIndex.toString(), 10)].isExpand;
}
}
var row = new row_1.Row(options);
row.cells = this.generateCells(columns, gObj);
rows.push(row);
}
this.processColumns(rows);
}
return rows;
};
ExportHelper.prototype.generateCells = function (columns, gObj) {
var cells = [];
if (gObj.childGridLevel) {
var len = gObj.childGridLevel;
for (var i = 0; len > i; i++) {
cells.push(this.generateCell({}, enum_1.CellType.Indent));
}
}
for (var _i = 0, columns_1 = columns; _i < columns_1.length; _i++) {
var col = columns_1[_i];
cells.push(this.generateCell(col, enum_1.CellType.Data));
}
return cells;
};
ExportHelper.prototype.getColumnData = function (gridObj) {
var _this = this;
var columnPromise = [];
var promise;
var fColumns = gridObj.getForeignKeyColumns();
if (fColumns.length) {
for (var i = 0; i < fColumns.length; i++) {
var colData = ('result' in fColumns[parseInt(i.toString(), 10)].dataSource) ?
new ej2_data_1.DataManager(fColumns[parseInt(i.toString(), 10)].dataSource.result) :
fColumns[parseInt(i.toString(), 10)].dataSource;
columnPromise.push(colData.executeQuery(new ej2_data_1.Query()));
}
promise = Promise.all(columnPromise).then(function (e) {
for (var j = 0; j < fColumns.length; j++) {
_this.foreignKeyData[fColumns[parseInt(j.toString(), 10)].field] = e[parseInt(j.toString(), 10)].result;
}
});
}
return promise;
};
ExportHelper.prototype.getHeaders = function (columns, isHideColumnInclude) {
if (isHideColumnInclude) {
this.hideColumnInclude = true;
}
else {
this.hideColumnInclude = false;
}
this.colDepth = util_1.measureColumnDepth(columns);
var rows = [];
for (var i = 0; i < this.colDepth; i++) {
rows[parseInt(i.toString(), 10)] = new row_1.Row({});
rows[parseInt(i.toString(), 10)].cells = [];
}
rows = this.processColumns(rows);
rows = this.processHeaderCells(rows, columns);
return { rows: rows, columns: this.generateActualColumns(columns) };
};
ExportHelper.prototype.getConvertedWidth = function (input) {
var value = parseFloat(input);
return (input.indexOf('%') !== -1) ? (this.parent.element.getBoundingClientRect().width * value / 100) : value;
};
ExportHelper.prototype.generateActualColumns = function (columns, actualColumns) {
if (actualColumns === void 0) { actualColumns = []; }
for (var _i = 0, columns_2 = columns; _i < columns_2.length; _i++) {
var column = columns_2[_i];
Iif (column.commands) {
continue;
}
if (!column.columns) {
if (column.visible || this.hideColumnInclude) {
actualColumns.push(column);
}
}
else {
Eif (column.visible || this.hideColumnInclude) {
var colSpan = this.getCellCount(column, 0);
Eif (colSpan !== 0) {
this.generateActualColumns(column.columns, actualColumns);
}
}
}
}
return actualColumns;
};
ExportHelper.prototype.processHeaderCells = function (rows, cols) {
var columns = cols;
for (var i = 0; i < columns.length; i++) {
Eif (!columns[parseInt(i.toString(), 10)].commands) {
rows = this.appendGridCells(columns[parseInt(i.toString(), 10)], rows, 0);
}
}
return rows;
};
ExportHelper.prototype.appendGridCells = function (cols, gridRows, index) {
if (!cols.columns && (cols.visible !== false || this.hideColumnInclude) && !cols.commands) {
gridRows[parseInt(index.toString(), 10)].cells.push(this.generateCell(cols, enum_1.CellType.Header, this.colDepth - index, index));
}
else if (cols.columns) {
var colSpan = this.getCellCount(cols, 0);
Eif (colSpan) {
gridRows[parseInt(index.toString(), 10)].cells.push(new cell_1.Cell({
cellType: enum_1.CellType.StackedHeader, column: cols, colSpan: colSpan
}));
}
var isIgnoreFirstCell = void 0;
for (var i = 0, len = cols.columns.length; i < len; i++) {
if (cols.columns[parseInt(i.toString(), 10)].visible && !isIgnoreFirstCell) {
isIgnoreFirstCell = true;
}
gridRows = this.appendGridCells(cols.columns[parseInt(i.toString(), 10)], gridRows, index + 1);
}
}
return gridRows;
};
ExportHelper.prototype.generateCell = function (gridColumn, cellType, rowSpan, rowIndex) {
var option = {
'visible': gridColumn.visible,
'isDataCell': cellType === enum_1.CellType.Data,
'column': gridColumn,
'cellType': cellType,
'rowSpan': rowSpan,
'index': rowIndex
};
if (!option.rowSpan || option.rowSpan < 2) {
delete option.rowSpan;
}
return new cell_1.Cell(option);
};
ExportHelper.prototype.processColumns = function (rows) {
var gridObj = this.parent;
var columnIndexes = [];
Iif (gridObj.enableColumnVirtualization) {
columnIndexes = gridObj.getColumnIndexesInView();
}
for (var i = 0, len = rows.length; i < len; i++) {
if (gridObj.allowGrouping) {
for (var j = 0, len_1 = gridObj.groupSettings.columns.length - 1; j < len_1; j++) {
Iif (gridObj.enableColumnVirtualization && columnIndexes.indexOf(j) === -1) {
continue;
}
rows[parseInt(i.toString(), 10)].cells.splice(0, 0, this.generateCell({}, enum_1.CellType.HeaderIndent));
}
}
}
return rows;
};
ExportHelper.prototype.getCellCount = function (column, count) {
if (column.columns) {
for (var i = 0; i < column.columns.length; i++) {
count = this.getCellCount(column.columns[parseInt(i.toString(), 10)], count);
}
}
else {
if (column.visible || this.hideColumnInclude) {
count++;
}
}
return count;
};
ExportHelper.prototype.checkAndExport = function (gridPool, globalResolve) {
var bool = Object.keys(gridPool).some(function (key) {
return !gridPool["" + key];
});
if (!bool) {
globalResolve();
}
};
ExportHelper.prototype.failureHandler = function (gridPool, childGridObj, resolve) {
var _this = this;
return function () {
gridPool[childGridObj.id] = true;
_this.checkAndExport(gridPool, resolve);
};
};
ExportHelper.prototype.createChildGrid = function (gObj, row, exportType, gridPool) {
var childGridObj = new grid_1.Grid(this.parent.detailRowModule.getGridModel(gObj, row, exportType));
gObj.isPrinting = false;
var parent = 'parentDetails';
childGridObj["" + parent] = {
parentID: gObj.element.id,
parentPrimaryKeys: gObj.getPrimaryKeyFieldNames(),
parentKeyField: gObj.childGrid.queryString,
parentKeyFieldValue: ej2_base_1.getValue(childGridObj.queryString, row.data),
parentRowData: row.data
};
var exportId = util_1.getUid('child-grid');
var element = ej2_base_1.createElement('div', {
id: exportId, styles: 'display: none'
});
document.body.appendChild(element);
childGridObj.id = exportId;
gridPool["" + exportId] = false;
childGridObj.isExportGrid = true;
return { childGrid: childGridObj, element: element };
};
ExportHelper.prototype.getGridExportColumns = function (columns) {
var actualGridColumns = [];
for (var i = 0, gridColumns = columns; i < gridColumns.length; i++) {
Eif (gridColumns[parseInt(i.toString(), 10)].type !== 'checkbox') {
actualGridColumns.push(gridColumns[parseInt(i.toString(), 10)]);
}
}
return actualGridColumns;
};
ExportHelper.prototype.getForeignKeyData = function () {
return this.foreignKeyData;
};
return ExportHelper;
}());
exports.ExportHelper = ExportHelper;
var ExportValueFormatter = (function () {
function ExportValueFormatter(culture) {
this.valueFormatter = new value_formatter_1.ValueFormatter(culture);
this.internationalization = new ej2_base_1.Internationalization(culture);
}
ExportValueFormatter.prototype.returnFormattedValue = function (args, customFormat) {
Eif (!ej2_base_1.isNullOrUndefined(args.value) && args.value) {
return this.valueFormatter.getFormatFunction(customFormat)(args.value);
}
else {
return '';
}
};
ExportValueFormatter.prototype.formatCellValue = function (args) {
Iif (args.isForeignKey) {
args.value = ej2_base_1.getValue(args.column.foreignKeyValue, util_1.getForeignData(args.column, {}, args.value)[0]);
}
if (args.column.type === 'number' && args.column.format !== undefined && args.column.format !== '') {
if (typeof args.column.format === 'string') {
args.column.format = { format: args.column.format };
}
return args.value || args.value === 0 ?
this.internationalization.getNumberFormat(args.column.format)(args.value) : '';
}
else if (args.column.type === 'boolean' && args.value !== '') {
return args.value ? 'true' : 'false';
}
else if ((args.column.type === 'date' || args.column.type === 'dateonly' || args.column.type === 'datetime' || args.column.type === 'time') && args.column.format !== undefined) {
if (typeof args.value === 'string') {
args.value = new Date(args.value);
}
Eif (typeof args.column.format === 'string') {
var format = void 0;
var cFormat = args.column.format;
if (args.column.type === 'date' || args.column.type === 'dateonly') {
format = { type: 'date', skeleton: cFormat };
}
else Iif (args.column.type === 'time') {
format = { type: 'time', skeleton: cFormat };
}
else {
format = { type: 'dateTime', skeleton: cFormat };
}
return this.returnFormattedValue(args, format);
}
else {
if (args.column.format instanceof Object && args.column.format.type === undefined) {
return (args.value.toString());
}
else {
var customFormat = void 0;
if (args.column.type === 'date' || args.column.type === 'dateonly') {
customFormat = {
type: args.column.format.type,
format: args.column.format.format, skeleton: args.column.format.skeleton
};
}
else if (args.column.type === 'time') {
customFormat = { type: 'time', format: args.column.format.format, skeleton: args.column.format.skeleton };
}
else {
customFormat = { type: 'dateTime', format: args.column.format.format, skeleton: args.column.format.skeleton };
}
return this.returnFormattedValue(args, customFormat);
}
}
}
else {
if ((!ej2_base_1.isNullOrUndefined(args.column.type) && !ej2_base_1.isNullOrUndefined(args.value)) || !ej2_base_1.isNullOrUndefined(args.value)) {
return (args.value).toString();
}
else {
return '';
}
}
};
return ExportValueFormatter;
}());
exports.ExportValueFormatter = ExportValueFormatter;
});
|