@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.
@@ -1462,7 +1462,7 @@ var ListView = /** @__PURE__ @class */ (function (_super) {
1462
1462
  this.currentLiElements = [];
1463
1463
  this.isNestedList = false;
1464
1464
  this.selectedData = [];
1465
- this.selectedId = [];
1465
+ this.selectedId = this.enablePersistence ? this.selectedId : [];
1466
1466
  this.LISTVIEW_TEMPLATE_ID = "" + this.element.id + LISTVIEW_TEMPLATE_PROPERTY;
1467
1467
  this.LISTVIEW_GROUPTEMPLATE_ID = "" + this.element.id + LISTVIEW_GROUPTEMPLATE_PROPERTY;
1468
1468
  this.LISTVIEW_HEADERTEMPLATE_ID = "" + this.element.id + LISTVIEW_HEADERTEMPLATE_PROPERTY;
@@ -1474,12 +1474,13 @@ var ListView = /** @__PURE__ @class */ (function (_super) {
1474
1474
  this.curUL = this.ulElement = this.liCollection = this.headerEle = this.contentContainer = undefined;
1475
1475
  };
1476
1476
  ListView.prototype.renderCheckbox = function (args) {
1477
+ var _this = this;
1477
1478
  if (args.item.classList.contains(classNames.hasChild)) {
1478
1479
  this.isNestedList = true;
1479
1480
  }
1480
1481
  if (this.showCheckBox && this.isValidLI(args.item)) {
1481
1482
  var checkboxElement = void 0;
1482
- var fieldData = void 0;
1483
+ var fieldData_1;
1483
1484
  // eslint-disable-next-line prefer-const
1484
1485
  checkboxElement = createCheckBox(this.createElement, false, {
1485
1486
  checked: false, enableRtl: this.enableRtl,
@@ -1490,8 +1491,14 @@ var ListView = /** @__PURE__ @class */ (function (_super) {
1490
1491
  args.item.classList.add(classNames.itemCheckList);
1491
1492
  args.item.firstElementChild.classList.add(classNames.checkbox);
1492
1493
  if (typeof this.dataSource[0] !== 'string' && typeof this.dataSource[0] !== 'number') {
1493
- fieldData = getFieldValues(args.curData, this.listBaseOption.fields);
1494
- if (fieldData[this.listBaseOption.fields.isChecked]) {
1494
+ fieldData_1 = getFieldValues(args.curData, this.listBaseOption.fields);
1495
+ if (this.enablePersistence && !isNullOrUndefined(this.selectedId)) {
1496
+ var index = this.selectedId.findIndex(function (e) { return e == fieldData_1[_this.listBaseOption.fields.id].toString(); });
1497
+ if (index != -1) {
1498
+ this.checkInternally(args, checkboxElement);
1499
+ }
1500
+ }
1501
+ else if (fieldData_1[this.listBaseOption.fields.isChecked]) {
1495
1502
  this.checkInternally(args, checkboxElement);
1496
1503
  }
1497
1504
  }
@@ -1556,6 +1563,7 @@ var ListView = /** @__PURE__ @class */ (function (_super) {
1556
1563
  checkboxIcon.parentElement.setAttribute('aria-checked', checked ? 'true' : 'false');
1557
1564
  }
1558
1565
  this.setSelectedItemData(liElement);
1566
+ this.updateSelectedId();
1559
1567
  }
1560
1568
  };
1561
1569
  /**
@@ -1598,6 +1606,7 @@ var ListView = /** @__PURE__ @class */ (function (_super) {
1598
1606
  if (this.enableVirtualization) {
1599
1607
  this.virtualizationModule.checkedItem(checked);
1600
1608
  }
1609
+ this.updateSelectedId();
1601
1610
  }
1602
1611
  };
1603
1612
  ListView.prototype.setCheckbox = function () {
@@ -1713,6 +1722,7 @@ var ListView = /** @__PURE__ @class */ (function (_super) {
1713
1722
  }
1714
1723
  }
1715
1724
  }
1725
+ this.updateSelectedId();
1716
1726
  };
1717
1727
  ListView.prototype.removeElement = function (element) {
1718
1728
  return element && element.parentNode && element.parentNode.removeChild(element);
@@ -1902,6 +1912,7 @@ var ListView = /** @__PURE__ @class */ (function (_super) {
1902
1912
  var eventArgs = this.selectEventData(li, e);
1903
1913
  merge(eventArgs, { isChecked: checkIcon ? checkIcon.classList.contains(classNames.checked) : false });
1904
1914
  this.trigger('select', eventArgs);
1915
+ this.updateSelectedId();
1905
1916
  }
1906
1917
  };
1907
1918
  ListView.prototype.keyActionHandler = function (e) {
@@ -2578,6 +2589,16 @@ var ListView = /** @__PURE__ @class */ (function (_super) {
2578
2589
  }
2579
2590
  return parentId;
2580
2591
  };
2592
+ ListView.prototype.updateSelectedId = function () {
2593
+ this.selectedId = [];
2594
+ var liCollection = this.curUL.getElementsByClassName(classNames.selected);
2595
+ for (var i = 0; i < liCollection.length; i++) {
2596
+ var tempData = this.getItemData(liCollection[i]);
2597
+ if (tempData[this.listBaseOption.fields.id]) {
2598
+ this.selectedId.push(tempData[this.listBaseOption.fields.id]);
2599
+ }
2600
+ }
2601
+ };
2581
2602
  /**
2582
2603
  * Gets the details of the currently selected item from the list items.
2583
2604
  *
@@ -3009,7 +3030,7 @@ var ListView = /** @__PURE__ @class */ (function (_super) {
3009
3030
  ListView.prototype.getPersistData = function () {
3010
3031
  return this.addOnPersist(['cssClass', 'enableRtl', 'htmlAttributes',
3011
3032
  'enable', 'fields', 'animation', 'headerTitle',
3012
- 'sortOrder', 'showIcon', 'height', 'width', 'showCheckBox', 'checkBoxPosition']);
3033
+ 'sortOrder', 'showIcon', 'height', 'width', 'showCheckBox', 'checkBoxPosition', 'selectedId']);
3013
3034
  };
3014
3035
  __decorate([
3015
3036
  Property('')