@syncfusion/ej2-lists 20.4.42 → 20.4.48

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.
@@ -1436,7 +1436,7 @@ let ListView = class ListView extends Component {
1436
1436
  this.currentLiElements = [];
1437
1437
  this.isNestedList = false;
1438
1438
  this.selectedData = [];
1439
- this.selectedId = [];
1439
+ this.selectedId = this.enablePersistence ? this.selectedId : [];
1440
1440
  this.LISTVIEW_TEMPLATE_ID = `${this.element.id}${LISTVIEW_TEMPLATE_PROPERTY}`;
1441
1441
  this.LISTVIEW_GROUPTEMPLATE_ID = `${this.element.id}${LISTVIEW_GROUPTEMPLATE_PROPERTY}`;
1442
1442
  this.LISTVIEW_HEADERTEMPLATE_ID = `${this.element.id}${LISTVIEW_HEADERTEMPLATE_PROPERTY}`;
@@ -1465,7 +1465,13 @@ let ListView = class ListView extends Component {
1465
1465
  args.item.firstElementChild.classList.add(classNames.checkbox);
1466
1466
  if (typeof this.dataSource[0] !== 'string' && typeof this.dataSource[0] !== 'number') {
1467
1467
  fieldData = getFieldValues(args.curData, this.listBaseOption.fields);
1468
- if (fieldData[this.listBaseOption.fields.isChecked]) {
1468
+ if (this.enablePersistence && !isNullOrUndefined(this.selectedId)) {
1469
+ let index = this.selectedId.findIndex(e => e == fieldData[this.listBaseOption.fields.id].toString());
1470
+ if (index != -1) {
1471
+ this.checkInternally(args, checkboxElement);
1472
+ }
1473
+ }
1474
+ else if (fieldData[this.listBaseOption.fields.isChecked]) {
1469
1475
  this.checkInternally(args, checkboxElement);
1470
1476
  }
1471
1477
  }
@@ -1530,6 +1536,7 @@ let ListView = class ListView extends Component {
1530
1536
  checkboxIcon.parentElement.setAttribute('aria-checked', checked ? 'true' : 'false');
1531
1537
  }
1532
1538
  this.setSelectedItemData(liElement);
1539
+ this.updateSelectedId();
1533
1540
  }
1534
1541
  }
1535
1542
  /**
@@ -1572,6 +1579,7 @@ let ListView = class ListView extends Component {
1572
1579
  if (this.enableVirtualization) {
1573
1580
  this.virtualizationModule.checkedItem(checked);
1574
1581
  }
1582
+ this.updateSelectedId();
1575
1583
  }
1576
1584
  }
1577
1585
  setCheckbox() {
@@ -1687,6 +1695,7 @@ let ListView = class ListView extends Component {
1687
1695
  }
1688
1696
  }
1689
1697
  }
1698
+ this.updateSelectedId();
1690
1699
  }
1691
1700
  removeElement(element) {
1692
1701
  return element && element.parentNode && element.parentNode.removeChild(element);
@@ -1875,6 +1884,7 @@ let ListView = class ListView extends Component {
1875
1884
  const eventArgs = this.selectEventData(li, e);
1876
1885
  merge(eventArgs, { isChecked: checkIcon ? checkIcon.classList.contains(classNames.checked) : false });
1877
1886
  this.trigger('select', eventArgs);
1887
+ this.updateSelectedId();
1878
1888
  }
1879
1889
  }
1880
1890
  keyActionHandler(e) {
@@ -2543,6 +2553,16 @@ let ListView = class ListView extends Component {
2543
2553
  }
2544
2554
  return parentId;
2545
2555
  }
2556
+ updateSelectedId() {
2557
+ this.selectedId = [];
2558
+ const liCollection = this.curUL.getElementsByClassName(classNames.selected);
2559
+ for (let i = 0; i < liCollection.length; i++) {
2560
+ const tempData = this.getItemData(liCollection[i]);
2561
+ if (tempData[this.listBaseOption.fields.id]) {
2562
+ this.selectedId.push(tempData[this.listBaseOption.fields.id]);
2563
+ }
2564
+ }
2565
+ }
2546
2566
  /**
2547
2567
  * Gets the details of the currently selected item from the list items.
2548
2568
  *
@@ -2972,7 +2992,7 @@ let ListView = class ListView extends Component {
2972
2992
  getPersistData() {
2973
2993
  return this.addOnPersist(['cssClass', 'enableRtl', 'htmlAttributes',
2974
2994
  'enable', 'fields', 'animation', 'headerTitle',
2975
- 'sortOrder', 'showIcon', 'height', 'width', 'showCheckBox', 'checkBoxPosition']);
2995
+ 'sortOrder', 'showIcon', 'height', 'width', 'showCheckBox', 'checkBoxPosition', 'selectedId']);
2976
2996
  }
2977
2997
  };
2978
2998
  __decorate([