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 | 1×
1×
1×
1×
118×
118×
118×
118×
118×
118×
118×
1×
11279×
1×
118×
118×
1×
116×
116×
1×
70×
70×
70×
70×
70×
70×
1×
1314×
5617×
84×
15×
15×
5533×
5533×
5617×
1244×
1244×
2×
2×
2×
2×
1×
1×
1×
1244×
1×
35×
1×
1×
1×
71×
1×
1×
1×
1×
116×
1×
1×
| define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-data", "@syncfusion/ej2-grids", "../utils"], function (require, exports, ej2_base_1, ej2_data_1, ej2_grids_1, utils_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Sort = (function () {
function Sort(grid) {
ej2_grids_1.Grid.Inject(ej2_grids_1.Sort);
this.parent = grid;
this.taskIds = [];
this.flatSortedData = [];
this.storedIndex = -1;
this.isSelfReference = !ej2_base_1.isNullOrUndefined(this.parent.parentIdMapping);
this.addEventListener();
}
Sort.prototype.getModuleName = function () {
return 'sort';
};
Sort.prototype.addEventListener = function () {
this.parent.on('updateModel', this.updateModel, this);
this.parent.on('createSort', this.createdSortedRecords, this);
};
Sort.prototype.removeEventListener = function () {
Eif (this.parent.isDestroyed) {
return;
}
this.parent.off('updateModel', this.updateModel);
this.parent.off('createSort', this.createdSortedRecords);
};
Sort.prototype.createdSortedRecords = function (sortParams) {
var data = sortParams.modifiedData;
var srtQry = sortParams.srtQry;
this.iterateSort(data, srtQry);
this.storedIndex = -1;
sortParams.modifiedData = this.flatSortedData;
this.flatSortedData = [];
};
Sort.prototype.iterateSort = function (data, srtQry) {
for (var d = 0; d < data.length; d++) {
if (this.parent.grid.filterSettings.columns.length > 0 || this.parent.grid.searchSettings.key !== '') {
if (!ej2_base_1.isNullOrUndefined(utils_1.getParentData(this.parent, data[parseInt(d.toString(), 10)].uniqueID, true))) {
this.storedIndex++;
this.flatSortedData[this.storedIndex] = data[parseInt(d.toString(), 10)];
}
}
else {
this.storedIndex++;
this.flatSortedData[this.storedIndex] = data[parseInt(d.toString(), 10)];
}
if (data[parseInt(d.toString(), 10)].hasChildRecords) {
var childSort = (new ej2_data_1.DataManager(data[parseInt(d.toString(), 10)].childRecords)
.executeLocal(srtQry));
if (this.parent.allowRowDragAndDrop && data[parseInt(d.toString(), 10)].childRecords.indexOf(this.parent.rowDragAndDropModule['draggedRecord']) !== -1 && this.parent.rowDragAndDropModule['dropPosition'] !== 'middleSegment') {
var dragdIndex = childSort.indexOf(this.parent.rowDragAndDropModule['draggedRecord']);
childSort.splice(dragdIndex, 1);
var dropdIndex = childSort.indexOf(this.parent.rowDragAndDropModule['droppedRecord']);
if (this.parent.rowDragAndDropModule['dropPosition'] === 'topSegment') {
childSort.splice(dropdIndex, 0, this.parent.rowDragAndDropModule['draggedRecord']);
}
else Eif (this.parent.rowDragAndDropModule['dropPosition'] === 'bottomSegment') {
childSort.splice(dropdIndex + 1, 0, this.parent.rowDragAndDropModule['draggedRecord']);
}
}
this.iterateSort(childSort, srtQry);
}
}
};
Sort.prototype.sortColumn = function (columnName, direction, isMultiSort) {
this.parent.grid.sortColumn(columnName, direction, isMultiSort);
};
Sort.prototype.removeSortColumn = function (field) {
this.parent.grid.removeSortColumn(field);
};
Sort.prototype.updateModel = function () {
this.parent.setProperties({ sortSettings: ej2_grids_1.getActualProperties(this.parent.grid.sortSettings) }, true);
};
Sort.prototype.clearSorting = function () {
this.parent.grid.clearSorting();
this.updateModel();
};
Sort.prototype.destroy = function () {
this.removeEventListener();
};
return Sort;
}());
exports.Sort = Sort;
});
|