@syncfusion/ej2-multicolumn-combobox 29.2.4 → 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
  }
@@ -475,6 +531,11 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
475
531
  }
476
532
  }
477
533
  onDataBound() {
534
+ if (this.isLocaleChanged) {
535
+ this.isLocaleChanged = false;
536
+ this.unWireEvents();
537
+ this.wireEvents();
538
+ }
478
539
  const dataCount = this.dataSource.length;
479
540
  const popupChild = this.popupDiv.querySelector('.' + MULTICOLUMNGRID);
480
541
  const hasNoDataClass = this.popupDiv.classList.contains(NODATA);
@@ -711,8 +772,8 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
711
772
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
712
773
  const dataLists = e.result;
713
774
  const filteredData = dataLists.filter((item) => {
714
- const fieldVal = this.updateFieldValue(isRerender ? (isValue ? this.fields.value : this.fields.text) :
715
- !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;
716
777
  return fieldVal === value;
717
778
  });
718
779
  if (filteredData.length > 0) {
@@ -1020,24 +1081,24 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
1020
1081
  this.showPopup(null, true);
1021
1082
  this.updateClearIconState();
1022
1083
  if (this.allowFiltering) {
1023
- const inputValue = e.target.value.toLowerCase();
1024
- let customFiltering = false;
1084
+ this.typedString = e.target.value.toLowerCase();
1025
1085
  const eventArgs = {
1026
1086
  preventDefaultAction: false,
1027
- text: inputValue,
1087
+ text: this.typedString,
1028
1088
  updateData: (dataSource, query, fields) => {
1029
1089
  if (eventArgs.cancel) {
1030
1090
  return;
1031
1091
  }
1032
- customFiltering = true;
1033
- this.filterAction(dataSource, inputValue, query, fields);
1092
+ this.isCustomFilter = true;
1093
+ this.customFilterQuery = query ? query.clone() : query;
1094
+ this.setGridData(dataSource, query);
1034
1095
  },
1035
1096
  event: e,
1036
1097
  cancel: false
1037
1098
  };
1038
1099
  this.trigger('filtering', eventArgs, (eventArgs) => {
1039
- if (!eventArgs.cancel && !eventArgs.preventDefaultAction && !customFiltering) {
1040
- 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);
1041
1102
  }
1042
1103
  });
1043
1104
  }
@@ -1048,11 +1109,7 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
1048
1109
  let data;
1049
1110
  let exactData;
1050
1111
  if (this.dataSource instanceof DataManager) {
1051
- const query = new Query();
1052
- /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1053
- const result = yield this.dataSource.executeQuery(query);
1054
- const totaldata = result.result;
1055
- ({ data, exactData } = this.filterDatas(totaldata, inputValue));
1112
+ ({ data, exactData } = this.filterDatas(this.mainData, inputValue));
1056
1113
  }
1057
1114
  else if (Array.isArray(this.dataSource)) {
1058
1115
  ({ data, exactData } = this.filterDatas(this.dataSource, inputValue));
@@ -1081,68 +1138,14 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
1081
1138
  const selectedIndex = this.findIndex(this.gridObj.currentViewData, this.matchedContent);
1082
1139
  this.matchedRowEle = this.gridObj.getRowByIndex(selectedIndex);
1083
1140
  }
1084
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1085
- filterAction(dataSource, inputValue, query, fields) {
1086
- const isQuery = query || new Query();
1087
- const filterType = this.filterType.toString().toLowerCase();
1088
- if (isNullOrUndefined(query) && isNullOrUndefined(fields)) {
1089
- this.updateGridDataSource(dataSource);
1090
- }
1091
- else if (query) {
1092
- if (dataSource instanceof DataManager) {
1093
- this.filteringHandler(dataSource, inputValue, query, fields);
1094
- }
1095
- else {
1096
- new DataManager(dataSource).executeQuery(query).then((e) => {
1097
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1098
- const dataLists = e.result;
1099
- this.updateGridDataSource(dataLists);
1100
- });
1101
- }
1102
- }
1103
- else {
1104
- if (dataSource instanceof DataManager) {
1105
- this.filteringHandler(dataSource, inputValue, isQuery, fields);
1106
- }
1107
- else if (Array.isArray(dataSource)) {
1108
- const filteredData = dataSource.filter((item) => this.filterData(item, filterType, inputValue, fields));
1109
- this.updateGridDataSource(filteredData);
1110
- }
1111
- }
1112
- }
1113
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1114
- filteringHandler(dataSource, inputValue, query, fields) {
1115
- const filterType = this.filterType.toString().toLowerCase();
1116
- let filteredData;
1117
- dataSource.executeQuery(query).then((e) => {
1118
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1119
- const dataLists = e.result;
1120
- filteredData = dataLists.filter((item) => this.filterData(item, filterType, inputValue, fields));
1121
- this.updateGridDataSource(filteredData);
1122
- });
1123
- }
1124
- filterData(item, filterType, inputValue, fields) {
1125
- const dataValue = this.updateFieldValue(fields ? fields.text : this.fields.text, item);
1126
- const itemValue = dataValue.toLowerCase();
1127
- switch (filterType) {
1128
- case 'startswith':
1129
- return itemValue.startsWith(inputValue);
1130
- case 'endswith':
1131
- return itemValue.endsWith(inputValue);
1132
- case 'contains':
1133
- return itemValue.includes(inputValue);
1134
- default:
1135
- return false;
1136
- }
1137
- }
1138
- updateGridDataSource(dataSource) {
1139
- if (dataSource.length > 0) {
1141
+ updateGridDataSource() {
1142
+ if (this.gridData && this.gridData.length > 0) {
1140
1143
  removeClass([this.popupDiv], [NODATA]);
1141
1144
  const noRecordEle = this.popupDiv.querySelector('.e-no-records');
1142
1145
  if (noRecordEle) {
1143
1146
  this.popupDiv.removeChild(noRecordEle);
1144
1147
  }
1145
- this.gridObj.dataSource = dataSource;
1148
+ this.gridObj.dataSource = this.gridData;
1146
1149
  this.isDataFiltered = true;
1147
1150
  }
1148
1151
  else {
@@ -1427,7 +1430,7 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
1427
1430
  if (this.gridObj) {
1428
1431
  let dataLength;
1429
1432
  this.isShowSpinner = true;
1430
- this.gridObj.dataSource = newDataSource;
1433
+ this.setGridData(newDataSource);
1431
1434
  const isRemoteData = oldDataSource instanceof DataManager;
1432
1435
  if (isRemoteData) {
1433
1436
  oldDataSource.executeQuery(new Query()).then((e) => {
@@ -1554,11 +1557,17 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
1554
1557
  }
1555
1558
  this.inputEle.removeAttribute('aria-owns');
1556
1559
  this.inputEle.removeAttribute('aria-activedescendant');
1560
+ this.customFilterQuery = null;
1557
1561
  }
1558
1562
  });
1559
1563
  setTimeout(() => {
1560
1564
  if (this.gridObj) {
1561
- 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
+ }
1562
1571
  this.updateGridHeight(true, false);
1563
1572
  }
1564
1573
  }, 100);
@@ -1763,9 +1772,8 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
1763
1772
  this.updateDynamicDataSource(newProp.dataSource, oldProp.dataSource);
1764
1773
  break;
1765
1774
  case 'query':
1766
- if (this.gridObj) {
1767
- this.gridObj.query = newProp.query;
1768
- }
1775
+ this.isMainDataUpdated = false;
1776
+ this.setGridData(this.dataSource);
1769
1777
  break;
1770
1778
  case 'gridSettings':
1771
1779
  if (this.gridObj) {
@@ -1813,6 +1821,9 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
1813
1821
  this.gridObj.columns = gridColumns;
1814
1822
  }
1815
1823
  break;
1824
+ case 'locale':
1825
+ this.isLocaleChanged = true;
1826
+ break;
1816
1827
  }
1817
1828
  }
1818
1829
  }