@syncfusion/ej2-treegrid 34.1.29 → 34.1.30

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.
@@ -1086,6 +1086,20 @@ var Selection = /** @__PURE__ @class */ (function () {
1086
1086
  this.resetSelectionCaches();
1087
1087
  this.removeEventListener();
1088
1088
  };
1089
+ /**
1090
+ * Gets the actual record from the data model's uniqueIDCollection.
1091
+ *
1092
+ * @param {ITreeData} record - The record (may be stale reference).
1093
+ * @returns {ITreeData} The actual record from the data model.
1094
+ */
1095
+ Selection.prototype.getRecordFromUidCollection = function (record) {
1096
+ if (!record) {
1097
+ return record;
1098
+ }
1099
+ var uidMap = this.parent.uniqueIDCollection;
1100
+ var uid = record.uniqueID;
1101
+ return (uidMap && uid != null) ? (uidMap[String(uid)] ? uidMap[String(uid)] : record) : record;
1102
+ };
1089
1103
  /**
1090
1104
  * Handles checkbox click events from the DOM and dispatches selection logic.
1091
1105
  *
@@ -1112,8 +1126,7 @@ var Selection = /** @__PURE__ @class */ (function () {
1112
1126
  }
1113
1127
  else if (checkWrap && checkWrap.querySelectorAll('.e-treeselectall').length > 0 && this.parent.autoCheckHierarchy) {
1114
1128
  var frame = checkWrap.querySelector('.e-frame');
1115
- var currentStateIsUncheck = !frame.classList.contains('e-check') && !frame.classList.contains('e-stop');
1116
- var targetState = currentStateIsUncheck; // If currently uncheck, target state is to check all.
1129
+ var targetState = frame.classList.contains('e-uncheck') || frame.classList.contains('e-stop');
1117
1130
  this.headerSelection(targetState);
1118
1131
  checkBox = checkWrap.querySelector('input[type="checkbox"]');
1119
1132
  this.triggerChkChangeEvent(checkBox, targetState, target.closest('tr'));
@@ -1280,6 +1293,7 @@ var Selection = /** @__PURE__ @class */ (function () {
1280
1293
  var flatRec = getParentData(this.parent, viewRec.uniqueID);
1281
1294
  var nextState = (flatRec.checkboxState === 'check') ? 'uncheck' : 'check';
1282
1295
  flatRec.checkboxState = nextState;
1296
+ viewRec.checkboxState = nextState;
1283
1297
  this.traverSelection(flatRec, nextState, false);
1284
1298
  }
1285
1299
  };
@@ -1331,10 +1345,11 @@ var Selection = /** @__PURE__ @class */ (function () {
1331
1345
  if (child.hasChildRecords) {
1332
1346
  this.traverSelection(child, checkboxState, true);
1333
1347
  }
1334
- if (child.checkboxState === 'check') {
1348
+ var updatedChild = this.getRecordFromUidCollection(child);
1349
+ if (updatedChild.checkboxState === 'check') {
1335
1350
  checkedCount++;
1336
1351
  }
1337
- else if (child.checkboxState === 'indeterminate') {
1352
+ else if (updatedChild.checkboxState === 'indeterminate') {
1338
1353
  indeterminateCount++;
1339
1354
  }
1340
1355
  }
@@ -1458,11 +1473,12 @@ var Selection = /** @__PURE__ @class */ (function () {
1458
1473
  if (!child || child.isSummaryRow) {
1459
1474
  continue;
1460
1475
  }
1476
+ var actualChild = this.getRecordFromUidCollection(child);
1461
1477
  summary.total++;
1462
- if (child.checkboxState === 'check') {
1478
+ if (actualChild.checkboxState === 'check') {
1463
1479
  summary.checked++;
1464
1480
  }
1465
- else if (child.checkboxState === 'indeterminate') {
1481
+ else if (actualChild.checkboxState === 'indeterminate') {
1466
1482
  summary.indeterminate++;
1467
1483
  }
1468
1484
  }
@@ -1590,12 +1606,13 @@ var Selection = /** @__PURE__ @class */ (function () {
1590
1606
  if (!record) {
1591
1607
  continue;
1592
1608
  }
1593
- var previousState = record.checkboxState;
1609
+ var actualRecord = this.getRecordFromUidCollection(record);
1610
+ var previousState = actualRecord.checkboxState;
1594
1611
  if (previousState === targetState) {
1595
1612
  continue;
1596
1613
  }
1597
- record.checkboxState = targetState;
1598
- this.updateSelectedItems(record, targetState, true);
1614
+ actualRecord.checkboxState = targetState;
1615
+ this.updateSelectedItems(actualRecord, targetState, true);
1599
1616
  }
1600
1617
  };
1601
1618
  /**
@@ -1623,9 +1640,10 @@ var Selection = /** @__PURE__ @class */ (function () {
1623
1640
  if (item.hasChildRecords && isFilterOrSearch && item.level === 0 && this.parent.autoCheckHierarchy) {
1624
1641
  this.updateParentSelection(item);
1625
1642
  }
1626
- if (item.uniqueID && item.checkboxState === 'check') {
1627
- newSelectedItems.push(item);
1628
- newSelectedUidMap.set(item.uniqueID, true);
1643
+ var actualItem = this.getRecordFromUidCollection(item);
1644
+ if (actualItem.uniqueID && actualItem.checkboxState === 'check') {
1645
+ newSelectedItems.push(actualItem);
1646
+ newSelectedUidMap.set(actualItem.uniqueID, true);
1629
1647
  }
1630
1648
  }
1631
1649
  if (!isFilterOrSearch) {
@@ -1800,7 +1818,8 @@ var Selection = /** @__PURE__ @class */ (function () {
1800
1818
  var checkedCountForHeaderLogic = 0;
1801
1819
  for (var _i = 0, recordsForHeaderLogic_1 = recordsForHeaderLogic; _i < recordsForHeaderLogic_1.length; _i++) {
1802
1820
  var record = recordsForHeaderLogic_1[_i];
1803
- if (record && !record.isSummaryRow && record.checkboxState === 'check') {
1821
+ var actualRecord = this.getRecordFromUidCollection(record);
1822
+ if (actualRecord && !actualRecord.isSummaryRow && actualRecord.checkboxState === 'check') {
1804
1823
  checkedCountForHeaderLogic++;
1805
1824
  }
1806
1825
  }