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 | 1×
1×
1×
1×
16×
16×
16×
16×
15×
15×
1×
5×
5×
5×
5×
5×
5×
5×
5×
5×
5×
5×
5×
5×
1×
1×
1×
1×
1×
1×
1×
1×
1×
2×
2×
1×
5×
1×
5×
5×
2×
1×
1×
1×
1×
1×
1×
1×
5×
2×
1×
13×
8×
5×
5×
5×
5×
5×
1×
1×
| define(["require", "exports", "../base/util", "@syncfusion/ej2-data", "@syncfusion/ej2-dropdowns", "@syncfusion/ej2-base", "../base/constant", "../base/string-literals"], function (require, exports, util_1, ej2_data_1, ej2_dropdowns_1, ej2_base_1, events, literals) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var BooleanFilterUI = (function () {
function BooleanFilterUI(parent, serviceLocator, filterSettings) {
this.parent = parent;
this.serviceLocator = serviceLocator;
this.filterSettings = filterSettings;
if (this.parent) {
this.parent.on(events.filterMenuClose, this.destroy, this);
this.parent.on(events.destroy, this.destroy, this);
}
}
BooleanFilterUI.prototype.create = function (args) {
var _this = this;
var isForeignColumn = args.column.isForeignColumn();
var dataSource = isForeignColumn ? args.column.dataSource : this.parent.dataSource;
var fields = isForeignColumn ? args.column.foreignKeyValue : args.column.field;
this.elem = this.parent.createElement('input', { className: 'e-flmenu-input', id: 'bool-ui-' + args.column.uid });
args.target.appendChild(this.elem);
this.dialogObj = args.dialogObj;
this.dropInstance = new ej2_dropdowns_1.DropDownList(ej2_base_1.extend({
dataSource: dataSource instanceof ej2_data_1.DataManager ?
dataSource : new ej2_data_1.DataManager(dataSource),
query: new ej2_data_1.Query().select(fields),
fields: { text: fields, value: fields },
placeholder: args.localizeText.getConstant('SelectValue'),
cssClass: this.parent.cssClass ? 'e-popup-flmenu' + ' ' + this.parent.cssClass : 'e-popup-flmenu',
locale: this.parent.locale,
enableRtl: this.parent.enableRtl
}, args.column.filter.params));
this.ddOpen = this.openPopup.bind(this);
this.ddComplete = this.actionComplete(fields);
this.dropInstance.addEventListener(literals['open'], this.ddOpen);
this.dropInstance.addEventListener(events.actionComplete, this.ddComplete);
if (dataSource && 'result' in dataSource) {
var query = this.parent.getQuery ? this.parent.getQuery().clone() : new ej2_data_1.Query();
var defObj = util_1.eventPromise({ requestType: 'booleanfilterrequest' }, query);
this.parent.trigger(events.dataStateChange, defObj.state);
var def = defObj.deffered;
def.promise.then(function (e) {
_this.dropInstance.dataSource = new ej2_data_1.DataManager(e);
_this.dropInstance.dataBind();
var columns = _this.parent.filterSettings.columns;
for (var _i = 0, columns_1 = columns; _i < columns_1.length; _i++) {
var column = columns_1[_i];
if (args.column.uid === column.uid) {
_this.dropInstance.value = column.value;
}
}
});
}
this.dropInstance.appendTo(this.elem);
};
BooleanFilterUI.prototype.write = function (args) {
var drpuiObj = document.querySelector('#bool-ui-' + args.column.uid).ej2_instances[0];
if (!ej2_base_1.isNullOrUndefined(args.filteredValue)) {
drpuiObj.value = args.filteredValue;
}
};
BooleanFilterUI.prototype.read = function (element, column, filterOptr, filterObj) {
var drpuiObj = document.querySelector('#bool-ui-' + column.uid).ej2_instances[0];
var filterValue = (drpuiObj.value);
filterObj.filterByColumn(column.field, filterOptr, filterValue, 'and', false);
};
BooleanFilterUI.prototype.openPopup = function (args) {
util_1.getZIndexCalcualtion(args, this.dialogObj);
};
BooleanFilterUI.prototype.actionComplete = function (fields) {
return function (e) {
e.result = ej2_data_1.DataUtil.distinct(e.result, fields, true);
};
};
BooleanFilterUI.prototype.destroy = function () {
if (!this.dropInstance || this.dropInstance.isDestroyed) {
return;
}
this.dropInstance.removeEventListener(literals['open'], this.ddOpen);
this.dropInstance.removeEventListener(events.actionComplete, this.ddComplete);
this.dropInstance.destroy();
this.parent.off(events.filterMenuClose, this.destroy);
this.parent.off(events.destroy, this.destroy);
};
return BooleanFilterUI;
}());
exports.BooleanFilterUI = BooleanFilterUI;
});
|