@syncfusion/ej2-dropdowns 27.2.2 → 27.2.3

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.
@@ -1349,9 +1349,11 @@ let DropDownBase = class DropDownBase extends Component {
1349
1349
  }
1350
1350
  renderItemsBySelect() {
1351
1351
  const element = this.element;
1352
- const fields = { value: 'value', text: 'text' };
1353
- const jsonElement = [];
1354
1352
  const group = element.querySelectorAll('select>optgroup');
1353
+ let fields;
1354
+ const isSelectGroupCheck = this.getModuleName() === 'multiselect' && this.isGroupChecking && group.length > 0;
1355
+ fields = isSelectGroupCheck ? { value: 'value', text: 'text', groupBy: 'categeory' } : fields = { value: 'value', text: 'text' };
1356
+ const jsonElement = [];
1355
1357
  const option = element.querySelectorAll('select>option');
1356
1358
  this.getJSONfromOption(jsonElement, option, fields);
1357
1359
  if (group.length) {
@@ -1361,12 +1363,17 @@ let DropDownBase = class DropDownBase extends Component {
1361
1363
  optionGroup[fields.text] = item.label;
1362
1364
  optionGroup.isHeader = true;
1363
1365
  const child = item.querySelectorAll('option');
1364
- jsonElement.push(optionGroup);
1365
- this.getJSONfromOption(jsonElement, child, fields);
1366
+ if (isSelectGroupCheck) {
1367
+ this.getJSONfromOption(jsonElement, child, fields, item.label);
1368
+ }
1369
+ else {
1370
+ jsonElement.push(optionGroup);
1371
+ this.getJSONfromOption(jsonElement, child, fields);
1372
+ }
1366
1373
  }
1367
1374
  element.querySelectorAll('select>option');
1368
1375
  }
1369
- this.updateFields(fields.text, fields.value, this.fields.groupBy, this.fields.htmlAttributes, this.fields.iconCss, this.fields.disabled);
1376
+ this.updateFields(fields.text, fields.value, isSelectGroupCheck ? fields.groupBy : this.fields.groupBy, this.fields.htmlAttributes, this.fields.iconCss, this.fields.disabled);
1370
1377
  this.resetList(jsonElement, fields);
1371
1378
  }
1372
1379
  updateFields(text, value, groupBy, htmlAttributes, iconCss, disabled) {
@@ -1382,12 +1389,15 @@ let DropDownBase = class DropDownBase extends Component {
1382
1389
  };
1383
1390
  this.setProperties(field, true);
1384
1391
  }
1385
- getJSONfromOption(items, options, fields) {
1392
+ getJSONfromOption(items, options, fields, category = null) {
1386
1393
  for (const option of options) {
1387
1394
  const json = {};
1388
1395
  json[fields.text] = option.innerText;
1389
1396
  json[fields.value] = !isNullOrUndefined(option.getAttribute(fields.value)) ?
1390
1397
  option.getAttribute(fields.value) : option.innerText;
1398
+ if (!isNullOrUndefined(category)) {
1399
+ json[fields.groupBy] = category;
1400
+ }
1391
1401
  items.push(json);
1392
1402
  }
1393
1403
  }
@@ -1841,7 +1851,12 @@ let DropDownBase = class DropDownBase extends Component {
1841
1851
  if (this.sortOrder !== 'None') {
1842
1852
  dataSource = this.getSortedDataSource(dataSource);
1843
1853
  }
1844
- dataSource = ListBase.groupDataSource(dataSource, fields.properties, this.sortOrder);
1854
+ if (this.element.querySelector('optgroup') && this.isGroupChecking && this.getModuleName() === 'multiselect') {
1855
+ dataSource = ListBase.groupDataSource(dataSource, fields, this.sortOrder);
1856
+ }
1857
+ else {
1858
+ dataSource = ListBase.groupDataSource(dataSource, fields.properties, this.sortOrder);
1859
+ }
1845
1860
  }
1846
1861
  addClass([this.list], dropDownBaseClasses.grouping);
1847
1862
  }
@@ -20430,11 +20445,13 @@ let ListBox = ListBox_1 = class ListBox extends DropDownBase {
20430
20445
  if (fListBox.value.length === 1 && fListBox.getSelectedItems().length) {
20431
20446
  fListBox.value[0] = fListBox.getFormattedValue(fListBox.getSelectedItems()[0].getAttribute('data-value'));
20432
20447
  }
20433
- if (fListBox.liCollections.length === fListBox.ulElement.querySelectorAll('.e-disabled').length) {
20448
+ if (fListBox.liCollections.length === fListBox.ulElement.querySelectorAll('.e-disabled').length && this.toolbarAction) {
20434
20449
  const wrap = this.list.parentElement.getElementsByClassName('e-listbox-tool')[0];
20435
20450
  const toolbarAction = this.toolbarAction === 'moveFrom' ? 'moveAllFrom' : 'moveAllTo';
20436
- const btn = wrap.querySelector('[data-value="' + toolbarAction + '"]');
20437
- btn.disabled = true;
20451
+ if (wrap) {
20452
+ const btn = wrap.querySelector('[data-value="' + toolbarAction + '"]');
20453
+ btn.disabled = true;
20454
+ }
20438
20455
  }
20439
20456
  }
20440
20457
  selectNextList(elems, dataLiIdx, dataIdx, inst) {