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 | 1×
1×
1×
1×
1×
32×
32×
32×
32×
31×
31×
1×
2×
2×
2×
2×
1×
13×
13×
13×
13×
13×
13×
13×
1×
13×
13×
13×
13×
1×
12×
12×
12×
1×
3×
1×
1×
2×
2×
1×
13×
13×
1×
13×
13×
13×
13×
13×
13×
13×
13×
13×
13×
1×
15×
1×
14×
1×
1×
1×
14×
1×
1×
18×
18×
18×
13×
18×
13×
13×
13×
1×
1×
| define(["require", "exports", "@syncfusion/ej2-inputs", "@syncfusion/ej2-base", "../base/constant", "@syncfusion/ej2-dropdowns", "@syncfusion/ej2-data", "../base/string-literals", "../base/util"], function (require, exports, ej2_inputs_1, ej2_base_1, events, ej2_dropdowns_1, ej2_data_1, literals, util_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
ej2_dropdowns_1.MultiSelect.Inject(ej2_dropdowns_1.CheckBoxSelection);
var NumberFilterUI = (function () {
function NumberFilterUI(parent, serviceLocator, filterSettings) {
this.filterSettings = filterSettings;
this.parent = parent;
this.serviceLocator = serviceLocator;
if (this.parent) {
this.parent.on(events.filterMenuClose, this.destroy, this);
this.parent.on(events.destroy, this.destroy, this);
}
}
NumberFilterUI.prototype.keyEventHandler = function (args) {
Eif (args.keyCode === 13 || args.keyCode === 9) {
var evt = document.createEvent('HTMLEvents');
evt.initEvent('change', false, true);
this.dispatchEvent(evt);
}
};
NumberFilterUI.prototype.create = function (args) {
this.numericInstance = this.parent.createElement('input', { className: 'e-flmenu-input', id: 'numberui-' + args.column.uid });
this.multiSelectCheckBoxInstance = this.parent.createElement('input', { className: 'multiselect-input', id: 'multiselectnumberui-' + args.column.uid });
args.target.appendChild(this.numericInstance);
args.target.appendChild(this.multiSelectCheckBoxInstance);
this.createNumericTextBox(args);
this.createMultiSelectDropDown(args);
util_1.toggleFilterUI(args.getOptrInstance.dropOptr.value, args.column.uid, args.column, args.column.type, args.dialogObj, args.getOptrInstance.dropOptr['previousValue']);
};
NumberFilterUI.prototype.write = function (args) {
var operatorDropdown = this.parent.filterModule.filterModule.getOperatorDropdown();
var numericObject = this.getNumericInstance(args.column.uid);
var multiSelectObject = this.getMultiSelectInstance(args.column.uid);
if (operatorDropdown.value === 'in' || operatorDropdown.value === 'notin') {
multiSelectObject.value = Array.isArray(args.filteredValue) ? args.filteredValue : [];
}
else {
numericObject.element.addEventListener('keydown', this.keyEventHandler);
Eif (!Array.isArray(args.filteredValue)) {
numericObject.value = args.filteredValue;
}
}
};
NumberFilterUI.prototype.read = function (element, column, filterOptr, filterObj) {
if (filterOptr === 'in' || filterOptr === 'notin') {
var filterValue = this.getMultiSelectInstance(column.uid).value;
filterObj.filterByColumn(column.field, filterOptr, filterValue, 'and', true);
}
else {
var filterValue = this.getNumericInstance(column.uid).value;
filterObj.filterByColumn(column.field, filterOptr, filterValue, 'and', true);
}
};
NumberFilterUI.prototype.createNumericTextBox = function (args) {
this.numericTxtObj = new ej2_inputs_1.NumericTextBox(ej2_base_1.extend({
format: typeof (args.column.format) === 'string' || ej2_base_1.isUndefined(args.column.format) ? args.column.format :
args.column.format.format,
locale: this.parent.locale,
cssClass: this.parent.cssClass ? 'e-popup-flmenu' + ' ' + this.parent.cssClass : 'e-popup-flmenu',
placeholder: args.localizeText.getConstant('EnterValue'),
enableRtl: this.parent.enableRtl
}, args.column.filter.params));
this.numericTxtObj.appendTo(this.numericInstance);
};
NumberFilterUI.prototype.createMultiSelectDropDown = function (args) {
var isForeignColumn = args.column.isForeignColumn();
var dataSource = isForeignColumn ? args.column.dataSource : this.parent.dataSource;
var fields = isForeignColumn ? args.column.foreignKeyValue : args.column.field;
this.multiSelectObj = new ej2_dropdowns_1.MultiSelect(ej2_base_1.extend({
dataSource: dataSource instanceof ej2_data_1.DataManager ? dataSource : new ej2_data_1.DataManager(dataSource),
fields: { text: fields, value: fields },
mode: 'CheckBox',
showDropDownIcon: true,
popupHeight: '300px',
showSelectAll: true,
query: new ej2_data_1.Query().select(fields),
cssClass: this.parent.cssClass ? 'e-multiselect-flmenu' + ' ' + this.parent.cssClass : 'e-multiselect-flmenu',
locale: this.parent.locale,
enableRtl: this.parent.enableRtl
}, args.column.filter.params));
this.dialogObj = args.dialogObj;
this.dropdownOpen = this.openPopup.bind(this);
this.dropdownComplete = this.actionComplete(fields);
this.multiSelectObj.addEventListener(literals['open'], this.dropdownOpen);
this.multiSelectObj.addEventListener(events.actionComplete, this.dropdownComplete);
this.multiSelectObj.appendTo(this.multiSelectCheckBoxInstance);
};
NumberFilterUI.prototype.getNumericInstance = function (uid) {
return document.querySelector("#numberui-" + uid).ej2_instances[0];
};
NumberFilterUI.prototype.getMultiSelectInstance = function (uid) {
return document.querySelector("#multiselectnumberui-" + uid).ej2_instances[0];
};
NumberFilterUI.prototype.openPopup = function (args) {
util_1.getZIndexCalcualtion(args, this.dialogObj);
};
NumberFilterUI.prototype.actionComplete = function (fields) {
return function (e) {
e.result = ej2_data_1.DataUtil.distinct(e.result, fields, true);
};
};
NumberFilterUI.prototype.destroy = function () {
this.parent.off(events.filterMenuClose, this.destroy);
this.parent.off(events.destroy, this.destroy);
if (this.numericTxtObj && !this.numericTxtObj.isDestroyed) {
this.numericTxtObj.destroy();
}
if (this.multiSelectObj && !this.multiSelectObj.isDestroyed) {
this.multiSelectObj.removeEventListener(literals['open'], this.dropdownOpen);
this.multiSelectObj.removeEventListener(events.actionComplete, this.dropdownComplete);
this.multiSelectObj.destroy();
}
};
return NumberFilterUI;
}());
exports.NumberFilterUI = NumberFilterUI;
});
|