@syncfusion/ej2-multicolumn-combobox 30.1.37 → 30.1.39

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,62 @@ 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.isMainDataUpdated = true;
294
+ }
295
+ if (this.popupDiv) {
296
+ this.updateGridDataSource();
297
+ }
298
+ });
299
+ }).catch((e) => {
300
+ this.trigger('actionFailure', e, null);
301
+ });
302
+ }
303
+ else {
304
+ const dataManager = new DataManager(dataSource);
305
+ const listItems = (this.getQuery(query)).executeLocal(dataManager);
306
+ this.gridData = listItems;
307
+ this.trigger('actionComplete', { result: listItems }, (e) => {
308
+ if (!this.isMainDataUpdated) {
309
+ this.mainData = this.gridData;
310
+ this.isMainDataUpdated = true;
311
+ }
312
+ if (this.popupDiv) {
313
+ this.updateGridDataSource();
314
+ }
315
+ });
316
+ }
317
+ }
318
+ });
319
+ }
320
+ getQuery(query) {
321
+ let filterQuery;
322
+ if (!this.isCustomFilter && this.allowFiltering) {
323
+ filterQuery = query ? query.clone() : this.query ? this.query.clone() : new Query();
324
+ const filterType = this.typedString === '' ? 'contains' : this.filterType;
325
+ if ((this.allowFiltering && this.typedString && this.typedString !== '')) {
326
+ const fields = (this.fields.text) ? this.fields.text : '';
327
+ filterQuery.where(fields, filterType, this.typedString, true, false);
328
+ }
329
+ }
330
+ else {
331
+ filterQuery = (this.customFilterQuery != null) ?
332
+ this.customFilterQuery.clone() : query ? query.clone() : this.query ? this.query.clone() : new Query();
333
+ }
334
+ return filterQuery;
335
+ }
277
336
  setHiddenValue() {
278
337
  if (isNullOrUndefined(this.value)) {
279
338
  this.hiddenElement.innerHTML = '';
@@ -296,7 +355,7 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
296
355
  const gridColumns = this.getGridColumns();
297
356
  const sortOrder = this.sortOrder.toString().toLowerCase();
298
357
  this.gridObj = new Grid({
299
- dataSource: this.dataSource,
358
+ dataSource: this.gridData,
300
359
  columns: gridColumns,
301
360
  allowSorting: this.allowSorting,
302
361
  enableStickyHeader: true,
@@ -306,7 +365,6 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
306
365
  enableVirtualization: this.enableVirtualization,
307
366
  enableRtl: this.enableRtl,
308
367
  editSettings: { allowAdding: false },
309
- query: this.query,
310
368
  allowTextWrap: this.gridSettings.allowTextWrap,
311
369
  textWrapSettings: { wrapMode: this.gridSettings.textWrapMode },
312
370
  height: this.popupHeight,
@@ -321,7 +379,6 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
321
379
  },
322
380
  dataBound: () => { this.onDataBound(); },
323
381
  actionFailure: (args) => { this.onActionFailure(args); },
324
- actionBegin: (args) => { this.trigger('actionBegin', args); },
325
382
  actionComplete: this.handleActionComplete.bind(this),
326
383
  keyPressed: this.handleKeyPressed.bind(this),
327
384
  resizing: (args) => {
@@ -356,7 +413,6 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
356
413
  }
357
414
  }
358
415
  handleActionComplete(args) {
359
- this.trigger('actionComplete', args);
360
416
  if (args.requestType === 'sorting') {
361
417
  this.updateRowSelection(args);
362
418
  }
@@ -716,8 +772,8 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
716
772
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
717
773
  const dataLists = e.result;
718
774
  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);
775
+ const fieldVal = item ? (this.updateFieldValue(isRerender ? (isValue ? this.fields.value :
776
+ this.fields.text) : !isNullOrUndefined(this.value) ? this.fields.value : this.fields.text, item)) : null;
721
777
  return fieldVal === value;
722
778
  });
723
779
  if (filteredData.length > 0) {
@@ -1025,24 +1081,24 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
1025
1081
  this.showPopup(null, true);
1026
1082
  this.updateClearIconState();
1027
1083
  if (this.allowFiltering) {
1028
- const inputValue = e.target.value.toLowerCase();
1029
- let customFiltering = false;
1084
+ this.typedString = e.target.value.toLowerCase();
1030
1085
  const eventArgs = {
1031
1086
  preventDefaultAction: false,
1032
- text: inputValue,
1087
+ text: this.typedString,
1033
1088
  updateData: (dataSource, query, fields) => {
1034
1089
  if (eventArgs.cancel) {
1035
1090
  return;
1036
1091
  }
1037
- customFiltering = true;
1038
- this.filterAction(dataSource, inputValue, query, fields);
1092
+ this.isCustomFilter = true;
1093
+ this.customFilterQuery = query ? query.clone() : query;
1094
+ this.setGridData(dataSource, query);
1039
1095
  },
1040
1096
  event: e,
1041
1097
  cancel: false
1042
1098
  };
1043
1099
  this.trigger('filtering', eventArgs, (eventArgs) => {
1044
- if (!eventArgs.cancel && !eventArgs.preventDefaultAction && !customFiltering) {
1045
- this.filterAction(this.dataSource, inputValue, this.query, this.fields);
1100
+ if (!eventArgs.cancel && !eventArgs.preventDefaultAction && !this.isCustomFilter) {
1101
+ this.setGridData(this.dataSource, this.query ? this.query.clone() : null);
1046
1102
  }
1047
1103
  });
1048
1104
  }
@@ -1053,11 +1109,7 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
1053
1109
  let data;
1054
1110
  let exactData;
1055
1111
  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));
1112
+ ({ data, exactData } = this.filterDatas(this.mainData, inputValue));
1061
1113
  }
1062
1114
  else if (Array.isArray(this.dataSource)) {
1063
1115
  ({ data, exactData } = this.filterDatas(this.dataSource, inputValue));
@@ -1086,68 +1138,14 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
1086
1138
  const selectedIndex = this.findIndex(this.gridObj.currentViewData, this.matchedContent);
1087
1139
  this.matchedRowEle = this.gridObj.getRowByIndex(selectedIndex);
1088
1140
  }
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) {
1141
+ updateGridDataSource() {
1142
+ if (this.gridData && this.gridData.length > 0) {
1145
1143
  removeClass([this.popupDiv], [NODATA]);
1146
1144
  const noRecordEle = this.popupDiv.querySelector('.e-no-records');
1147
1145
  if (noRecordEle) {
1148
1146
  this.popupDiv.removeChild(noRecordEle);
1149
1147
  }
1150
- this.gridObj.dataSource = dataSource;
1148
+ this.gridObj.dataSource = this.gridData;
1151
1149
  this.isDataFiltered = true;
1152
1150
  }
1153
1151
  else {
@@ -1432,7 +1430,7 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
1432
1430
  if (this.gridObj) {
1433
1431
  let dataLength;
1434
1432
  this.isShowSpinner = true;
1435
- this.gridObj.dataSource = newDataSource;
1433
+ this.setGridData(newDataSource);
1436
1434
  const isRemoteData = oldDataSource instanceof DataManager;
1437
1435
  if (isRemoteData) {
1438
1436
  oldDataSource.executeQuery(new Query()).then((e) => {
@@ -1559,11 +1557,17 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
1559
1557
  }
1560
1558
  this.inputEle.removeAttribute('aria-owns');
1561
1559
  this.inputEle.removeAttribute('aria-activedescendant');
1560
+ this.customFilterQuery = null;
1562
1561
  }
1563
1562
  });
1564
1563
  setTimeout(() => {
1565
1564
  if (this.gridObj) {
1566
- this.gridObj.dataSource = this.dataSource;
1565
+ this.gridObj.dataSource = this.allowFiltering ? this.mainData : this.gridData;
1566
+ const noRecordEle = this.popupDiv.querySelector('.e-no-records');
1567
+ if (noRecordEle) {
1568
+ this.popupDiv.removeChild(noRecordEle);
1569
+ removeClass([this.popupDiv], [NODATA]);
1570
+ }
1567
1571
  this.updateGridHeight(true, false);
1568
1572
  }
1569
1573
  }, 100);
@@ -1768,9 +1772,8 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
1768
1772
  this.updateDynamicDataSource(newProp.dataSource, oldProp.dataSource);
1769
1773
  break;
1770
1774
  case 'query':
1771
- if (this.gridObj) {
1772
- this.gridObj.query = newProp.query;
1773
- }
1775
+ this.isMainDataUpdated = false;
1776
+ this.setGridData(this.dataSource);
1774
1777
  break;
1775
1778
  case 'gridSettings':
1776
1779
  if (this.gridObj) {