@syncfusion/ej2-querybuilder 26.1.40 → 26.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1081,7 +1081,7 @@ let QueryBuilder = class QueryBuilder extends Component {
1081
1081
  popupHeight: ((this.columns.length > 5) ? height : 'auto'), changeOnBlur: false,
1082
1082
  change: this.changeField.bind(this), value: !isNullOrUndefined(ddlValue) ? [ddlValue] : null,
1083
1083
  open: this.popupOpen.bind(this, false), treeSettings: { expandOn: 'Click' },
1084
- cssClass: 'e-qb-ddt'
1084
+ cssClass: 'e-qb-ddt', filtering: this.dropdownTreeFiltering.bind(this), close: this.dropdownTreeClose.bind(this)
1085
1085
  };
1086
1086
  if (this.fieldModel) {
1087
1087
  ddlField = Object.assign({}, ddlField, this.fieldModel);
@@ -1151,6 +1151,70 @@ let QueryBuilder = class QueryBuilder extends Component {
1151
1151
  this.setMultiConnector(ruleElem);
1152
1152
  }
1153
1153
  }
1154
+ dropdownTreeFiltering(args) {
1155
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
1156
+ const proxy = this;
1157
+ let ruleElemID = '';
1158
+ const srcElement = args.event.srcElement;
1159
+ const isClearIcon = srcElement.classList.contains('e-clear-icon');
1160
+ const inputElem = isClearIcon ? srcElement.parentElement.querySelector('.e-textbox') : srcElement;
1161
+ ruleElemID = inputElem.id.split('_filterkey')[0];
1162
+ const ruleElem = document.getElementById(ruleElemID);
1163
+ this.ddTree = getComponent(ruleElem.querySelector('input.e-dropdowntree'), 'dropdowntree');
1164
+ const hierarchicalData = extend([], this.columns, [], true);
1165
+ // Cancel the default filtering.
1166
+ args.cancel = true;
1167
+ if (args.text === '') {
1168
+ this.changeDataSource(hierarchicalData);
1169
+ }
1170
+ else {
1171
+ const matchedDataSource = hierarchicalData
1172
+ .map((data) => this.nestedChildFilter(args.text, data))
1173
+ .filter((filteredChild) => filteredChild !== null);
1174
+ this.changeDataSource(matchedDataSource);
1175
+ setTimeout(() => {
1176
+ proxy.ddTree.treeObj.expandAll();
1177
+ }, 100);
1178
+ }
1179
+ }
1180
+ changeDataSource(data) {
1181
+ this.ddTree.treeObj.fields = {
1182
+ dataSource: data,
1183
+ value: 'field',
1184
+ text: 'label',
1185
+ child: 'columns',
1186
+ expanded: 'expanded'
1187
+ };
1188
+ this.ddTree.treeObj.refresh();
1189
+ }
1190
+ nestedChildFilter(value, node) {
1191
+ const children = node[this.ddTree.fields.child];
1192
+ if (!children) {
1193
+ return this.isMatchedNode(value, node) ? node : null;
1194
+ }
1195
+ const matchedChildren = children
1196
+ .map((child) => this.nestedChildFilter(value, child))
1197
+ .filter((filteredChild) => filteredChild !== null);
1198
+ if (matchedChildren.length) {
1199
+ node[this.ddTree.fields.child] = matchedChildren;
1200
+ return node;
1201
+ }
1202
+ else {
1203
+ node[this.ddTree.fields.child] = children;
1204
+ return this.isMatchedNode(value, node) ? node : null;
1205
+ }
1206
+ }
1207
+ isMatchedNode(value, node) {
1208
+ const checkValue = node[this.ddTree.fields.text].toLowerCase();
1209
+ value = value ? value.toLowerCase() : '';
1210
+ return checkValue.indexOf(value) !== -1;
1211
+ }
1212
+ dropdownTreeClose() {
1213
+ if (this.ddTree) {
1214
+ this.changeDataSource(this.columns);
1215
+ }
1216
+ this.ddTree = null;
1217
+ }
1154
1218
  updateDropdowntreeDS(columns) {
1155
1219
  for (let i = 0; i < columns.length; i++) {
1156
1220
  if (columns[parseInt(i.toString(), 10)].type === 'object') {