@syncfusion/ej2-multicolumn-combobox 30.1.37 → 30.1.40

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.
@@ -267,6 +267,9 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
267
267
  }
268
268
  render() {
269
269
  this.renderInput();
270
+ if (this.gridData == null) {
271
+ this.setGridData(this.dataSource);
272
+ }
270
273
  this.renderGrid();
271
274
  this.popupDiv = this.createElement('div', { className: CONTENT });
272
275
  this.popupDiv.appendChild(this.gridEle);
@@ -274,6 +277,64 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
274
277
  this.renderPopup();
275
278
  this.wireEvents();
276
279
  }
280
+ setGridData(dataSource, query) {
281
+ this.trigger('actionBegin', { cancel: false, query: query }, (args) => {
282
+ if (!args.cancel) {
283
+ if (dataSource instanceof DataManager) {
284
+ if (this.isShowSpinner) {
285
+ this.showHideSpinner(true);
286
+ }
287
+ dataSource.executeQuery(this.getQuery(query)).then((e) => {
288
+ this.gridData = e.result;
289
+ this.trigger('actionComplete', e, (e) => {
290
+ this.showHideSpinner(false);
291
+ if (!this.isMainDataUpdated) {
292
+ this.mainData = this.gridData;
293
+ this.remoteDataLength = this.gridData.length;
294
+ this.isMainDataUpdated = true;
295
+ }
296
+ if (this.popupDiv) {
297
+ this.updateGridDataSource();
298
+ }
299
+ });
300
+ }).catch((e) => {
301
+ this.trigger('actionFailure', e, null);
302
+ });
303
+ }
304
+ else {
305
+ const dataManager = new DataManager(dataSource);
306
+ const listItems = (this.getQuery(query)).executeLocal(dataManager);
307
+ this.gridData = listItems;
308
+ this.trigger('actionComplete', { result: listItems }, (e) => {
309
+ if (!this.isMainDataUpdated) {
310
+ this.mainData = this.gridData;
311
+ this.remoteDataLength = this.gridData.length;
312
+ this.isMainDataUpdated = true;
313
+ }
314
+ if (this.popupDiv) {
315
+ this.updateGridDataSource();
316
+ }
317
+ });
318
+ }
319
+ }
320
+ });
321
+ }
322
+ getQuery(query) {
323
+ let filterQuery;
324
+ if (!this.isCustomFilter && this.allowFiltering) {
325
+ filterQuery = query ? query.clone() : this.query ? this.query.clone() : new Query();
326
+ const filterType = this.typedString === '' ? 'contains' : this.filterType;
327
+ if ((this.allowFiltering && this.typedString && this.typedString !== '')) {
328
+ const fields = (this.fields.text) ? this.fields.text : '';
329
+ filterQuery.where(fields, filterType, this.typedString, true, false);
330
+ }
331
+ }
332
+ else {
333
+ filterQuery = (this.customFilterQuery != null) ?
334
+ this.customFilterQuery.clone() : query ? query.clone() : this.query ? this.query.clone() : new Query();
335
+ }
336
+ return filterQuery;
337
+ }
277
338
  setHiddenValue() {
278
339
  if (isNullOrUndefined(this.value)) {
279
340
  this.hiddenElement.innerHTML = '';
@@ -296,7 +357,7 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
296
357
  const gridColumns = this.getGridColumns();
297
358
  const sortOrder = this.sortOrder.toString().toLowerCase();
298
359
  this.gridObj = new Grid({
299
- dataSource: this.dataSource,
360
+ dataSource: this.gridData,
300
361
  columns: gridColumns,
301
362
  allowSorting: this.allowSorting,
302
363
  enableStickyHeader: true,
@@ -306,7 +367,6 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
306
367
  enableVirtualization: this.enableVirtualization,
307
368
  enableRtl: this.enableRtl,
308
369
  editSettings: { allowAdding: false },
309
- query: this.query,
310
370
  allowTextWrap: this.gridSettings.allowTextWrap,
311
371
  textWrapSettings: { wrapMode: this.gridSettings.textWrapMode },
312
372
  height: this.popupHeight,
@@ -321,7 +381,6 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
321
381
  },
322
382
  dataBound: () => { this.onDataBound(); },
323
383
  actionFailure: (args) => { this.onActionFailure(args); },
324
- actionBegin: (args) => { this.trigger('actionBegin', args); },
325
384
  actionComplete: this.handleActionComplete.bind(this),
326
385
  keyPressed: this.handleKeyPressed.bind(this),
327
386
  resizing: (args) => {
@@ -356,7 +415,6 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
356
415
  }
357
416
  }
358
417
  handleActionComplete(args) {
359
- this.trigger('actionComplete', args);
360
418
  if (args.requestType === 'sorting') {
361
419
  this.updateRowSelection(args);
362
420
  }
@@ -716,8 +774,8 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
716
774
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
717
775
  const dataLists = e.result;
718
776
  const filteredData = dataLists.filter((item) => {
719
- const fieldVal = this.updateFieldValue(isRerender ? (isValue ? this.fields.value : this.fields.text) :
720
- !isNullOrUndefined(this.value) ? this.fields.value : this.fields.text, item);
777
+ const fieldVal = item ? (this.updateFieldValue(isRerender ? (isValue ? this.fields.value :
778
+ this.fields.text) : !isNullOrUndefined(this.value) ? this.fields.value : this.fields.text, item)) : null;
721
779
  return fieldVal === value;
722
780
  });
723
781
  if (filteredData.length > 0) {
@@ -1025,24 +1083,24 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
1025
1083
  this.showPopup(null, true);
1026
1084
  this.updateClearIconState();
1027
1085
  if (this.allowFiltering) {
1028
- const inputValue = e.target.value.toLowerCase();
1029
- let customFiltering = false;
1086
+ this.typedString = e.target.value.toLowerCase();
1030
1087
  const eventArgs = {
1031
1088
  preventDefaultAction: false,
1032
- text: inputValue,
1089
+ text: this.typedString,
1033
1090
  updateData: (dataSource, query, fields) => {
1034
1091
  if (eventArgs.cancel) {
1035
1092
  return;
1036
1093
  }
1037
- customFiltering = true;
1038
- this.filterAction(dataSource, inputValue, query, fields);
1094
+ this.isCustomFilter = true;
1095
+ this.customFilterQuery = query ? query.clone() : query;
1096
+ this.setGridData(dataSource, query);
1039
1097
  },
1040
1098
  event: e,
1041
1099
  cancel: false
1042
1100
  };
1043
1101
  this.trigger('filtering', eventArgs, (eventArgs) => {
1044
- if (!eventArgs.cancel && !eventArgs.preventDefaultAction && !customFiltering) {
1045
- this.filterAction(this.dataSource, inputValue, this.query, this.fields);
1102
+ if (!eventArgs.cancel && !eventArgs.preventDefaultAction && !this.isCustomFilter) {
1103
+ this.setGridData(this.dataSource, this.query ? this.query.clone() : null);
1046
1104
  }
1047
1105
  });
1048
1106
  }
@@ -1053,11 +1111,7 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
1053
1111
  let data;
1054
1112
  let exactData;
1055
1113
  if (this.dataSource instanceof DataManager) {
1056
- const query = new Query();
1057
- /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1058
- const result = yield this.dataSource.executeQuery(query);
1059
- const totaldata = result.result;
1060
- ({ data, exactData } = this.filterDatas(totaldata, inputValue));
1114
+ ({ data, exactData } = this.filterDatas(this.mainData, inputValue));
1061
1115
  }
1062
1116
  else if (Array.isArray(this.dataSource)) {
1063
1117
  ({ data, exactData } = this.filterDatas(this.dataSource, inputValue));
@@ -1086,68 +1140,14 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
1086
1140
  const selectedIndex = this.findIndex(this.gridObj.currentViewData, this.matchedContent);
1087
1141
  this.matchedRowEle = this.gridObj.getRowByIndex(selectedIndex);
1088
1142
  }
1089
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1090
- filterAction(dataSource, inputValue, query, fields) {
1091
- const isQuery = query || new Query();
1092
- const filterType = this.filterType.toString().toLowerCase();
1093
- if (isNullOrUndefined(query) && isNullOrUndefined(fields)) {
1094
- this.updateGridDataSource(dataSource);
1095
- }
1096
- else if (query) {
1097
- if (dataSource instanceof DataManager) {
1098
- this.filteringHandler(dataSource, inputValue, query, fields);
1099
- }
1100
- else {
1101
- new DataManager(dataSource).executeQuery(query).then((e) => {
1102
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1103
- const dataLists = e.result;
1104
- this.updateGridDataSource(dataLists);
1105
- });
1106
- }
1107
- }
1108
- else {
1109
- if (dataSource instanceof DataManager) {
1110
- this.filteringHandler(dataSource, inputValue, isQuery, fields);
1111
- }
1112
- else if (Array.isArray(dataSource)) {
1113
- const filteredData = dataSource.filter((item) => this.filterData(item, filterType, inputValue, fields));
1114
- this.updateGridDataSource(filteredData);
1115
- }
1116
- }
1117
- }
1118
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1119
- filteringHandler(dataSource, inputValue, query, fields) {
1120
- const filterType = this.filterType.toString().toLowerCase();
1121
- let filteredData;
1122
- dataSource.executeQuery(query).then((e) => {
1123
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1124
- const dataLists = e.result;
1125
- filteredData = dataLists.filter((item) => this.filterData(item, filterType, inputValue, fields));
1126
- this.updateGridDataSource(filteredData);
1127
- });
1128
- }
1129
- filterData(item, filterType, inputValue, fields) {
1130
- const dataValue = this.updateFieldValue(fields ? fields.text : this.fields.text, item);
1131
- const itemValue = dataValue.toLowerCase();
1132
- switch (filterType) {
1133
- case 'startswith':
1134
- return itemValue.startsWith(inputValue);
1135
- case 'endswith':
1136
- return itemValue.endsWith(inputValue);
1137
- case 'contains':
1138
- return itemValue.includes(inputValue);
1139
- default:
1140
- return false;
1141
- }
1142
- }
1143
- updateGridDataSource(dataSource) {
1144
- if (dataSource.length > 0) {
1143
+ updateGridDataSource() {
1144
+ if (this.gridData && this.gridData.length > 0) {
1145
1145
  removeClass([this.popupDiv], [NODATA]);
1146
1146
  const noRecordEle = this.popupDiv.querySelector('.e-no-records');
1147
1147
  if (noRecordEle) {
1148
1148
  this.popupDiv.removeChild(noRecordEle);
1149
1149
  }
1150
- this.gridObj.dataSource = dataSource;
1150
+ this.gridObj.dataSource = this.gridData;
1151
1151
  this.isDataFiltered = true;
1152
1152
  }
1153
1153
  else {
@@ -1254,7 +1254,8 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
1254
1254
  const e = mouseEvent ? mouseEvent : keyEvent;
1255
1255
  const val = isKeyDown ? this.matchedContent : this.exactMatchedContent;
1256
1256
  if (!val && e.code !== 'Enter') {
1257
- this.inputEle.value = this.value = this.index = this.text = null;
1257
+ this.inputEle.value = null;
1258
+ this.setProperties({ value: null, index: null, text: null }, true);
1258
1259
  }
1259
1260
  this.hidePopup(e);
1260
1261
  if (this.matchedRowEle && !isClearValues && val) {
@@ -1432,7 +1433,7 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
1432
1433
  if (this.gridObj) {
1433
1434
  let dataLength;
1434
1435
  this.isShowSpinner = true;
1435
- this.gridObj.dataSource = newDataSource;
1436
+ this.setGridData(newDataSource);
1436
1437
  const isRemoteData = oldDataSource instanceof DataManager;
1437
1438
  if (isRemoteData) {
1438
1439
  oldDataSource.executeQuery(new Query()).then((e) => {
@@ -1522,12 +1523,6 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
1522
1523
  this.inputEle.setAttribute('aria-activedescendant', firstRow.getAttribute('data-uid'));
1523
1524
  }
1524
1525
  }
1525
- if (!isNullOrUndefined(this.dataSource) && this.dataSource instanceof DataManager) {
1526
- this.dataSource.executeQuery(new Query).then((e) => {
1527
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1528
- this.remoteDataLength = e.result.length;
1529
- });
1530
- }
1531
1526
  this.popupObj.show(new Animation(eventArgs.animation), this.popupEle.firstElementChild);
1532
1527
  }
1533
1528
  });
@@ -1559,11 +1554,17 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
1559
1554
  }
1560
1555
  this.inputEle.removeAttribute('aria-owns');
1561
1556
  this.inputEle.removeAttribute('aria-activedescendant');
1557
+ this.customFilterQuery = null;
1562
1558
  }
1563
1559
  });
1564
1560
  setTimeout(() => {
1565
1561
  if (this.gridObj) {
1566
- this.gridObj.dataSource = this.dataSource;
1562
+ this.gridObj.dataSource = this.allowFiltering ? this.mainData : this.gridData;
1563
+ const noRecordEle = this.popupDiv.querySelector('.e-no-records');
1564
+ if (noRecordEle) {
1565
+ this.popupDiv.removeChild(noRecordEle);
1566
+ removeClass([this.popupDiv], [NODATA]);
1567
+ }
1567
1568
  this.updateGridHeight(true, false);
1568
1569
  }
1569
1570
  }, 100);
@@ -1768,9 +1769,8 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
1768
1769
  this.updateDynamicDataSource(newProp.dataSource, oldProp.dataSource);
1769
1770
  break;
1770
1771
  case 'query':
1771
- if (this.gridObj) {
1772
- this.gridObj.query = newProp.query;
1773
- }
1772
+ this.isMainDataUpdated = false;
1773
+ this.setGridData(this.dataSource);
1774
1774
  break;
1775
1775
  case 'gridSettings':
1776
1776
  if (this.gridObj) {