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 | 1×
1×
1×
1×
883×
883×
1×
882×
882×
1×
883×
1×
882×
13×
1×
98×
98×
98×
98×
98×
98×
98×
97×
97×
97×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
98×
98×
97×
97×
97×
97×
97×
97×
97×
97×
97×
97×
97×
97×
97×
11×
599×
599×
11×
11×
11×
86×
881×
881×
15×
866×
866×
866×
866×
97×
13×
1×
126650×
1×
1×
| define(["require", "exports", "../base/index", "@syncfusion/ej2-data", "../common/index", "../index", "../common/event"], function (require, exports, index_1, ej2_data_1, index_2, index_3, event_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var WorkbookFilter = (function () {
function WorkbookFilter(parent) {
this.parent = parent;
this.addEventListener();
}
WorkbookFilter.prototype.destroy = function () {
this.removeEventListener();
this.parent = null;
};
WorkbookFilter.prototype.addEventListener = function () {
this.parent.on(event_1.initiateFilter, this.initiateFilterHandler, this);
};
WorkbookFilter.prototype.removeEventListener = function () {
if (!this.parent.isDestroyed) {
this.parent.off(event_1.initiateFilter, this.initiateFilterHandler);
}
};
WorkbookFilter.prototype.initiateFilterHandler = function (eventArgs) {
var _this = this;
var args = eventArgs.args;
var deferred = new ej2_data_1.Deferred();
var sheet = index_1.getSheet(this.parent, index_2.getSheetIndexFromAddress(this.parent, args.range));
var filterOptions = args.filterOptions || {};
eventArgs.promise = deferred.promise;
if (filterOptions.datasource) {
this.setFilter(filterOptions.datasource, filterOptions.predicates, args.range, eventArgs.refresh, filterOptions.equalOrPredicates);
var filterEventArgs = { range: args.range, filterOptions: filterOptions };
deferred.resolve(filterEventArgs);
}
else {
var range = index_2.getSwapRange(index_2.getIndexesFromAddress(args.range));
Iif (range[0] > sheet.usedRange.rowIndex || range[1] > sheet.usedRange.colIndex) {
deferred.reject('Select a cell or range inside the used range and try again.');
return;
}
Eif (range[0] === range[2] && (range[2] - range[0]) === 0) {
range[0] = 0;
range[1] = 0;
range[3] = sheet.usedRange.colIndex;
}
range[2] = sheet.usedRange.rowIndex;
range[0] = range[0] + 1;
var address_1 = index_2.getRangeAddress(range);
index_1.getData(this.parent, sheet.name + "!" + address_1, true, true, null, null, null, null, false).then(function (jsonData) {
var dataManager = new ej2_data_1.DataManager(jsonData);
_this.setFilter(dataManager, filterOptions.predicates, args.range, eventArgs.refresh);
var filterEventArgs = { range: address_1, filterOptions: filterOptions };
deferred.resolve(filterEventArgs);
});
}
};
WorkbookFilter.prototype.setFilter = function (dataManager, predicates, range, refresh, equalOrPredicates) {
var _this = this;
if (dataManager && predicates) {
var jsonData = dataManager.dataSource.json;
var result_1 = index_2.applyPredicates(dataManager, predicates, equalOrPredicates);
var rowKey_1 = '__rowIndex';
var sheet_1;
var sheetIdx_1;
Eif (range.indexOf('!') > -1) {
sheetIdx_1 = index_3.getSheetIndex(this.parent, range.substring(0, range.lastIndexOf('!')));
sheet_1 = index_1.getSheet(this.parent, sheetIdx_1);
}
else {
sheet_1 = this.parent.getActiveSheet();
sheetIdx_1 = index_3.getSheetIndex(this.parent, sheet_1.name);
}
Eif (this.parent.getModuleName() === 'spreadsheet') {
var parent_1 = this.parent;
var hide_1;
var refreshUI_1;
if ((parent_1.scrollSettings.enableVirtualization && ((sheet_1.rows || jsonData).length > (parent_1.viewport.rowCount +
(parent_1.getThreshold('row') * 2))) || sheet_1.frozenRows || sheet_1.frozenColumns) || refresh) {
jsonData.forEach(function (data) {
hide_1 = result_1.indexOf(data) < 0;
index_3.setRow(sheet_1, Number(data["" + rowKey_1]) - 1, { hidden: hide_1, isFiltered: hide_1 });
});
refreshUI_1 = sheetIdx_1 === parent_1.activeSheetIndex;
var paneIndexes = index_2.getRangeIndexes(sheet_1.paneTopLeftCell);
this.parent.updateTopLeftCell(index_2.skipHiddenIdx(sheet_1, paneIndexes[0], true) - this.parent.frozenRowCount(sheet_1), null, 'col');
}
else {
jsonData.forEach(function (data) {
hide_1 = result_1.indexOf(data) < 0;
if (refreshUI_1) {
index_3.setRow(sheet_1, Number(data["" + rowKey_1]) - 1, { hidden: hide_1, isFiltered: hide_1 });
}
else {
var eventArgs = { startIndex: Number(data["" + rowKey_1]) - 1, hide: hide_1,
isFiltering: true, sheetIndex: sheetIdx_1 };
eventArgs.endIndex = eventArgs.startIndex;
_this.parent.notify(event_1.hideShow, eventArgs);
refreshUI_1 = eventArgs.refreshUI;
}
});
}
if (refreshUI_1) {
parent_1.renderModule.refreshSheet(false, false, document.activeElement.id !== this.parent.element.id + "_SearchBox");
}
}
else {
var hide_2;
jsonData.forEach(function (data) {
hide_2 = result_1.indexOf(data) < 0;
index_3.setRow(sheet_1, Number(data["" + rowKey_1]) - 1, { hidden: hide_2, isFiltered: hide_2 });
});
}
}
};
WorkbookFilter.prototype.getModuleName = function () {
return 'workbookFilter';
};
return WorkbookFilter;
}());
exports.WorkbookFilter = WorkbookFilter;
});
|