@syncfusion/ej2-treegrid 31.2.12 → 32.1.19

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.
Files changed (156) hide show
  1. package/dist/ej2-treegrid.min.js +1 -10
  2. package/dist/ej2-treegrid.umd.min.js +1 -10
  3. package/dist/ej2-treegrid.umd.min.js.map +1 -1
  4. package/dist/es6/ej2-treegrid.es2015.js +1069 -324
  5. package/dist/es6/ej2-treegrid.es2015.js.map +1 -1
  6. package/dist/es6/ej2-treegrid.es5.js +1075 -327
  7. package/dist/es6/ej2-treegrid.es5.js.map +1 -1
  8. package/dist/global/ej2-treegrid.min.js +1 -10
  9. package/dist/global/ej2-treegrid.min.js.map +1 -1
  10. package/dist/global/index.d.ts +0 -9
  11. package/package.json +5 -5
  12. package/src/treegrid/actions/batch-edit.js +22 -4
  13. package/src/treegrid/actions/context-menu.d.ts +1 -0
  14. package/src/treegrid/actions/context-menu.js +16 -0
  15. package/src/treegrid/actions/crud-actions.js +12 -5
  16. package/src/treegrid/actions/edit.d.ts +4 -1
  17. package/src/treegrid/actions/edit.js +59 -3
  18. package/src/treegrid/actions/freeze-column.js +1 -1
  19. package/src/treegrid/actions/rowdragdrop.js +3 -0
  20. package/src/treegrid/actions/selection.d.ts +226 -8
  21. package/src/treegrid/actions/selection.js +759 -288
  22. package/src/treegrid/actions/summary.js +1 -1
  23. package/src/treegrid/actions/virtual-scroll.js +6 -3
  24. package/src/treegrid/base/data.js +2 -1
  25. package/src/treegrid/base/treegrid-model.d.ts +16 -0
  26. package/src/treegrid/base/treegrid.d.ts +50 -4
  27. package/src/treegrid/base/treegrid.js +158 -19
  28. package/src/treegrid/models/column.d.ts +24 -0
  29. package/src/treegrid/models/column.js +12 -0
  30. package/src/treegrid/renderer/virtual-tree-content-render.d.ts +5 -0
  31. package/src/treegrid/renderer/virtual-tree-content-render.js +24 -2
  32. package/styles/bds-lite.scss +17 -18
  33. package/styles/bds.scss +18 -19
  34. package/styles/bootstrap-dark-lite.scss +17 -18
  35. package/styles/bootstrap-dark.scss +18 -19
  36. package/styles/bootstrap-lite.scss +17 -18
  37. package/styles/bootstrap.scss +18 -19
  38. package/styles/bootstrap4-lite.scss +17 -18
  39. package/styles/bootstrap4.scss +18 -19
  40. package/styles/bootstrap5-dark-lite.scss +17 -18
  41. package/styles/bootstrap5-dark.scss +18 -19
  42. package/styles/bootstrap5-lite.scss +18 -18
  43. package/styles/bootstrap5.3-lite.css +81 -1
  44. package/styles/bootstrap5.3-lite.scss +18 -18
  45. package/styles/bootstrap5.3.css +81 -1
  46. package/styles/bootstrap5.3.scss +19 -19
  47. package/styles/bootstrap5.scss +19 -19
  48. package/styles/fabric-dark-lite.scss +18 -18
  49. package/styles/fabric-dark.scss +19 -19
  50. package/styles/fabric-lite.scss +18 -18
  51. package/styles/fabric.scss +19 -19
  52. package/styles/fluent-dark-lite.scss +18 -18
  53. package/styles/fluent-dark.scss +19 -19
  54. package/styles/fluent-lite.scss +18 -18
  55. package/styles/fluent.scss +19 -19
  56. package/styles/fluent2-lite.css +152 -4
  57. package/styles/fluent2-lite.scss +18 -18
  58. package/styles/fluent2.css +152 -4
  59. package/styles/fluent2.scss +19 -19
  60. package/styles/highcontrast-light-lite.scss +18 -18
  61. package/styles/highcontrast-light.scss +19 -19
  62. package/styles/highcontrast-lite.scss +18 -18
  63. package/styles/highcontrast.scss +19 -19
  64. package/styles/material-dark-lite.scss +18 -18
  65. package/styles/material-dark.scss +19 -19
  66. package/styles/material-lite.scss +17 -18
  67. package/styles/material.scss +18 -19
  68. package/styles/material3-dark-lite.css +140 -1
  69. package/styles/material3-dark-lite.scss +18 -18
  70. package/styles/material3-dark.css +140 -1
  71. package/styles/material3-dark.scss +19 -21
  72. package/styles/material3-lite.css +140 -1
  73. package/styles/material3-lite.scss +18 -18
  74. package/styles/material3.css +140 -1
  75. package/styles/material3.scss +19 -21
  76. package/styles/tailwind-dark-lite.scss +18 -18
  77. package/styles/tailwind-dark.scss +19 -19
  78. package/styles/tailwind-lite.scss +18 -18
  79. package/styles/tailwind.scss +19 -19
  80. package/styles/tailwind3-lite.css +119 -1
  81. package/styles/tailwind3-lite.scss +18 -18
  82. package/styles/tailwind3.css +119 -1
  83. package/styles/tailwind3.scss +19 -19
  84. package/styles/treegrid/_all.scss +2 -2
  85. package/styles/treegrid/_bds-definition.scss +2 -0
  86. package/styles/treegrid/_bigger.scss +2 -0
  87. package/styles/treegrid/_bootstrap-dark-definition.scss +2 -0
  88. package/styles/treegrid/_bootstrap-definition.scss +2 -0
  89. package/styles/treegrid/_bootstrap4-definition.scss +2 -0
  90. package/styles/treegrid/_bootstrap5-dark-definition.scss +26 -1
  91. package/styles/treegrid/_bootstrap5-definition.scss +2 -0
  92. package/styles/treegrid/_bootstrap5.3-definition.scss +2 -0
  93. package/styles/treegrid/_fabric-dark-definition.scss +2 -0
  94. package/styles/treegrid/_fabric-definition.scss +2 -0
  95. package/styles/treegrid/_fluent-dark-definition.scss +27 -1
  96. package/styles/treegrid/_fluent-definition.scss +2 -0
  97. package/styles/treegrid/_fluent2-definition.scss +2 -0
  98. package/styles/treegrid/_highcontrast-definition.scss +2 -0
  99. package/styles/treegrid/_highcontrast-light-definition.scss +2 -0
  100. package/styles/treegrid/_layout.scss +5 -2
  101. package/styles/treegrid/_material-dark-definition.scss +2 -0
  102. package/styles/treegrid/_material-definition.scss +2 -0
  103. package/styles/treegrid/_material3-dark-definition.scss +26 -1
  104. package/styles/treegrid/_material3-definition.scss +2 -0
  105. package/styles/treegrid/_tailwind-dark-definition.scss +26 -1
  106. package/styles/treegrid/_tailwind-definition.scss +2 -0
  107. package/styles/treegrid/_tailwind3-definition.scss +2 -0
  108. package/styles/treegrid/_theme-variables.scss +1 -0
  109. package/styles/treegrid/bds.scss +19 -19
  110. package/styles/treegrid/bootstrap-dark.scss +19 -19
  111. package/styles/treegrid/bootstrap.scss +19 -19
  112. package/styles/treegrid/bootstrap4.scss +19 -19
  113. package/styles/treegrid/bootstrap5-dark.scss +19 -19
  114. package/styles/treegrid/bootstrap5.3.css +81 -1
  115. package/styles/treegrid/bootstrap5.3.scss +19 -19
  116. package/styles/treegrid/bootstrap5.scss +19 -19
  117. package/styles/treegrid/fabric-dark.scss +19 -19
  118. package/styles/treegrid/fabric.scss +19 -19
  119. package/styles/treegrid/fluent-dark.scss +19 -19
  120. package/styles/treegrid/fluent.scss +19 -19
  121. package/styles/treegrid/fluent2.css +152 -4
  122. package/styles/treegrid/fluent2.scss +19 -19
  123. package/styles/treegrid/highcontrast-light.scss +19 -19
  124. package/styles/treegrid/highcontrast.scss +19 -19
  125. package/styles/treegrid/icons/_bds.scss +1 -0
  126. package/styles/treegrid/icons/_bootstrap-dark.scss +1 -0
  127. package/styles/treegrid/icons/_bootstrap.scss +1 -0
  128. package/styles/treegrid/icons/_bootstrap4.scss +1 -0
  129. package/styles/treegrid/icons/_bootstrap5-dark.scss +1 -1
  130. package/styles/treegrid/icons/_bootstrap5.3.scss +1 -0
  131. package/styles/treegrid/icons/_bootstrap5.scss +1 -0
  132. package/styles/treegrid/icons/_fabric-dark.scss +1 -0
  133. package/styles/treegrid/icons/_fabric.scss +1 -0
  134. package/styles/treegrid/icons/_fluent-dark.scss +1 -1
  135. package/styles/treegrid/icons/_fluent.scss +1 -0
  136. package/styles/treegrid/icons/_fluent2.scss +1 -0
  137. package/styles/treegrid/icons/_fusionnew.scss +1 -0
  138. package/styles/treegrid/icons/_highcontrast-light.scss +1 -0
  139. package/styles/treegrid/icons/_highcontrast.scss +1 -0
  140. package/styles/treegrid/icons/_material-dark.scss +1 -0
  141. package/styles/treegrid/icons/_material.scss +1 -0
  142. package/styles/treegrid/icons/_material3-dark.scss +1 -1
  143. package/styles/treegrid/icons/_material3.scss +1 -0
  144. package/styles/treegrid/icons/_tailwind-dark.scss +1 -0
  145. package/styles/treegrid/icons/_tailwind.scss +1 -0
  146. package/styles/treegrid/icons/_tailwind3.scss +1 -0
  147. package/styles/treegrid/material-dark.scss +19 -19
  148. package/styles/treegrid/material.scss +19 -19
  149. package/styles/treegrid/material3-dark.css +140 -1
  150. package/styles/treegrid/material3-dark.scss +19 -20
  151. package/styles/treegrid/material3.css +140 -1
  152. package/styles/treegrid/material3.scss +19 -20
  153. package/styles/treegrid/tailwind-dark.scss +19 -19
  154. package/styles/treegrid/tailwind.scss +19 -19
  155. package/styles/treegrid/tailwind3.css +119 -1
  156. package/styles/treegrid/tailwind3.scss +19 -19
@@ -1,4 +1,4 @@
1
- import { Property, merge, ChildProperty, Collection, isNullOrUndefined, Browser, removeClass, addClass, getValue, createElement, setValue, extend as extend$1, Internationalization, getEnumValue, compile, L10n, EventHandler, KeyboardEvents, SanitizeHtmlHelper, Complex, Event, NotifyPropertyChanges, Component, closest, setStyleAttribute, select, classList, debounce, remove } from '@syncfusion/ej2-base';
1
+ import { Property, merge, ChildProperty, Collection, isNullOrUndefined, Browser, removeClass, addClass, getValue, createElement, setValue, extend as extend$1, Internationalization, getEnumValue, compile, Component, L10n, EventHandler, KeyboardEvents, SanitizeHtmlHelper, Complex, Event, NotifyPropertyChanges, closest, setStyleAttribute, select, classList, debounce, remove } from '@syncfusion/ej2-base';
2
2
  import { Grid, Logger as Logger$1, detailLists, Clipboard, getObject, parentsUntil, Print as Print$1, templateCompiler, appendChildren, extend, CellRenderer, getUid, CellType, Freeze as Freeze$1, getNumberFormat, getActualProperties, iterateArrayOrObject, RowDropSettings as RowDropSettings$1, Reorder as Reorder$1, Resize as Resize$1, Scroll, RowDD as RowDD$1, VirtualRowModelGenerator, Filter as Filter$1, Data, ExportHelper, ExcelExport as ExcelExport$1, PdfExport as PdfExport$1, Page as Page$1, Toolbar as Toolbar$1, calculateAggregate, Aggregate as Aggregate$1, Sort as Sort$1, ColumnMenu as ColumnMenu$1, ContextMenu as ContextMenu$1, resetRowIndex, Edit as Edit$1, CommandColumn as CommandColumn$1, DetailRow as DetailRow$1, Cell, getVisiblePage, VirtualContentRenderer, InterSectionObserver, getTransformValues, RenderType, VirtualHeaderRenderer, VirtualScroll as VirtualScroll$1, ColumnChooser as ColumnChooser$1, RowRenderer, InfiniteScroll as InfiniteScroll$1 } from '@syncfusion/ej2-grids';
3
3
  import { createCheckBox } from '@syncfusion/ej2-buttons';
4
4
  import { DataManager, ODataAdaptor, WebApiAdaptor, WebMethodAdaptor, CacheAdaptor, UrlAdaptor, Query, DataUtil, RemoteSaveAdaptor, Deferred, JsonAdaptor, Predicate as Predicate$1 } from '@syncfusion/ej2-data';
@@ -83,6 +83,18 @@ var Column = /** @__PURE__ @class */ (function () {
83
83
  * @default null
84
84
  */
85
85
  this.filter = {};
86
+ /**
87
+ * Allows treegrid to perform row spanning on the specified column.
88
+ *
89
+ * @default true
90
+ */
91
+ this.enableRowSpan = true;
92
+ /**
93
+ * Allows treegrid to perform column spanning on the specified column.
94
+ *
95
+ * @default true
96
+ */
97
+ this.enableColumnSpan = true;
86
98
  merge(this, options);
87
99
  }
88
100
  /**
@@ -991,27 +1003,56 @@ function isHidden(el) {
991
1003
  */
992
1004
  var Selection = /** @__PURE__ @class */ (function () {
993
1005
  /**
994
- * Constructor for Selection module
1006
+ * Creates an instance of Selection.
995
1007
  *
996
- * @param {TreeGrid} parent - Tree Grid instance
1008
+ * @param {TreeGrid} parent - The TreeGrid instance this selection module is associated with.
997
1009
  */
998
1010
  function Selection(parent) {
1011
+ this.headerCheckboxFrameEl = null;
1012
+ this.checkboxColIndexCache = -2;
1013
+ this.parentSelectionCounters = {};
1014
+ this.selectedUidMap = new Map(); // Quick lookup for whether an item is selected
1015
+ this.totalSelectableCount = 0;
1016
+ this.headerSelectionState = 'uncheck';
1017
+ this.checkedItemCount = 0;
1018
+ this.visibleUidIndex = {};
999
1019
  this.parent = parent;
1000
1020
  this.selectedItems = [];
1001
- this.selectedIndexes = [];
1021
+ this.selectedIndexes = []; // Initialize here
1002
1022
  this.filteredList = [];
1003
1023
  this.searchingRecords = [];
1004
1024
  this.addEventListener();
1005
1025
  }
1006
1026
  /**
1007
- * For internal use only - Get the module name.
1027
+ * Gets the module name.
1008
1028
  *
1009
- * @private
1010
- * @returns {string} Returns Selection module name
1029
+ * @returns {string} The name of the module ('selection').
1011
1030
  */
1012
- Selection.prototype.getModuleName = function () {
1013
- return 'selection';
1031
+ Selection.prototype.getModuleName = function () { return 'selection'; };
1032
+ /**
1033
+ * Builds a map from visible record uniqueID to its visible index.
1034
+ * This map is crucial for finding the *current visible index* of a record.
1035
+ *
1036
+ * @returns {void}
1037
+ */
1038
+ Selection.prototype.buildVisibleUidMap = function () {
1039
+ this.visibleUidIndex = {};
1040
+ var view = this.parent.grid.currentViewData;
1041
+ if (!view) {
1042
+ return;
1043
+ }
1044
+ for (var i = 0, len = view.length; i < len; i++) {
1045
+ var rec = view[parseInt(i.toString(), 10)];
1046
+ if (rec && rec.uniqueID) {
1047
+ this.visibleUidIndex[rec.uniqueID] = i; // Map uid -> visible row index
1048
+ }
1049
+ }
1014
1050
  };
1051
+ /**
1052
+ * Adds required event listeners for selection handling.
1053
+ *
1054
+ * @returns {void}
1055
+ */
1015
1056
  Selection.prototype.addEventListener = function () {
1016
1057
  this.parent.on('dataBoundArg', this.headerCheckbox, this);
1017
1058
  this.parent.on('columnCheckbox', this.columnCheckbox, this);
@@ -1019,6 +1060,11 @@ var Selection = /** @__PURE__ @class */ (function () {
1019
1060
  this.parent.grid.on('colgroup-refresh', this.headerCheckbox, this);
1020
1061
  this.parent.on('checkboxSelection', this.checkboxSelection, this);
1021
1062
  };
1063
+ /**
1064
+ * Removes previously added event listeners.
1065
+ *
1066
+ * @returns {void}
1067
+ */
1022
1068
  Selection.prototype.removeEventListener = function () {
1023
1069
  if (this.parent.isDestroyed) {
1024
1070
  return;
@@ -1030,14 +1076,20 @@ var Selection = /** @__PURE__ @class */ (function () {
1030
1076
  this.parent.off('updateGridActions', this.updateGridActions);
1031
1077
  };
1032
1078
  /**
1033
- * To destroy the Selection
1079
+ * Destroys the selection module and clears internal caches.
1034
1080
  *
1035
1081
  * @returns {void}
1036
- * @hidden
1037
1082
  */
1038
1083
  Selection.prototype.destroy = function () {
1084
+ this.resetSelectionCaches();
1039
1085
  this.removeEventListener();
1040
1086
  };
1087
+ /**
1088
+ * Handles checkbox click events from the DOM and dispatches selection logic.
1089
+ *
1090
+ * @param {Object} args - Event args containing the click target.
1091
+ * @returns {void}
1092
+ */
1041
1093
  Selection.prototype.checkboxSelection = function (args) {
1042
1094
  var _a;
1043
1095
  var target = getObject('target', args);
@@ -1046,16 +1098,23 @@ var Selection = /** @__PURE__ @class */ (function () {
1046
1098
  if (checkWrap && checkWrap.querySelectorAll('.e-treecheckselect').length > 0) {
1047
1099
  checkBox = checkWrap.querySelector('input[type="checkbox"]');
1048
1100
  var rowIndex = [];
1049
- rowIndex.push(target.closest('tr').rowIndex);
1101
+ if (this.parent.frozenRows) {
1102
+ rowIndex.push(parseInt(target.closest('tr').getAttribute('aria-rowindex'), 10) - 1);
1103
+ }
1104
+ else {
1105
+ rowIndex.push(target.closest('tr').rowIndex);
1106
+ }
1050
1107
  this.selectCheckboxes(rowIndex);
1051
- this.triggerChkChangeEvent(checkBox, checkBox.nextElementSibling.classList.contains('e-check'), target.closest('tr'));
1108
+ var newCheckState = checkBox.nextElementSibling.classList.contains('e-check');
1109
+ this.triggerChkChangeEvent(checkBox, newCheckState, target.closest('tr'));
1052
1110
  }
1053
1111
  else if (checkWrap && checkWrap.querySelectorAll('.e-treeselectall').length > 0 && this.parent.autoCheckHierarchy) {
1054
- var checkBoxvalue = !checkWrap.querySelector('.e-frame').classList.contains('e-check')
1055
- && !checkWrap.querySelector('.e-frame').classList.contains('e-stop');
1056
- this.headerSelection(checkBoxvalue);
1112
+ var frame = checkWrap.querySelector('.e-frame');
1113
+ var currentStateIsUncheck = !frame.classList.contains('e-check') && !frame.classList.contains('e-stop');
1114
+ var targetState = currentStateIsUncheck; // If currently uncheck, target state is to check all.
1115
+ this.headerSelection(targetState);
1057
1116
  checkBox = checkWrap.querySelector('input[type="checkbox"]');
1058
- this.triggerChkChangeEvent(checkBox, checkBoxvalue, target.closest('tr'));
1117
+ this.triggerChkChangeEvent(checkBox, targetState, target.closest('tr'));
1059
1118
  }
1060
1119
  if (!isNullOrUndefined(this.parent['parentQuery']) && this.parent.selectionSettings.persistSelection
1061
1120
  && this.parent['columnModel'].filter(function (col) { return col.type === 'checkbox'; }).length > 0
@@ -1066,63 +1125,99 @@ var Selection = /** @__PURE__ @class */ (function () {
1066
1125
  }
1067
1126
  }
1068
1127
  };
1128
+ /**
1129
+ * Triggers the checkboxChange event with the appropriate arguments.
1130
+ *
1131
+ * @param {HTMLInputElement} checkBox - The checkbox input element that changed.
1132
+ * @param {boolean} checkState - The new checked state.
1133
+ * @param {HTMLTableRowElement} rowElement - The row element where the change occurred.
1134
+ * @returns {void}
1135
+ */
1069
1136
  Selection.prototype.triggerChkChangeEvent = function (checkBox, checkState, rowElement) {
1070
1137
  var data = this.parent.getCurrentViewRecords()[rowElement.rowIndex];
1071
- var args = { checked: checkState, target: checkBox, rowElement: rowElement,
1138
+ var args = {
1139
+ checked: checkState, target: checkBox, rowElement: rowElement,
1072
1140
  rowData: checkBox.classList.contains('e-treeselectall')
1073
- ? this.parent.getCheckedRecords() : data };
1141
+ ? this.parent.getCheckedRecords() : data
1142
+ };
1074
1143
  this.parent.trigger(checkboxChange, args);
1075
1144
  };
1145
+ /**
1146
+ * Determines the index of the checkbox column in the header.
1147
+ *
1148
+ * @returns {number} The index of the checkbox column, or -1 if not found.
1149
+ */
1076
1150
  Selection.prototype.getCheckboxcolumnIndex = function () {
1151
+ if (this.checkboxColIndexCache !== -2) {
1152
+ return this.checkboxColIndexCache;
1153
+ }
1077
1154
  var mappingUid;
1078
- var columnIndex;
1155
+ var columnIndex = -1;
1079
1156
  var stackedHeader = 'stackedHeader';
1080
1157
  var columnModel = 'columnModel';
1081
1158
  var columns = this.parent["" + stackedHeader] ? this.parent["" + columnModel] : (this.parent.columns);
1082
1159
  for (var col = 0; col < columns.length; col++) {
1083
1160
  if (columns[parseInt(col.toString(), 10)].showCheckbox) {
1084
1161
  mappingUid = columns[parseInt(col.toString(), 10)].uid;
1162
+ break;
1085
1163
  }
1086
1164
  }
1087
- var headerCelllength = this.parent.getHeaderContent().querySelectorAll('.e-headercelldiv').length;
1088
- for (var j = 0; j < headerCelllength; j++) {
1089
- var headercell = this.parent.getHeaderContent().querySelectorAll('.e-headercelldiv')[parseInt(j.toString(), 10)];
1165
+ var headerDivs = this.parent.getHeaderContent().querySelectorAll('.e-headercelldiv');
1166
+ for (var j = 0; j < headerDivs.length; j++) {
1167
+ var headercell = headerDivs[parseInt(j.toString(), 10)];
1090
1168
  if (headercell.getAttribute('data-mappinguid') === mappingUid) {
1091
1169
  columnIndex = j;
1170
+ break;
1092
1171
  }
1093
1172
  }
1094
- return columnIndex;
1173
+ this.checkboxColIndexCache = isNullOrUndefined(columnIndex) ? -1 : columnIndex;
1174
+ return this.checkboxColIndexCache;
1095
1175
  };
1176
+ /**
1177
+ * Renders and initializes the header checkbox element.
1178
+ *
1179
+ * @returns {void}
1180
+ */
1096
1181
  Selection.prototype.headerCheckbox = function () {
1182
+ this.buildVisibleUidMap();
1183
+ this.totalSelectableCount = this.countSelectableRecords(this.resolveHeaderSelectionList(true)); // Use all flatData for initial count
1097
1184
  this.columnIndex = this.getCheckboxcolumnIndex();
1098
- if (this.columnIndex > -1 && this.parent.getHeaderContent().querySelectorAll('.e-treeselectall').length === 0) {
1185
+ if (this.columnIndex > -1) {
1099
1186
  var headerElement = this.parent.getHeaderContent().querySelectorAll('.e-headercelldiv')[this.columnIndex];
1100
- var value = false;
1101
- var rowChkBox = this.parent.createElement('input', { className: 'e-treeselectall', attrs: { 'type': 'checkbox' } });
1102
- var checkWrap = createCheckBox(this.parent.createElement, false, { checked: value, label: ' ' });
1103
- checkWrap.classList.add('e-hierarchycheckbox');
1104
- checkWrap.insertBefore(rowChkBox.cloneNode(), checkWrap.firstChild);
1105
- if (!isNullOrUndefined(headerElement)) {
1106
- headerElement.insertBefore(checkWrap, headerElement.firstChild);
1107
- }
1108
- if (this.parent.autoCheckHierarchy) {
1109
- this.headerSelection();
1187
+ if (headerElement && headerElement.querySelectorAll('.e-treeselectall').length === 0) {
1188
+ var value = false; // Initial state can be false.
1189
+ var rowChkBox = this.parent.createElement('input', { className: 'e-treeselectall', attrs: { 'type': 'checkbox' } });
1190
+ var checkWrap = createCheckBox(this.parent.createElement, false, { checked: value, label: ' ' });
1191
+ checkWrap.classList.add('e-hierarchycheckbox');
1192
+ checkWrap.insertBefore(rowChkBox.cloneNode(), checkWrap.firstChild);
1193
+ if (!isNullOrUndefined(headerElement)) {
1194
+ headerElement.insertBefore(checkWrap, headerElement.firstChild);
1195
+ }
1196
+ this.headerCheckboxFrameEl = checkWrap.querySelector('.e-frame'); // Assign the frame element
1197
+ if (this.parent.autoCheckHierarchy) {
1198
+ this.headerSelection();
1199
+ } // Update header state based on data
1110
1200
  }
1111
- }
1112
- else if (this.columnIndex > -1 && this.parent.getHeaderContent().querySelectorAll('.e-treeselectall').length > 0) {
1113
- var checkWrap = this.parent.getHeaderContent().querySelectorAll('.e-checkbox-wrapper')[0];
1114
- var checkBoxvalue = checkWrap.querySelector('.e-frame').classList.contains('e-check');
1115
- if (this.parent.autoCheckHierarchy && checkBoxvalue) {
1116
- this.headerSelection(checkBoxvalue);
1201
+ else if (headerElement && headerElement.querySelectorAll('.e-treeselectall').length > 0) {
1202
+ this.headerCheckboxFrameEl = headerElement.querySelector('.e-frame');
1203
+ if (this.parent.autoCheckHierarchy) {
1204
+ this.headerSelection();
1205
+ } // Update status based on current selections
1117
1206
  }
1118
1207
  }
1119
1208
  };
1209
+ /**
1210
+ * Renders a checkbox element for a column cell.
1211
+ *
1212
+ * @param {QueryCellInfoEventArgs} args - The QueryCellInfoEventArgs for the cell.
1213
+ * @returns {Element} The rendered checkbox wrapper element.
1214
+ */
1120
1215
  Selection.prototype.renderColumnCheckbox = function (args) {
1121
1216
  var rowChkBox = this.parent.createElement('input', { className: 'e-treecheckselect', attrs: { 'type': 'checkbox', 'aria-label': 'checkbox' } });
1122
1217
  var data = args.data;
1123
1218
  args.cell.classList.add('e-treegridcheckbox');
1124
1219
  args.cell.setAttribute('aria-label', 'checkbox');
1125
- var value = (isNullOrUndefined(data.checkboxState) || data.checkboxState === 'uncheck') ? false : true;
1220
+ var value = (data.checkboxState === 'check');
1126
1221
  var checkWrap = createCheckBox(this.parent.createElement, false, { checked: value, label: ' ' });
1127
1222
  checkWrap.classList.add('e-hierarchycheckbox');
1128
1223
  if (this.parent.allowTextWrap) {
@@ -1133,9 +1228,25 @@ var Selection = /** @__PURE__ @class */ (function () {
1133
1228
  removeClass([checkbox], ['e-check', 'e-stop', 'e-uncheck']);
1134
1229
  checkWrap.querySelector('.e-frame').classList.add('e-stop');
1135
1230
  }
1231
+ else if (data.checkboxState === 'uncheck') {
1232
+ var checkbox = checkWrap.querySelectorAll('.e-frame')[0];
1233
+ removeClass([checkbox], ['e-check', 'e-stop', 'e-uncheck']);
1234
+ checkWrap.querySelector('.e-frame').classList.add('e-uncheck');
1235
+ }
1236
+ else if (data.checkboxState === 'check') {
1237
+ var checkbox = checkWrap.querySelectorAll('.e-frame')[0];
1238
+ removeClass([checkbox], ['e-check', 'e-stop', 'e-uncheck']);
1239
+ checkWrap.querySelector('.e-frame').classList.add('e-check');
1240
+ }
1136
1241
  checkWrap.insertBefore(rowChkBox.cloneNode(), checkWrap.firstChild);
1137
1242
  return checkWrap;
1138
1243
  };
1244
+ /**
1245
+ * Injects the checkbox into a column cell during QueryCellInfo.
1246
+ *
1247
+ * @param {QueryCellInfoEventArgs} container - The cell event args.
1248
+ * @returns {void}
1249
+ */
1139
1250
  Selection.prototype.columnCheckbox = function (container) {
1140
1251
  var checkWrap = this.renderColumnCheckbox(container);
1141
1252
  var containerELe = container.cell.querySelector('.e-treecolumn-container');
@@ -1155,54 +1266,105 @@ var Selection = /** @__PURE__ @class */ (function () {
1155
1266
  container.cell.appendChild(divEle);
1156
1267
  }
1157
1268
  };
1269
+ /**
1270
+ * Selects or toggles checkboxes for the provided row indexes.
1271
+ *
1272
+ * @param {number[]} rowIndexes - Array of row indexes to toggle selection for.
1273
+ * @returns {void}
1274
+ */
1158
1275
  Selection.prototype.selectCheckboxes = function (rowIndexes) {
1159
- if (isNullOrUndefined(rowIndexes)) {
1160
- var error = 'The provided value for the rowIndexes is undefined. Please ensure the rowIndexes contains number.';
1161
- this.parent.trigger(actionFailure, { error: error });
1162
- }
1163
1276
  for (var i = 0; i < rowIndexes.length; i++) {
1164
- var record = this.parent.getCurrentViewRecords()[rowIndexes[parseInt(i.toString(), 10)]];
1165
- var flatRecord = getParentData(this.parent, record.uniqueID);
1166
- record = flatRecord;
1167
- var checkboxState = (record.checkboxState === 'uncheck') ? 'check' : 'uncheck';
1168
- record.checkboxState = checkboxState;
1169
- var keys = Object.keys(record);
1170
- for (var j = 0; j < keys.length; j++) {
1171
- if (Object.prototype.hasOwnProperty.call(flatRecord, keys[parseInt(j.toString(), 10)])) {
1172
- flatRecord[keys[parseInt(j.toString(), 10)]] = record[keys[parseInt(j.toString(), 10)]];
1173
- }
1174
- }
1175
- this.traverSelection(record, checkboxState, false);
1176
- if (this.parent.autoCheckHierarchy) {
1177
- this.headerSelection();
1178
- }
1277
+ var viewRec = this.parent.getCurrentViewRecords()[rowIndexes[parseInt(i.toString(), 10)]];
1278
+ var flatRec = getParentData(this.parent, viewRec.uniqueID);
1279
+ var nextState = (flatRec.checkboxState === 'check') ? 'uncheck' : 'check';
1280
+ flatRec.checkboxState = nextState;
1281
+ this.traverSelection(flatRec, nextState, false);
1179
1282
  }
1180
1283
  };
1181
- Selection.prototype.traverSelection = function (record, checkboxState, ischildItem) {
1182
- var length = 0;
1183
- this.updateSelectedItems(record, checkboxState);
1184
- if (!ischildItem && record.parentItem && this.parent.autoCheckHierarchy) {
1185
- this.updateParentSelection(record.parentItem);
1186
- }
1187
- if (record.childRecords && this.parent.autoCheckHierarchy) {
1188
- var childRecords = record.childRecords;
1189
- if (!isNullOrUndefined(this.parent.filterModule) &&
1190
- this.parent.filterModule.filteredResult.length > 0 && this.parent.autoCheckHierarchy) {
1191
- childRecords = this.getFilteredChildRecords(childRecords);
1192
- }
1193
- length = childRecords.length;
1194
- for (var count = 0; count < length; count++) {
1195
- if (!childRecords[parseInt(count.toString(), 10)].isSummaryRow) {
1196
- if (childRecords[parseInt(count.toString(), 10)].hasChildRecords) {
1197
- this.traverSelection(childRecords[parseInt(count.toString(), 10)], checkboxState, true);
1198
- }
1199
- else {
1200
- this.updateSelectedItems(childRecords[parseInt(count.toString(), 10)], checkboxState);
1201
- }
1284
+ /**
1285
+ * Traverses selection for a record and cascades selections to children/parents as necessary.
1286
+ *
1287
+ * @param {ITreeData} record - The record to process.
1288
+ * @param {string} checkboxState - The desired checkbox state ('check'|'uncheck'|'indeterminate').
1289
+ * @param {boolean} isChildItem - True if this invocation is for a child during recursion.
1290
+ * @returns {void}
1291
+ */
1292
+ Selection.prototype.traverSelection = function (record, checkboxState, isChildItem) {
1293
+ var previousState = record.checkboxState;
1294
+ if (!isChildItem) {
1295
+ this.buildVisibleUidMap();
1296
+ }
1297
+ var effectiveChildren = Array.isArray(record.childRecords) ? record.childRecords : [];
1298
+ if ((!effectiveChildren || effectiveChildren.length === 0) && this.parent.autoCheckHierarchy) {
1299
+ effectiveChildren = this.getChildrenFromFlat(record);
1300
+ }
1301
+ if (this.parent.filterModule && this.parent.filterModule.filteredResult.length > 0
1302
+ && effectiveChildren && effectiveChildren.length) {
1303
+ effectiveChildren = this.getFilteredChildRecords(effectiveChildren);
1304
+ }
1305
+ if (!this.parent.autoCheckHierarchy || !effectiveChildren || effectiveChildren.length === 0) {
1306
+ this.updateSelectedItems(record, checkboxState);
1307
+ if (!isChildItem) {
1308
+ if (record.parentItem && this.parent.autoCheckHierarchy) {
1309
+ this.updateParentSelection(record.parentItem);
1202
1310
  }
1311
+ this.updateSelectedCollectionsAfterBulk(this.resolveHeaderSelectionList(), '');
1312
+ this.refreshVisibleCheckboxes();
1313
+ if (this.parent.autoCheckHierarchy) {
1314
+ this.updateHeaderCheckboxState();
1315
+ }
1316
+ }
1317
+ return;
1318
+ }
1319
+ var childCount = 0;
1320
+ var checkedCount = 0;
1321
+ var indeterminateCount = 0;
1322
+ for (var i = 0; i < effectiveChildren.length; i++) {
1323
+ var child = effectiveChildren[parseInt(i.toString(), 10)];
1324
+ if (!child || child.isSummaryRow) {
1325
+ continue;
1326
+ }
1327
+ childCount++;
1328
+ this.updateSelectedItems(child, checkboxState, true);
1329
+ if (child.hasChildRecords) {
1330
+ this.traverSelection(child, checkboxState, true);
1331
+ }
1332
+ if (child.checkboxState === 'check') {
1333
+ checkedCount++;
1334
+ }
1335
+ else if (child.checkboxState === 'indeterminate') {
1336
+ indeterminateCount++;
1203
1337
  }
1204
1338
  }
1339
+ if (record.uniqueID) {
1340
+ this.parentSelectionCounters[record.uniqueID] = {
1341
+ total: childCount,
1342
+ checked: checkedCount,
1343
+ indeterminate: indeterminateCount
1344
+ };
1345
+ }
1346
+ var summary = this.parentSelectionCounters[record.uniqueID];
1347
+ var finalState = this.deriveParentState(record, summary);
1348
+ if (checkboxState === 'check' && summary.total > 0 && summary.checked === summary.total && summary.indeterminate === 0) {
1349
+ finalState = 'check';
1350
+ }
1351
+ this.updateSelectedItems(record, finalState);
1352
+ if (!isChildItem && record.parentItem && this.parent.autoCheckHierarchy) {
1353
+ this.updateParentSelection(record.parentItem, previousState, finalState);
1354
+ }
1355
+ if (!isChildItem) {
1356
+ var bulkList = this.resolveHeaderSelectionList();
1357
+ this.updateSelectedCollectionsAfterBulk(bulkList, ''); // This will rebuild selectedItems & selectedIndexes based on total state
1358
+ this.refreshVisibleCheckboxes();
1359
+ this.updateHeaderCheckboxState();
1360
+ }
1205
1361
  };
1362
+ /**
1363
+ * Filters provided child records against the current filter result.
1364
+ *
1365
+ * @param {ITreeData[]} childRecords - The array of child records to filter.
1366
+ * @returns {ITreeData[]} The filtered child records array.
1367
+ */
1206
1368
  Selection.prototype.getFilteredChildRecords = function (childRecords) {
1207
1369
  var _this = this;
1208
1370
  var filteredChildRecords = childRecords.filter(function (e) {
@@ -1210,59 +1372,142 @@ var Selection = /** @__PURE__ @class */ (function () {
1210
1372
  });
1211
1373
  return filteredChildRecords;
1212
1374
  };
1213
- Selection.prototype.updateParentSelection = function (parentRecord) {
1214
- var length = 0;
1215
- var childRecords = [];
1216
- var record = getParentData(this.parent, parentRecord.uniqueID);
1217
- if (record && record.childRecords) {
1218
- childRecords = record.childRecords;
1219
- }
1220
- if (!isNullOrUndefined(this.parent.filterModule) &&
1221
- this.parent.filterModule.filteredResult.length > 0 && this.parent.autoCheckHierarchy) {
1222
- childRecords = this.getFilteredChildRecords(childRecords);
1223
- }
1224
- length = childRecords && childRecords.length;
1225
- var indeter = 0;
1226
- var checkChildRecords = 0;
1227
- if (!isNullOrUndefined(record)) {
1228
- for (var i = 0; i < childRecords.length; i++) {
1229
- var currentRecord = getParentData(this.parent, childRecords[parseInt(i.toString(), 10)].uniqueID);
1230
- var checkBoxRecord = currentRecord;
1231
- if (!isNullOrUndefined(checkBoxRecord)) {
1232
- if (checkBoxRecord.checkboxState === 'indeterminate') {
1233
- indeter++;
1234
- }
1235
- else if (checkBoxRecord.checkboxState === 'check') {
1236
- checkChildRecords++;
1237
- }
1238
- }
1239
- }
1240
- if (indeter > 0 || (checkChildRecords > 0 && checkChildRecords !== length)) {
1241
- record.checkboxState = 'indeterminate';
1375
+ /**
1376
+ * Derives children for a record from flatData using the parentItem link.
1377
+ * Used when childRecords is missing or empty.
1378
+ *
1379
+ * @param {ITreeData} record - The record for which to find child elements.
1380
+ * @returns {ITreeData[]} An array of child records derived from flatData.
1381
+ */
1382
+ Selection.prototype.getChildrenFromFlat = function (record) {
1383
+ var all = (this.parent.flatData);
1384
+ if (!all || !record) {
1385
+ return [];
1386
+ }
1387
+ var pid = record.uniqueID;
1388
+ var out = [];
1389
+ for (var i = 0; i < all.length; i++) {
1390
+ var r = all[parseInt(i.toString(), 10)];
1391
+ if (!r || r.isSummaryRow) {
1392
+ continue;
1242
1393
  }
1243
- else if (checkChildRecords === 0 && (!record.hasFilteredChildRecords || isNullOrUndefined(record.hasFilteredChildRecords)) && !isNullOrUndefined(this.parent['dataResults']['actionArgs']) &&
1244
- (this.parent['dataResults']['actionArgs'].requestType === 'searching' || this.parent['dataResults']['actionArgs'].requestType === 'filtering') && record.checkboxState === 'check') {
1245
- record.checkboxState = 'check';
1394
+ var p = r.parentItem;
1395
+ if (p && p.uniqueID === pid) {
1396
+ out.push(r);
1246
1397
  }
1247
- else if ((checkChildRecords === 0 && indeter === 0) || (checkChildRecords === 0 && record.hasFilteredChildRecords && !isNullOrUndefined(this.parent['dataResults']['actionArgs']) &&
1248
- (this.parent['dataResults']['actionArgs'].requestType === 'searching' || this.parent['dataResults']['actionArgs'].requestType === 'filtering') && record.checkboxState === 'check')) {
1249
- record.checkboxState = 'uncheck';
1398
+ }
1399
+ return out;
1400
+ };
1401
+ /**
1402
+ * Updates parent selection by rebuilding summary and applying deltas, then bubbling up if required.
1403
+ *
1404
+ * @param {ITreeData} parentRecord - The parent record reference.
1405
+ * @param {string} [previousChildState] - Previous state of the child that changed.
1406
+ * @param {string} [nextChildState] - Next state of the child that changed.
1407
+ * @returns {void}
1408
+ */
1409
+ Selection.prototype.updateParentSelection = function (parentRecord, previousChildState, nextChildState) {
1410
+ var parent = getParentData(this.parent, parentRecord.uniqueID);
1411
+ if (!parent) {
1412
+ return;
1413
+ }
1414
+ var summary = this.buildSelectionSummary(parent);
1415
+ if (previousChildState) {
1416
+ this.applySummaryDelta(summary, previousChildState, -1);
1417
+ }
1418
+ if (nextChildState) {
1419
+ this.applySummaryDelta(summary, nextChildState, 1);
1420
+ }
1421
+ if (parent.uniqueID) {
1422
+ this.parentSelectionCounters[parent.uniqueID] = summary;
1423
+ }
1424
+ var desiredState = this.deriveParentState(parent, summary);
1425
+ if (parent.checkboxState === desiredState) {
1426
+ return;
1427
+ }
1428
+ var parentPrev = parent.checkboxState;
1429
+ parent.checkboxState = desiredState;
1430
+ this.updateSelectedItems(parent, desiredState);
1431
+ if (parent.parentItem) {
1432
+ this.updateParentSelection(parent.parentItem, parentPrev, desiredState);
1433
+ }
1434
+ };
1435
+ /**
1436
+ * Builds a selection summary for a record's children.
1437
+ *
1438
+ * @param {Object} record - The record whose children should be summarized.
1439
+ * @param {boolean} [ignoreFilter] - If true, ignore current filter when computing summary.
1440
+ * @returns {{ total: number, checked: number, indeterminate: number }} The computed summary.
1441
+ */
1442
+ Selection.prototype.buildSelectionSummary = function (record, ignoreFilter) {
1443
+ var summary = { total: 0, checked: 0, indeterminate: 0 };
1444
+ var children = [];
1445
+ if (record && Array.isArray(record.childRecords) && record.childRecords.length) {
1446
+ children = record.childRecords;
1447
+ }
1448
+ else {
1449
+ children = this.getChildrenFromFlat(record);
1450
+ }
1451
+ if (!ignoreFilter && this.parent.filterModule && this.parent.filterModule.filteredResult.length > 0) {
1452
+ children = this.getFilteredChildRecords(children);
1453
+ }
1454
+ for (var i = 0; i < children.length; i++) {
1455
+ var child = children[parseInt(i.toString(), 10)];
1456
+ if (!child || child.isSummaryRow) {
1457
+ continue;
1250
1458
  }
1251
- else {
1252
- record.checkboxState = 'check';
1459
+ summary.total++;
1460
+ if (child.checkboxState === 'check') {
1461
+ summary.checked++;
1253
1462
  }
1254
- this.updateSelectedItems(record, record.checkboxState);
1255
- if (record.parentItem) {
1256
- this.updateParentSelection(record.parentItem);
1463
+ else if (child.checkboxState === 'indeterminate') {
1464
+ summary.indeterminate++;
1257
1465
  }
1258
1466
  }
1467
+ return summary;
1468
+ };
1469
+ /**
1470
+ * Applies a delta to a selection summary based on a state change.
1471
+ *
1472
+ * @param {Object} summary - The summary to modify. Object with numeric properties: total, checked, indeterminate.
1473
+ * @param {string} state - The state that changed ('check' | 'indeterminate').
1474
+ * @param {number} delta - The delta to apply (e.g. +1 or -1).
1475
+ * @returns {void}
1476
+ */
1477
+ Selection.prototype.applySummaryDelta = function (summary, state, delta) {
1478
+ if (state === 'check') {
1479
+ summary.checked = Math.max(0, summary.checked + delta);
1480
+ }
1481
+ else if (state === 'indeterminate') {
1482
+ summary.indeterminate = Math.max(0, summary.indeterminate + delta);
1483
+ }
1259
1484
  };
1485
+ /**
1486
+ * Derives the parent's checkbox state based on children summary counts.
1487
+ *
1488
+ * @param {ITreeData} record The parent record.
1489
+ * @param {{ total: number, checked: number, indeterminate: number }} summary The children summary.
1490
+ * @returns {'check'|'indeterminate'|'uncheck'} The derived checkbox state.
1491
+ */
1492
+ Selection.prototype.deriveParentState = function (record, summary) {
1493
+ var total = summary.total;
1494
+ var checked = summary.checked;
1495
+ var indeterminate = summary.indeterminate;
1496
+ if (indeterminate > 0 || (checked > 0 && checked !== total)) {
1497
+ return 'indeterminate';
1498
+ }
1499
+ if (checked === total && total > 0) {
1500
+ return 'check';
1501
+ }
1502
+ return 'uncheck';
1503
+ };
1504
+ /**
1505
+ * Handles header checkbox (select all / clear all) behavior.
1506
+ *
1507
+ * @param {boolean} [checkAll] - Optional explicit flag to check or uncheck all.
1508
+ * @returns {void}
1509
+ */
1260
1510
  Selection.prototype.headerSelection = function (checkAll) {
1261
- var _this = this;
1262
- var index = -1;
1263
- var length = 0;
1264
- //This property used to maintain the check state of the currentview data after clear filtering
1265
- var multiFilterCheckState = false;
1266
1511
  if (!isNullOrUndefined(this.parent.filterModule) && this.parent.filterModule.filteredResult.length > 0) {
1267
1512
  var filterResult = this.parent.filterModule.filteredResult;
1268
1513
  if (this.filteredList.length === 0) {
@@ -1272,161 +1517,401 @@ var Selection = /** @__PURE__ @class */ (function () {
1272
1517
  this.searchingRecords = filterResult;
1273
1518
  }
1274
1519
  else {
1275
- if (this.filteredList !== filterResult) {
1520
+ if (this.filteredList !== filterResult && !this.parent.grid.searchSettings.key.length) {
1276
1521
  this.filteredList = filterResult;
1277
- multiFilterCheckState = true;
1278
- }
1279
- else {
1280
- multiFilterCheckState = false;
1522
+ this.searchingRecords = [];
1281
1523
  }
1282
1524
  }
1283
1525
  }
1284
- if (this.filteredList.length > 0) {
1285
- if (!this.parent.filterSettings.columns.length && this.filteredList.length && !this.parent.grid.searchSettings.key.length) {
1286
- this.filteredList = [];
1526
+ if (this.searchingRecords.length > 0 && !isNullOrUndefined(checkAll)) {
1527
+ this.filteredList = this.searchingRecords;
1528
+ }
1529
+ else if (this.filteredList.length > 0 && !this.parent.filterSettings.columns.length
1530
+ && !this.parent.grid.searchSettings.key.length) {
1531
+ this.filteredList = [];
1532
+ }
1533
+ var records = this.resolveHeaderSelectionList(true);
1534
+ if (!isNullOrUndefined(checkAll)) {
1535
+ this.resetSelectionCaches();
1536
+ var targetState = checkAll ? 'check' : 'uncheck';
1537
+ this.headerSelectionState = targetState;
1538
+ this.processHeaderSelection(records, targetState);
1539
+ this.finalizeParentsAfterBulk(records);
1540
+ this.updateSelectedCollectionsAfterBulk(records, '');
1541
+ this.refreshVisibleCheckboxes();
1542
+ this.updateHeaderCheckboxState();
1543
+ return;
1544
+ }
1545
+ this.totalSelectableCount = this.countSelectableRecords(records);
1546
+ this.updateHeaderCheckboxState();
1547
+ };
1548
+ /**
1549
+ * Finalizes parent states after a bulk header operation (e.g., Select All).
1550
+ * This ensures parent states (checked/indeterminate) are correct after cascades.
1551
+ *
1552
+ * @param {ITreeData[]} records - The records that were processed in the bulk operation.
1553
+ * @returns {void}
1554
+ */
1555
+ Selection.prototype.finalizeParentsAfterBulk = function (records) {
1556
+ var all = records;
1557
+ for (var i = 0; i < all.length; i++) {
1558
+ var rec = all[parseInt(i.toString(), 10)];
1559
+ if (!rec || !rec.hasChildRecords) {
1560
+ continue;
1287
1561
  }
1288
- if (this.searchingRecords.length && !isNullOrUndefined(checkAll)) {
1289
- this.filteredList = this.searchingRecords;
1562
+ var summary = this.buildSelectionSummary(rec, true);
1563
+ this.parentSelectionCounters[rec.uniqueID] = summary;
1564
+ var finalState = this.deriveParentState(rec, summary);
1565
+ if (this.headerSelectionState === 'check' &&
1566
+ summary.total > 0 && summary.checked === summary.total && summary.indeterminate === 0) {
1567
+ finalState = 'check';
1568
+ }
1569
+ else if (this.headerSelectionState === 'uncheck') {
1570
+ finalState = 'uncheck';
1571
+ }
1572
+ if (rec.checkboxState !== finalState) {
1573
+ this.updateSelectedItems(rec, finalState);
1290
1574
  }
1291
1575
  }
1292
- var data;
1293
- if (!(isNullOrUndefined(this.parent.filterModule)) &&
1294
- this.parent.filterModule.filteredResult.length === 0 && this.parent.getCurrentViewRecords().length === 0 &&
1295
- this.parent.filterSettings.columns.length > 0) {
1296
- data = this.filteredList;
1297
- }
1298
- else {
1299
- data = (!isNullOrUndefined(this.parent.filterModule) &&
1300
- (this.filteredList.length > 0)) ? this.filteredList : this.parent.flatData;
1576
+ };
1577
+ /**
1578
+ * Processes header selection for each record, setting their state silently in the data model.
1579
+ * Called during bulk operations like "select all".
1580
+ *
1581
+ * @param {ITreeData[]} records - The records to process.
1582
+ * @param {string} targetState - The target state to set on each record.
1583
+ * @returns {void}
1584
+ */
1585
+ Selection.prototype.processHeaderSelection = function (records, targetState) {
1586
+ for (var i = 0; i < records.length; i++) {
1587
+ var record = records[parseInt(i.toString(), 10)];
1588
+ if (!record) {
1589
+ continue;
1590
+ }
1591
+ var previousState = record.checkboxState;
1592
+ if (previousState === targetState) {
1593
+ continue;
1594
+ }
1595
+ record.checkboxState = targetState;
1596
+ this.updateSelectedItems(record, targetState, true);
1301
1597
  }
1302
- data = isRemoteData(this.parent) ? this.parent.getCurrentViewRecords() : data;
1303
- if (!isNullOrUndefined(checkAll)) {
1304
- for (var i = 0; i < data.length; i++) {
1305
- if (checkAll) {
1306
- if (data[parseInt(i.toString(), 10)].checkboxState === 'check') {
1598
+ };
1599
+ /**
1600
+ * Rebuilds `selectedItems`, `selectedUidMap`, and `selectedIndexes` based on the current data states in the model.
1601
+ * This method is called after bulk operations (like headerSelection, grid actions, etc.) to synchronize internal collections.
1602
+ * It ensures `selectedItems` retains original selection order *as much as possible* for currently checked items
1603
+ * and `selectedIndexes` reflects their *current visible order*.
1604
+ *
1605
+ * @param {ITreeData[]} records - The records that were processed (or the full data set if re-evaluating everything).
1606
+ * @param {string} requestType - The data action type such as filtering, searching, refresh,etc.
1607
+ * @returns {void}
1608
+ */
1609
+ Selection.prototype.updateSelectedCollectionsAfterBulk = function (records, requestType) {
1610
+ var hasFilter = !!(this.parent.filterModule && this.parent.filterModule.filteredResult &&
1611
+ this.parent.filterModule.filteredResult.length);
1612
+ var hasSearch = !!(this.parent.grid && this.parent.grid.searchSettings &&
1613
+ this.parent.grid.searchSettings.key && this.parent.grid.searchSettings.key.length);
1614
+ var isFilterOrSearch = hasFilter || hasSearch || requestType === 'refresh' || requestType === 'searching';
1615
+ var currentlySelectedItemsInOrder = isFilterOrSearch ? records : this.selectedItems.slice();
1616
+ var newSelectedItems = [];
1617
+ var newSelectedUidMap = new Map();
1618
+ var newSelectedIndexes = [];
1619
+ for (var _i = 0, currentlySelectedItemsInOrder_1 = currentlySelectedItemsInOrder; _i < currentlySelectedItemsInOrder_1.length; _i++) {
1620
+ var item = currentlySelectedItemsInOrder_1[_i];
1621
+ if (item.hasChildRecords && isFilterOrSearch && item.level === 0) {
1622
+ this.updateParentSelection(item);
1623
+ }
1624
+ if (item.uniqueID && item.checkboxState === 'check') {
1625
+ newSelectedItems.push(item);
1626
+ newSelectedUidMap.set(item.uniqueID, true);
1627
+ }
1628
+ }
1629
+ if (!isFilterOrSearch) {
1630
+ var allFlatData = this.parent.flatData;
1631
+ if (allFlatData) {
1632
+ for (var _a = 0, allFlatData_1 = allFlatData; _a < allFlatData_1.length; _a++) {
1633
+ var record = allFlatData_1[_a];
1634
+ if (!record || record.isSummaryRow) {
1307
1635
  continue;
1308
1636
  }
1309
- if (multiFilterCheckState) {
1310
- continue;
1637
+ if (record.uniqueID && record.checkboxState === 'check' && !newSelectedUidMap.has(record.uniqueID)) {
1638
+ newSelectedItems.push(record);
1639
+ newSelectedUidMap.set(record.uniqueID, true);
1311
1640
  }
1312
- data[parseInt(i.toString(), 10)].checkboxState = 'check';
1313
- this.updateSelectedItems(data[parseInt(i.toString(), 10)], data[parseInt(i.toString(), 10)].checkboxState);
1314
1641
  }
1315
- else {
1316
- index = this.selectedItems.indexOf(data[parseInt(i.toString(), 10)]);
1317
- if (index > -1) {
1318
- data[parseInt(i.toString(), 10)].checkboxState = 'uncheck';
1319
- this.updateSelectedItems(data[parseInt(i.toString(), 10)], data[parseInt(i.toString(), 10)].checkboxState);
1320
- if (this.parent.autoCheckHierarchy) {
1321
- this.updateParentSelection(data[parseInt(i.toString(), 10)]);
1322
- }
1642
+ }
1643
+ }
1644
+ this.selectedItems = newSelectedItems;
1645
+ this.selectedUidMap = newSelectedUidMap;
1646
+ this.buildVisibleUidMap();
1647
+ for (var _b = 0, _c = this.selectedItems; _b < _c.length; _b++) {
1648
+ var item = _c[_b];
1649
+ var visibleIdx = this.visibleUidIndex[item.uniqueID];
1650
+ if (visibleIdx !== undefined) {
1651
+ newSelectedIndexes.push(visibleIdx);
1652
+ }
1653
+ }
1654
+ this.selectedIndexes = newSelectedIndexes;
1655
+ this.checkedItemCount = this.selectedItems.length;
1656
+ this.totalSelectableCount =
1657
+ this.countSelectableRecords(records);
1658
+ };
1659
+ /**
1660
+ * Refreshes visible checkbox DOM elements to reflect the current data state.
1661
+ * This method exclusively updates the UI representation of checkboxes.
1662
+ *
1663
+ * @returns {void}
1664
+ */
1665
+ Selection.prototype.refreshVisibleCheckboxes = function () {
1666
+ this.buildVisibleUidMap();
1667
+ var data = this.parent.getCurrentViewRecords();
1668
+ var uidMap = this.parent.uniqueIDCollection;
1669
+ for (var i = 0; data && i < data.length; i++) {
1670
+ var viewRec = data[parseInt(i.toString(), 10)];
1671
+ if (!viewRec) {
1672
+ continue;
1673
+ }
1674
+ var uid = viewRec.uniqueID;
1675
+ var srcRec = (uidMap && uid != null) ? uidMap[String(uid)] : viewRec;
1676
+ var state = (srcRec && srcRec.checkboxState) ? srcRec.checkboxState : 'uncheck';
1677
+ var rowEl = null;
1678
+ var rowUid = viewRec.uid;
1679
+ if (rowUid) {
1680
+ rowEl = this.parent.grid.getRowElementByUID(rowUid);
1681
+ }
1682
+ if (!rowEl) {
1683
+ var rows = this.parent.getRows();
1684
+ rowEl = rows && rows[parseInt(i.toString(), 10)];
1685
+ if ((this.parent.frozenRows || this.parent.getFrozenColumns()) && !rowEl) {
1686
+ var movableRows = this.parent.getDataRows();
1687
+ rowEl = movableRows && movableRows[parseInt(i.toString(), 10)];
1688
+ }
1689
+ }
1690
+ if (rowEl) {
1691
+ var frame = rowEl.querySelector('.e-hierarchycheckbox .e-frame');
1692
+ if (frame) {
1693
+ removeClass([frame], ['e-check', 'e-stop', 'e-uncheck']);
1694
+ frame.classList.add(state === 'indeterminate' ? 'e-stop' : ('e-' + state));
1695
+ var input = rowEl.querySelector('.e-treecheckselect');
1696
+ if (input) {
1697
+ input.setAttribute('aria-checked', state === 'check' ? 'true' :
1698
+ (state === 'uncheck' ? 'false' : 'mixed'));
1323
1699
  }
1324
1700
  }
1325
1701
  }
1326
1702
  }
1327
- if (checkAll === false && this.parent.enableVirtualization) {
1328
- this.selectedItems = [];
1329
- this.selectedIndexes = [];
1330
- data.filter(function (rec) {
1331
- rec.checkboxState = 'uncheck';
1332
- _this.updateSelectedItems(rec, rec.checkboxState);
1333
- });
1703
+ };
1704
+ /**
1705
+ * Resets internal selection caches to their initial state.
1706
+ * This is usually called before a bulk selection operation (like "select all").
1707
+ *
1708
+ * @returns {void}
1709
+ */
1710
+ Selection.prototype.resetSelectionCaches = function () {
1711
+ this.parentSelectionCounters = {};
1712
+ this.selectedUidMap = new Map();
1713
+ this.selectedItems = [];
1714
+ this.selectedIndexes = [];
1715
+ this.totalSelectableCount = 0;
1716
+ this.headerSelectionState = 'uncheck';
1717
+ this.checkedItemCount = 0;
1718
+ };
1719
+ /**
1720
+ * Counts selectable (non-summary) records in the provided array.
1721
+ *
1722
+ * @param {ITreeData[]} records - The records to count.
1723
+ * @returns {number} The number of selectable records.
1724
+ */
1725
+ Selection.prototype.countSelectableRecords = function (records) {
1726
+ var count = 0;
1727
+ if (!records) {
1728
+ return count;
1334
1729
  }
1335
- length = this.selectedItems.length;
1336
- var checkbox = this.parent.getHeaderContent().querySelectorAll('.e-frame')[0];
1337
- if (length > 0 && data.length > 0) {
1338
- if (length !== data.length && !checkAll) {
1339
- removeClass([checkbox], ['e-check']);
1340
- checkbox.classList.add('e-stop');
1730
+ for (var i = 0; i < records.length; i++) {
1731
+ var rec = records[parseInt(i.toString(), 10)];
1732
+ if (rec && !rec.isSummaryRow) {
1733
+ count++;
1734
+ }
1735
+ }
1736
+ return count;
1737
+ };
1738
+ /**
1739
+ * Resolves the list of records used for header selection operations (e.g., for `select all`).
1740
+ *
1741
+ * @param {boolean} [includeAll] - If true and data is local, returns flatData (all records for full dataset actions).
1742
+ * @returns {ITreeData[]} The array of records to consider for header operations.
1743
+ */
1744
+ Selection.prototype.resolveHeaderSelectionList = function (includeAll) {
1745
+ var dataToProcess = [];
1746
+ if (!isRemoteData(this.parent)) {
1747
+ var hasFilter = !!(this.parent.filterModule &&
1748
+ this.parent.filterModule.filteredResult &&
1749
+ this.parent.filterModule.filteredResult.length);
1750
+ var hasSearch = !!(this.parent.grid &&
1751
+ this.parent.grid.searchSettings &&
1752
+ this.parent.grid.searchSettings.key &&
1753
+ this.parent.grid.searchSettings.key.length);
1754
+ if (includeAll) {
1755
+ if (hasFilter) {
1756
+ dataToProcess = this.filteredList && this.filteredList.length
1757
+ ? this.filteredList
1758
+ : this.parent.filterModule.filteredResult;
1759
+ }
1760
+ else if (hasSearch && this.searchingRecords && this.searchingRecords.length) {
1761
+ dataToProcess = this.searchingRecords;
1762
+ }
1763
+ else {
1764
+ dataToProcess = this.parent.flatData;
1765
+ }
1341
1766
  }
1342
1767
  else {
1343
- removeClass([checkbox], ['e-stop']);
1344
- checkbox.classList.add('e-check');
1768
+ if (hasFilter) {
1769
+ dataToProcess = this.filteredList && this.filteredList.length
1770
+ ? this.filteredList
1771
+ : this.parent.filterModule.filteredResult;
1772
+ }
1773
+ else if (hasSearch && this.searchingRecords && this.searchingRecords.length) {
1774
+ dataToProcess = this.searchingRecords;
1775
+ }
1776
+ else {
1777
+ dataToProcess = this.parent.flatData;
1778
+ }
1345
1779
  }
1346
1780
  }
1347
1781
  else {
1348
- removeClass([checkbox], ['e-check', 'e-stop']);
1782
+ dataToProcess = this.parent.getCurrentViewRecords();
1349
1783
  }
1784
+ return dataToProcess;
1350
1785
  };
1351
- Selection.prototype.updateSelectedItems = function (currentRecord, checkState) {
1352
- var record = this.parent.grid.currentViewData.filter(function (e) {
1353
- return e.uniqueID === currentRecord.uniqueID;
1354
- });
1355
- var checkedRecord;
1356
- var recordIndex = this.parent.grid.currentViewData.indexOf(record[0]);
1357
- var checkboxRecord = getParentData(this.parent, currentRecord.uniqueID);
1358
- var tr = this.parent.getRows()[parseInt(recordIndex.toString(), 10)];
1359
- var checkbox;
1360
- if (recordIndex > -1) {
1361
- var movableTr = void 0;
1362
- if (this.parent.frozenRows || this.parent.getFrozenColumns()) {
1363
- movableTr = this.parent.getDataRows()[parseInt(recordIndex.toString(), 10)];
1364
- }
1365
- checkbox = tr.querySelectorAll('.e-hierarchycheckbox .e-frame')[0] ? tr.querySelectorAll('.e-hierarchycheckbox .e-frame')[0]
1366
- : movableTr.querySelectorAll('.e-hierarchycheckbox .e-frame')[0];
1367
- if (!isNullOrUndefined(checkbox)) {
1368
- removeClass([checkbox], ['e-check', 'e-stop', 'e-uncheck']);
1786
+ /**
1787
+ * Updates the header checkbox state (checked/indeterminate/unchecked) based on current selections.
1788
+ *
1789
+ * @returns {void}
1790
+ */
1791
+ Selection.prototype.updateHeaderCheckboxState = function () {
1792
+ var frame = this.headerCheckboxFrameEl;
1793
+ if (!frame) {
1794
+ return;
1795
+ }
1796
+ var recordsForHeaderLogic = this.resolveHeaderSelectionList(true);
1797
+ this.totalSelectableCount = this.countSelectableRecords(recordsForHeaderLogic);
1798
+ var checkedCountForHeaderLogic = 0;
1799
+ for (var _i = 0, recordsForHeaderLogic_1 = recordsForHeaderLogic; _i < recordsForHeaderLogic_1.length; _i++) {
1800
+ var record = recordsForHeaderLogic_1[_i];
1801
+ if (record && !record.isSummaryRow && record.checkboxState === 'check') {
1802
+ checkedCountForHeaderLogic++;
1369
1803
  }
1370
1804
  }
1371
- checkedRecord = checkboxRecord;
1372
- if (isNullOrUndefined(checkedRecord)) {
1373
- checkedRecord = currentRecord;
1805
+ removeClass([frame], ['e-check', 'e-stop', 'e-uncheck']);
1806
+ if (this.totalSelectableCount === 0) {
1807
+ frame.classList.add('e-uncheck');
1374
1808
  }
1375
- checkedRecord.checkboxState = checkState;
1376
- if (checkState === 'check' && isNullOrUndefined(currentRecord.isSummaryRow)) {
1377
- if (recordIndex !== -1 && this.selectedIndexes.indexOf(recordIndex) === -1) {
1378
- this.selectedIndexes.push(recordIndex);
1379
- }
1380
- if (this.selectedItems.indexOf(checkedRecord) === -1 && (recordIndex !== -1 &&
1381
- (!isNullOrUndefined(this.parent.filterModule) && this.parent.filterModule.filteredResult.length > 0))) {
1382
- this.selectedItems.push(checkedRecord);
1383
- }
1384
- if (this.selectedItems.indexOf(checkedRecord) === -1 && (this.parent.enableVirtualization || this.parent.allowPaging) && ((!isNullOrUndefined(this.parent.filterModule) && this.parent.filterModule.filteredResult.length > 0))) {
1385
- this.selectedItems.push(checkedRecord);
1386
- }
1387
- if (this.selectedItems.indexOf(checkedRecord) === -1 && (!isNullOrUndefined(this.parent.filterModule) &&
1388
- this.parent.filterModule.filteredResult.length === 0)) {
1389
- this.selectedItems.push(checkedRecord);
1809
+ else if (checkedCountForHeaderLogic === 0) {
1810
+ frame.classList.add('e-uncheck');
1811
+ }
1812
+ else if (checkedCountForHeaderLogic === this.totalSelectableCount) {
1813
+ frame.classList.add('e-check');
1814
+ }
1815
+ else {
1816
+ frame.classList.add('e-stop');
1817
+ }
1818
+ };
1819
+ /**
1820
+ * Updates selection arrays (selectedItems, selectedUidMap, selectedIndexes) and visible DOM for a single record.
1821
+ * This is the core method for managing the state of a single checkbox.
1822
+ *
1823
+ * @param {ITreeData} currentRecord - The record to update.
1824
+ * @param {string} checkState - The new checkbox state ('check' | 'uncheck' | 'indeterminate').
1825
+ * @param {boolean} [silent] - If true, update is silent (only updates data model, no collection management or DOM update).
1826
+ * @returns {void}
1827
+ */
1828
+ Selection.prototype.updateSelectedItems = function (currentRecord, checkState, silent) {
1829
+ this.buildVisibleUidMap();
1830
+ var uid = currentRecord.uniqueID;
1831
+ var uidMap = this.parent.uniqueIDCollection;
1832
+ var checkboxRecord = (uidMap && uid != null) ? (uidMap[String(uid)] ?
1833
+ uidMap[String(uid)] : currentRecord) : currentRecord;
1834
+ var isSummary = currentRecord.isSummaryRow === true;
1835
+ var previousState = checkboxRecord.checkboxState;
1836
+ var currentVisibleIndex = this.visibleUidIndex[String(uid)];
1837
+ checkboxRecord.checkboxState = checkState;
1838
+ if (silent) {
1839
+ return;
1840
+ }
1841
+ if (!isSummary && previousState !== checkState) {
1842
+ if (checkState === 'check') {
1843
+ this.checkedItemCount++;
1844
+ if (!this.selectedUidMap.has(String(uid))) {
1845
+ if (checkboxRecord.uniqueID) {
1846
+ this.selectedUidMap.set(String(checkboxRecord.uniqueID), true);
1847
+ }
1848
+ this.selectedItems.push(checkboxRecord);
1849
+ if (currentVisibleIndex !== undefined && this.selectedIndexes.indexOf(currentVisibleIndex) === -1) {
1850
+ this.selectedIndexes.push(currentVisibleIndex);
1851
+ }
1852
+ }
1390
1853
  }
1391
- if (this.selectedItems.indexOf(checkedRecord) === -1 && isNullOrUndefined(this.parent.filterModule)) {
1392
- this.selectedItems.push(checkedRecord);
1854
+ else if (previousState === 'check' || previousState === 'indeterminate') {
1855
+ if (this.checkedItemCount > 0) {
1856
+ this.checkedItemCount--;
1857
+ }
1858
+ if (checkboxRecord && checkboxRecord.uniqueID && this.selectedUidMap.has(String(checkboxRecord.uniqueID))) {
1859
+ this.selectedUidMap.delete(String(checkboxRecord.uniqueID));
1860
+ var itemIdx = this.selectedItems.indexOf(checkboxRecord);
1861
+ if (itemIdx !== -1) {
1862
+ this.selectedItems.splice(itemIdx, 1);
1863
+ }
1864
+ if (currentVisibleIndex !== undefined) {
1865
+ var indexInSelectedIndexes = this.selectedIndexes.indexOf(currentVisibleIndex);
1866
+ if (indexInSelectedIndexes > -1) {
1867
+ this.selectedIndexes.splice(indexInSelectedIndexes, 1);
1868
+ }
1869
+ }
1870
+ }
1393
1871
  }
1394
1872
  }
1395
- else if ((checkState === 'uncheck' || checkState === 'indeterminate') && isNullOrUndefined(currentRecord.isSummaryRow)) {
1396
- var index = this.selectedItems.indexOf(checkedRecord);
1397
- if (index !== -1) {
1398
- this.selectedItems.splice(index, 1);
1399
- }
1400
- if (this.selectedIndexes.indexOf(recordIndex) !== -1) {
1401
- var checkedIndex = this.selectedIndexes.indexOf(recordIndex);
1402
- this.selectedIndexes.splice(checkedIndex, 1);
1873
+ var rowEl = null;
1874
+ var rowUid = currentRecord.uid;
1875
+ if (rowUid) {
1876
+ rowEl = this.parent.grid.getRowElementByUID(rowUid);
1877
+ }
1878
+ if (!rowEl) {
1879
+ var recordVisibleIndex = currentVisibleIndex !== undefined ? currentVisibleIndex : (typeof this.visibleUidIndex[String(uid)] === 'number' ? this.visibleUidIndex[String(uid)] : -1);
1880
+ if (recordVisibleIndex > -1) {
1881
+ rowEl = this.parent.getRows()[parseInt(recordVisibleIndex.toString(), 10)];
1882
+ if (!rowEl && (this.parent.frozenRows || this.parent.getFrozenColumns())) {
1883
+ rowEl = this.parent.getDataRows()[parseInt(recordVisibleIndex.toString(), 10)];
1884
+ }
1403
1885
  }
1404
1886
  }
1405
- var checkBoxclass = checkState === 'indeterminate' ? 'e-stop' : 'e-' + checkState;
1406
- if (recordIndex > -1) {
1407
- if (!isNullOrUndefined(checkbox)) {
1408
- checkbox.classList.add(checkBoxclass);
1409
- tr.querySelector('.e-treecheckselect').setAttribute('aria-checked', checkState === 'check' ? 'true' : checkState === 'uncheck' ? 'false' : 'mixed');
1887
+ if (rowEl) {
1888
+ var frame = rowEl.querySelector('.e-hierarchycheckbox .e-frame');
1889
+ if (frame) {
1890
+ removeClass([frame], ['e-check', 'e-stop', 'e-uncheck']);
1891
+ frame.classList.add(checkState === 'indeterminate' ? 'e-stop' : ('e-' + checkState));
1892
+ }
1893
+ var input = rowEl.querySelector('.e-treecheckselect');
1894
+ if (input) {
1895
+ input.setAttribute('aria-checked', checkState === 'check' ? 'true' :
1896
+ (checkState === 'uncheck' ? 'false' : 'mixed'));
1410
1897
  }
1411
1898
  }
1412
1899
  };
1900
+ /**
1901
+ * Handles various grid actions and updates selection state accordingly.
1902
+ * This method ensures that selection state is maintained and UI is refreshed after grid operations.
1903
+ *
1904
+ * @param {CellSaveEventArgs} args - Action arguments containing requestType and data.
1905
+ * @returns {void}
1906
+ */
1413
1907
  Selection.prototype.updateGridActions = function (args) {
1414
- var _this = this;
1415
1908
  var requestType = args.requestType;
1416
- var childData;
1417
- var childLength;
1418
1909
  if (isCheckboxcolumn(this.parent)) {
1419
1910
  if (this.parent.autoCheckHierarchy) {
1420
1911
  if ((requestType === 'sorting' || requestType === 'paging')) {
1421
- var rows = this.parent.grid.getRows();
1422
- childData = this.parent.getCurrentViewRecords();
1423
- childLength = childData.length;
1424
- this.selectedIndexes = [];
1425
- for (var i = 0; i < childLength; i++) {
1426
- if (!rows[parseInt(i.toString(), 10)].classList.contains('e-summaryrow')) {
1427
- this.updateSelectedItems(childData[parseInt(i.toString(), 10)], childData[parseInt(i.toString(), 10)].checkboxState);
1428
- }
1429
- }
1912
+ this.updateSelectedCollectionsAfterBulk(this.resolveHeaderSelectionList(), '');
1913
+ this.refreshVisibleCheckboxes();
1914
+ this.updateHeaderCheckboxState();
1430
1915
  }
1431
1916
  else if (requestType === 'delete' || args.action === 'add') {
1432
1917
  var updatedData = [];
@@ -1438,71 +1923,69 @@ var Selection = /** @__PURE__ @class */ (function () {
1438
1923
  }
1439
1924
  for (var i = 0; i < updatedData.length; i++) {
1440
1925
  if (requestType === 'delete') {
1441
- var index = this.parent.flatData.indexOf(updatedData[parseInt(i.toString(), 10)]);
1442
- var checkedIndex = this.selectedIndexes.indexOf(index);
1443
- this.selectedIndexes.splice(checkedIndex, 1);
1444
- this.updateSelectedItems(updatedData[parseInt(i.toString(), 10)], 'uncheck');
1926
+ this.updateSelectedItems(updatedData[parseInt(i.toString(), 10)], 'uncheck', false);
1445
1927
  }
1446
1928
  if (!isNullOrUndefined(updatedData[parseInt(i.toString(), 10)].parentItem)) {
1447
1929
  this.updateParentSelection(updatedData[parseInt(i.toString(), 10)].parentItem);
1448
1930
  }
1449
1931
  }
1932
+ this.updateSelectedCollectionsAfterBulk(this.resolveHeaderSelectionList(true), '');
1933
+ this.refreshVisibleCheckboxes();
1934
+ if (this.parent.autoCheckHierarchy) {
1935
+ this.updateHeaderCheckboxState();
1936
+ }
1450
1937
  }
1451
1938
  else if (args.requestType === 'add' && this.parent.autoCheckHierarchy) {
1452
1939
  args.data.checkboxState = 'uncheck';
1453
1940
  }
1454
- else if (requestType === 'filtering' || requestType === 'searching' || requestType === 'refresh'
1455
- && !isRemoteData(this.parent)) {
1456
- this.selectedItems = [];
1457
- this.selectedIndexes = [];
1458
- childData = (!isNullOrUndefined(this.parent.filterModule) && this.parent.filterModule.filteredResult.length > 0) ?
1459
- this.parent.filterModule.filteredResult : this.parent.flatData;
1460
- childData.forEach(function (record) {
1461
- if (_this.parent.enableVirtualization) {
1462
- if (record.hasChildRecords && record.childRecords.length > 0) {
1463
- _this.updateParentSelection(record);
1464
- }
1465
- else {
1466
- _this.updateSelectedItems(record, record.checkboxState);
1467
- }
1468
- var child = findChildrenRecords(record);
1469
- child = _this.getFilteredChildRecords(child);
1470
- for (var i = 0; i < child.length; i++) {
1471
- if (child[parseInt(i.toString(), 10)].hasChildRecords) {
1472
- _this.updateParentSelection(child[parseInt(i.toString(), 10)]);
1473
- }
1474
- else if (!(child[parseInt(i.toString(), 10)].hasChildRecords) &&
1475
- !isNullOrUndefined(child[parseInt(i.toString(), 10)])) {
1476
- _this.updateSelectedItems(child[parseInt(i.toString(), 10)], child[parseInt(i.toString(), 10)].checkboxState);
1477
- }
1478
- }
1479
- }
1480
- else {
1481
- if (record.hasChildRecords) {
1482
- _this.updateParentSelection(record);
1483
- }
1484
- else {
1485
- _this.updateSelectedItems(record, record.checkboxState);
1486
- }
1487
- }
1488
- });
1489
- this.headerSelection();
1941
+ else if (requestType === 'filtering' || requestType === 'searching' || requestType === 'refresh') {
1942
+ this.updateSelectedCollectionsAfterBulk(this.resolveHeaderSelectionList(), requestType);
1943
+ this.refreshVisibleCheckboxes();
1944
+ if (this.parent.autoCheckHierarchy) {
1945
+ this.updateHeaderCheckboxState();
1946
+ }
1490
1947
  }
1491
1948
  }
1492
1949
  else {
1493
- if ((requestType === 'filtering' || requestType === 'searching' || requestType === 'refresh')
1494
- && !isRemoteData(this.parent)) {
1950
+ if ((requestType === 'filtering' || requestType === 'searching' || requestType === 'refresh' ||
1951
+ requestType === 'sorting' || requestType === 'paging' || requestType === 'expanding' ||
1952
+ requestType === 'expand' || requestType === 'collapsing' || requestType === 'collapse') && !isRemoteData(this.parent)) {
1495
1953
  this.selectedItems = [];
1954
+ this.selectedUidMap = new Map();
1496
1955
  this.selectedIndexes = [];
1956
+ this.refreshVisibleCheckboxes();
1957
+ if (this.parent.autoCheckHierarchy) {
1958
+ this.updateHeaderCheckboxState();
1959
+ }
1497
1960
  }
1498
1961
  }
1499
1962
  }
1500
1963
  };
1501
- Selection.prototype.getCheckedrecords = function () {
1502
- return this.selectedItems;
1503
- };
1964
+ /**
1965
+ * Retrieves checked record objects.
1966
+ * This array maintains the `ITreeData` objects in the order they were selected.
1967
+ *
1968
+ * @returns {ITreeData[]} Array of checked records.
1969
+ */
1970
+ Selection.prototype.getCheckedrecords = function () { return this.selectedItems; };
1971
+ /**
1972
+ * Retrieves visible indexes of checked rows in the current view, in the order they were selected.
1973
+ * This method dynamically generates the list of visible indexes by iterating through `selectedItems`
1974
+ * (which preserves selection order) and finding their *current* visible index.
1975
+ *
1976
+ * @returns {number[]} Array of checked row indexes in selection order.
1977
+ */
1504
1978
  Selection.prototype.getCheckedRowIndexes = function () {
1505
- return this.selectedIndexes;
1979
+ this.buildVisibleUidMap();
1980
+ var orderedVisibleIndexes = [];
1981
+ for (var _i = 0, _a = this.selectedItems; _i < _a.length; _i++) {
1982
+ var selectedItem = _a[_i];
1983
+ var uid = selectedItem.uniqueID;
1984
+ if (uid !== undefined && this.visibleUidIndex[uid] !== undefined) {
1985
+ orderedVisibleIndexes.push(this.visibleUidIndex[uid]);
1986
+ }
1987
+ }
1988
+ return orderedVisibleIndexes;
1506
1989
  };
1507
1990
  return Selection;
1508
1991
  }());
@@ -2104,6 +2587,7 @@ var DataManipulation = /** @__PURE__ @class */ (function () {
2104
2587
  */
2105
2588
  DataManipulation.prototype.destroy = function () {
2106
2589
  this.removeEventListener();
2590
+ this.hierarchyData = null;
2107
2591
  };
2108
2592
  /**
2109
2593
  * @hidden
@@ -2716,7 +3200,7 @@ var DataManipulation = /** @__PURE__ @class */ (function () {
2716
3200
  this.parent.parentData.push(currentData);
2717
3201
  }
2718
3202
  currentData.uniqueID = getUid(this.parent.element.id + '_data_');
2719
- setValue('uniqueIDCollection.' + currentData.uniqueID, currentData, this.parent);
3203
+ this.parent.uniqueIDCollection[currentData.uniqueID] = currentData;
2720
3204
  if (!isNullOrUndefined(parentRecords)) {
2721
3205
  var parentData = extend$1({}, parentRecords);
2722
3206
  delete parentData.childRecords;
@@ -3329,6 +3813,7 @@ function editAction(details, control, isSelfReference, addRowIndex, selectedInde
3329
3813
  var key = control.grid.getPrimaryKeyFieldNames()[0];
3330
3814
  var treeData = control.dataSource instanceof DataManager ?
3331
3815
  control.dataSource.dataSource.json : control.dataSource;
3816
+ var gridData = control.grid.dataSource;
3332
3817
  var modifiedData = [];
3333
3818
  var originalData = value;
3334
3819
  var isSkip = false;
@@ -3356,9 +3841,9 @@ function editAction(details, control, isSelfReference, addRowIndex, selectedInde
3356
3841
  var keys = modifiedData[parseInt(k.toString(), 10)].taskData ?
3357
3842
  Object.keys(modifiedData[parseInt(k.toString(), 10)].taskData) :
3358
3843
  Object.keys(modifiedData[parseInt(k.toString(), 10)]);
3359
- i = treeData.length;
3844
+ i = treeData.length === 0 && gridData.length === 1 ? gridData.length : treeData.length;
3360
3845
  var _loop_1 = function () {
3361
- if (treeData[parseInt(i.toString(), 10)]["" + key] === modifiedData[parseInt(k.toString(), 10)]["" + key]) {
3846
+ if ((treeData.length === 0 && gridData.length === 1 && gridData[parseInt(i.toString(), 10)]["" + key] === modifiedData[parseInt(k.toString(), 10)]["" + key]) || treeData[parseInt(i.toString(), 10)]["" + key] === modifiedData[parseInt(k.toString(), 10)]["" + key]) {
3362
3847
  if (action === 'delete') {
3363
3848
  var currentData_1 = treeData[parseInt(i.toString(), 10)];
3364
3849
  treeData.splice(i, 1);
@@ -3404,7 +3889,10 @@ function editAction(details, control, isSelfReference, addRowIndex, selectedInde
3404
3889
  else if (action === 'add' || action === 'batchsave') {
3405
3890
  var index = void 0;
3406
3891
  if (control.editSettings.newRowPosition === 'Child') {
3407
- if (isSelfReference) {
3892
+ if (treeData.length === 0 && gridData.length === 1) {
3893
+ treeData.push(originalData.taskData);
3894
+ }
3895
+ else if (isSelfReference) {
3408
3896
  originalData.taskData["" + control.parentIdMapping] = treeData[parseInt(i.toString(), 10)]["" + control.idMapping];
3409
3897
  treeData.splice(i + 1, 0, originalData.taskData);
3410
3898
  }
@@ -3484,6 +3972,9 @@ function addAction(details, treeData, control, isSelfReference, addRowIndex, sel
3484
3972
  value = extend$1({}, addRowRecord);
3485
3973
  value = getPlainData(value);
3486
3974
  }
3975
+ else if (currentViewRecords.length === 0) {
3976
+ value = getPlainData(value);
3977
+ }
3487
3978
  else {
3488
3979
  value = extend$1({}, currentViewRecords[addRowIndex + 1]);
3489
3980
  value = getPlainData(value);
@@ -3497,8 +3988,8 @@ function addAction(details, treeData, control, isSelfReference, addRowIndex, sel
3497
3988
  }
3498
3989
  else {
3499
3990
  var primaryKeys = control.grid.getPrimaryKeyFieldNames()[0];
3500
- var currentdata = currentViewRecords[parseInt(addRowIndex.toString(), 10)];
3501
- if (!isNullOrUndefined(currentdata) && currentdata["" + primaryKeys] === details.value["" + primaryKeys] || selectedIndex !== -1) {
3991
+ var currentdata = currentViewRecords.length > 0 ? currentViewRecords[parseInt(addRowIndex.toString(), 10)] : [];
3992
+ if (!isNullOrUndefined(currentdata) && currentdata["" + primaryKeys] === details.value["" + primaryKeys] || selectedIndex !== -1 && treeData.length !== 0) {
3502
3993
  value = extend$1({}, currentdata);
3503
3994
  }
3504
3995
  else {
@@ -3837,7 +4328,9 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
3837
4328
  function TreeGrid(options, element) {
3838
4329
  var _this = _super.call(this, options, element) || this;
3839
4330
  _this.dataResults = {};
4331
+ /** @hidden */
3840
4332
  _this.uniqueIDCollection = {};
4333
+ /** @hidden */
3841
4334
  _this.uniqueIDFilterCollection = {};
3842
4335
  _this.changedRecords = 'changedRecords';
3843
4336
  _this.deletedRecords = 'deletedRecords';
@@ -3847,6 +4340,8 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
3847
4340
  _this.modifiedRecords = [];
3848
4341
  _this.stackedHeader = false;
3849
4342
  _this.freezeColumnRefresh = true;
4343
+ _this.componentRefresh = Component.prototype.refresh;
4344
+ _this.isComponentRefresh = false;
3850
4345
  _this.objectEqualityChecker = function (old, current) {
3851
4346
  if (old) {
3852
4347
  var keys = Object.keys(old);
@@ -3897,7 +4392,7 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
3897
4392
  /* eslint-disable */
3898
4393
  TreeGrid.prototype.excelExport = function (excelExportProperties, isMultipleExport, workbook, isBlob) {
3899
4394
  /* eslint-enable */
3900
- return this.excelExportModule.Map(excelExportProperties, isMultipleExport, workbook, isBlob, false);
4395
+ return this.allowExcelExport ? this.excelExportModule.Map(excelExportProperties, isMultipleExport, workbook, isBlob, false) : null;
3901
4396
  };
3902
4397
  /**
3903
4398
  * Exports the TreeGrid data to a CSV file.
@@ -3911,7 +4406,7 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
3911
4406
  /* eslint-disable */
3912
4407
  TreeGrid.prototype.csvExport = function (excelExportProperties, isMultipleExport, workbook, isBlob) {
3913
4408
  /* eslint-enable */
3914
- return this.excelExportModule.Map(excelExportProperties, isMultipleExport, workbook, isBlob, true);
4409
+ return this.allowExcelExport ? this.excelExportModule.Map(excelExportProperties, isMultipleExport, workbook, isBlob, true) : null;
3915
4410
  };
3916
4411
  /**
3917
4412
  * Exports the TreeGrid data to a PDF document.
@@ -3923,7 +4418,7 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
3923
4418
  * @returns {Promise<any>} - Returns a promise that resolves with the result of the export action.
3924
4419
  */
3925
4420
  TreeGrid.prototype.pdfExport = function (pdfExportProperties, isMultipleExport, pdfDoc, isBlob) {
3926
- return this.pdfExportModule.Map(pdfExportProperties, isMultipleExport, pdfDoc, isBlob);
4421
+ return this.allowPdfExport ? this.pdfExportModule.Map(pdfExportProperties, isMultipleExport, pdfDoc, isBlob) : null;
3927
4422
  };
3928
4423
  /**
3929
4424
  * Sends a POST request to export the TreeGrid to an Excel file on the server side.
@@ -4043,6 +4538,26 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
4043
4538
  TreeGrid.prototype.getModuleName = function () {
4044
4539
  return 'treegrid';
4045
4540
  };
4541
+ /**
4542
+ * Initiates a complete refresh of the TreeGrid's column and layout.
4543
+ *
4544
+ * This method forces a full re-render of the TreeGrid, ensuring that any dynamic
4545
+ * changes to columns or layout are immediately reflected.
4546
+ *
4547
+ * @returns {void}
4548
+ */
4549
+ TreeGrid.prototype.refreshLayout = function () {
4550
+ this.componentRefresh();
4551
+ };
4552
+ /**
4553
+ * @param {Object} prop - Defines the property
4554
+ * @param {boolean} muteOnChange - Defines the mute on change
4555
+ * @returns {void}
4556
+ * @private
4557
+ */
4558
+ TreeGrid.prototype.setProperties = function (prop, muteOnChange) {
4559
+ _super.prototype.setProperties.call(this, prop, muteOnChange);
4560
+ };
4046
4561
  /**
4047
4562
  * For internal use only - Initialize the event handler;
4048
4563
  *
@@ -4050,6 +4565,9 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
4050
4565
  * @returns {void}
4051
4566
  */
4052
4567
  TreeGrid.prototype.preRender = function () {
4568
+ if (this.isComponentRefresh) {
4569
+ this.grid = new Grid();
4570
+ }
4053
4571
  this.TreeGridLocale();
4054
4572
  this.initProperties();
4055
4573
  this.defaultLocale = {
@@ -4219,7 +4737,10 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
4219
4737
  }
4220
4738
  }
4221
4739
  else {
4222
- this.clearSelection();
4740
+ var contentTableBody = this.grid.getContent().querySelector('.e-table tbody');
4741
+ if (parentTarget && contentTableBody && parentTarget !== contentTableBody.lastElementChild) {
4742
+ this.clearSelection();
4743
+ }
4223
4744
  }
4224
4745
  }
4225
4746
  }
@@ -4290,6 +4811,8 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
4290
4811
  this.isExpandAll = false;
4291
4812
  this.isCollapseAll = false;
4292
4813
  this.freezeColumnRefresh = true;
4814
+ this.componentRefresh = Component.prototype.refresh;
4815
+ this.isComponentRefresh = false;
4293
4816
  this.keyConfigs = {
4294
4817
  ctrlDownArrow: 'ctrl+downarrow',
4295
4818
  ctrlUpArrow: 'ctrl+uparrow',
@@ -4610,6 +5133,7 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
4610
5133
  if (this.isIndentEnabled) {
4611
5134
  this.refreshToolbarItems();
4612
5135
  }
5136
+ this.updateColumnModel();
4613
5137
  this.wireEvents();
4614
5138
  this.renderComplete();
4615
5139
  var destroyTemplate = 'destroyTemplate';
@@ -4660,6 +5184,15 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
4660
5184
  if (this.allowSelection && !isNullOrUndefined(this.rowTemplate)) {
4661
5185
  failureCases.push('Selection is not supported in RowTemplate');
4662
5186
  }
5187
+ if (!this.allowExcelExport && this.action === 'csvExport') {
5188
+ failureCases.push('CSV export is not allowed when allowExcelExport is disabled.');
5189
+ }
5190
+ if (!this.allowPdfExport && this.action === 'pdfExport') {
5191
+ failureCases.push('PDF export is not allowed when allowPdfExport is disabled');
5192
+ }
5193
+ if (!this.allowExcelExport && this.action === 'excelExport') {
5194
+ failureCases.push('Excel export is not allowed when allowExcelExport is disabled.');
5195
+ }
4663
5196
  if (this.treeColumnIndex >= this.columns.length) {
4664
5197
  failureCases.push('TreeColumnIndex value should not exceed the total column count.');
4665
5198
  }
@@ -4820,6 +5353,8 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
4820
5353
  this.grid.frozenRows = this.frozenRows;
4821
5354
  this.grid.frozenColumns = this.frozenColumns;
4822
5355
  this.grid.clipMode = getActualProperties(this.clipMode);
5356
+ this.grid.enableColumnSpan = this.enableColumnSpan;
5357
+ this.grid.enableRowSpan = this.enableRowSpan;
4823
5358
  var templateInstance = 'templateDotnetInstance';
4824
5359
  this.grid["" + templateInstance] = this["" + templateInstance];
4825
5360
  var isJsComponent = 'isJsComponent';
@@ -5300,12 +5835,12 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
5300
5835
  _this.grid.refresh();
5301
5836
  }
5302
5837
  if (args.action === 'filter') {
5303
- if (!args.isCollapseMaintain && _this.filterModule['currentFilterObject'] !== '' && _this.enableVirtualization && !_this.initialRender && !(isRemoteData(_this) && _this.enableVirtualization)) {
5838
+ if (!args.isCollapseMaintain && _this.filterModule['currentFilterObject'] !== '' && _this.enableVirtualization && !_this.initialRender && !_this.expandStateMapping && !(isRemoteData(_this) && _this.enableVirtualization)) {
5304
5839
  _this.expandAll();
5305
5840
  }
5306
5841
  }
5307
5842
  if (args.requestType === 'searching') {
5308
- if (!args.isCollapseMaintain && _this.searchSettings.key !== '' && _this.enableVirtualization && !_this.initialRender && !(isRemoteData(_this) && _this.enableVirtualization)) {
5843
+ if (!args.isCollapseMaintain && _this.searchSettings.key !== '' && _this.enableVirtualization && !_this.initialRender && !_this.expandStateMapping && !(isRemoteData(_this) && _this.enableVirtualization)) {
5309
5844
  _this.expandAll();
5310
5845
  }
5311
5846
  }
@@ -5645,12 +6180,15 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
5645
6180
  TreeGrid.prototype.onPropertyChanged = function (newProp) {
5646
6181
  var properties = Object.keys(newProp);
5647
6182
  var requireRefresh = false;
5648
- if (properties.indexOf('columns') > -1 && !isNullOrUndefined(newProp.columns)) {
5649
- this.refreshColumns();
5650
- }
5651
6183
  for (var _i = 0, properties_1 = properties; _i < properties_1.length; _i++) {
5652
6184
  var prop = properties_1[_i];
5653
6185
  switch (prop) {
6186
+ case 'columns':
6187
+ if (!isNullOrUndefined(newProp.columns)) {
6188
+ this.refreshColumns();
6189
+ }
6190
+ requireRefresh = true;
6191
+ break;
5654
6192
  case 'treeColumnIndex':
5655
6193
  this.grid.refreshColumns();
5656
6194
  break;
@@ -5861,8 +6399,19 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
5861
6399
  }
5862
6400
  this.grid.editSettings = this.getGridEditSettings();
5863
6401
  break;
6402
+ case 'enableRowSpan':
6403
+ case 'enableColumnSpan':
6404
+ this.grid.enableRowSpan = this.enableRowSpan;
6405
+ this.grid.enableColumnSpan = this.enableColumnSpan;
6406
+ this.refreshColumns();
6407
+ break;
5864
6408
  }
5865
- if (requireRefresh) {
6409
+ }
6410
+ if (requireRefresh) {
6411
+ if (this.isFrozenGrid()) {
6412
+ this.refreshLayout();
6413
+ }
6414
+ else {
5866
6415
  this.grid.refresh();
5867
6416
  }
5868
6417
  }
@@ -5883,6 +6432,7 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
5883
6432
  * @returns {void}
5884
6433
  */
5885
6434
  TreeGrid.prototype.destroy = function () {
6435
+ this.isComponentRefresh = true;
5886
6436
  var treeGridElement = this.element;
5887
6437
  if (!treeGridElement) {
5888
6438
  return;
@@ -5893,15 +6443,20 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
5893
6443
  this.unwireEvents();
5894
6444
  }
5895
6445
  this.removeListener();
5896
- if (hasTreeGridChild) {
5897
- _super.prototype.destroy.call(this);
6446
+ if (this.dataModule) {
6447
+ this.dataModule.destroy();
5898
6448
  }
5899
6449
  if (this.grid) {
6450
+ this.grid.dataSource = null;
5900
6451
  this.grid.destroy();
5901
6452
  }
5902
- if (this.dataModule) {
5903
- this.dataModule.destroy();
6453
+ if (hasTreeGridChild) {
6454
+ _super.prototype.destroy.call(this);
5904
6455
  }
6456
+ this.infiniteScrollData = null;
6457
+ this.remoteCollapsedData = null;
6458
+ this.remoteExpandedData = null;
6459
+ this.parentData = null;
5905
6460
  var modules = ['dataModule', 'sortModule', 'renderModule', 'filterModule', 'printModule', 'clipboardModule',
5906
6461
  'excelExportModule', 'pdfExportModule', 'toolbarModule', 'summaryModule', 'reorderModule', 'resizeModule',
5907
6462
  'pagerModule', 'keyboardModule', 'columnMenuModule', 'contextMenuModule', 'editModule', 'virtualScrollModule',
@@ -5911,6 +6466,9 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
5911
6466
  this[modules[parseInt(i.toString(), 10)]] = null;
5912
6467
  }
5913
6468
  }
6469
+ this.dataResults = null;
6470
+ this.uniqueIDCollection = {};
6471
+ this.uniqueIDFilterCollection = {};
5914
6472
  this.element.innerHTML = '';
5915
6473
  this.grid = null;
5916
6474
  };
@@ -6052,7 +6610,7 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
6052
6610
  /**
6053
6611
  * Adds a new record to the TreeGrid at the specified position or default location.
6054
6612
  *
6055
- * @param {Object} data - Object containing the data for the new record. If omitted, an empty row is added.
6613
+ * @param {Object | Object[]} data - Object containing data for a single record, or an array of objects for creating multiple records. If omitted, an empty row is added.
6056
6614
  * @param {number} index - The index at which the new row should be added.
6057
6615
  * @param {RowPosition} position - Specifies the position of the new row (e.g., before, after or child).
6058
6616
  *
@@ -6863,7 +7421,9 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
6863
7421
  if (isNullOrUndefined(refreshUI) || refreshUI) {
6864
7422
  this.grid.columns = this.getGridColumns(this.columns);
6865
7423
  this.getTreeColumn();
6866
- this.grid.refreshColumns();
7424
+ if (!this.isFrozenGrid()) {
7425
+ this.grid.refreshColumns();
7426
+ }
6867
7427
  }
6868
7428
  else {
6869
7429
  this.grid.setProperties({ columns: this.getGridColumns(this.columns) }, true);
@@ -7405,7 +7965,8 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
7405
7965
  if (rows.length) {
7406
7966
  for (var i = 0; i < rows.length; i++) {
7407
7967
  if (action === 'collapse') {
7408
- if (!isNullOrUndefined(this.getCurrentViewRecords()[rows[parseInt(i.toString(), 10)].rowIndex])) {
7968
+ var currentRecordIndx = this.frozenRows ? this.getCurrentViewRecords()[parseInt(rows[parseInt(i.toString(), 10)].getAttribute('aria-rowindex'), 10) - 1] : this.getCurrentViewRecords()[rows[parseInt(i.toString(), 10)].rowIndex];
7969
+ if (!isNullOrUndefined(currentRecordIndx)) {
7409
7970
  this.collapseRow(rows[parseInt(i.toString(), 10)]);
7410
7971
  }
7411
7972
  }
@@ -7532,8 +8093,9 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
7532
8093
  }
7533
8094
  var lastrowIdx = this.getVisibleRecords()[this.getVisibleRecords().length - 1]['index'];
7534
8095
  var lastRow = this.getRowByIndex(lastrowIdx);
7535
- if (this.grid.getContentTable().clientHeight <= this.grid.getContent().clientHeight && !isNullOrUndefined(lastRow) && !lastRow.cells[0].classList.contains('e-lastrowcell')) {
7536
- this.lastRowBorder(lastRow, true);
8096
+ var borderElement = lastRow ? lastRow.nextElementSibling ? lastRow.nextElementSibling.classList.contains('e-detailrow') ? lastRow.nextElementSibling : lastRow : lastRow : null;
8097
+ if (this.grid.getContentTable().clientHeight <= this.grid.getContent().clientHeight && !isNullOrUndefined(borderElement) && !borderElement.cells[0].classList.contains('e-lastrowcell')) {
8098
+ this.lastRowBorder(borderElement, true);
7537
8099
  }
7538
8100
  }
7539
8101
  if (isCountRequired(this) && action === 'expand') {
@@ -7697,12 +8259,16 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
7697
8259
  };
7698
8260
  TreeGrid.prototype.localExpand = function (action, row, record) {
7699
8261
  var rows;
8262
+ var detailRow = row.nextElementSibling ? row.nextElementSibling.classList.contains('e-detailrow') ? row.nextElementSibling : null : null;
7700
8263
  var childRecords = this.grid.currentViewData.filter(function (e) {
7701
8264
  return e.parentUniqueID === record.uniqueID;
7702
8265
  });
7703
8266
  if (this.isPixelHeight() && row.cells[0].classList.contains('e-lastrowcell')) {
7704
8267
  this.lastRowBorder(row, false);
7705
8268
  }
8269
+ else if (this.isPixelHeight() && detailRow && detailRow.cells[0].classList.contains('e-lastrowcell')) {
8270
+ this.lastRowBorder(row.nextElementSibling, false);
8271
+ }
7706
8272
  var movableRows;
7707
8273
  var freezeRightRows;
7708
8274
  var gridRows = this.getRows();
@@ -7917,6 +8483,7 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
7917
8483
  this.on('updateResults', this.updateResultModel, this);
7918
8484
  this.grid.on('initial-end', this.afterGridRender, this);
7919
8485
  this.grid.on('partial-filter-update', this.partialFilterUpdate, this);
8486
+ this.grid.on('get-row-cells', this.getCellsByTableName, this);
7920
8487
  };
7921
8488
  TreeGrid.prototype.updateResultModel = function (returnResult) {
7922
8489
  this.dataResults = returnResult;
@@ -7933,6 +8500,16 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
7933
8500
  this.grid.off('initial-end', this.afterGridRender);
7934
8501
  this.grid.off('last-rowcell-border-updated', this.lastRowCellBorderUpdated);
7935
8502
  this.grid.off('partial-filter-update', this.partialFilterUpdate);
8503
+ this.grid.off('get-row-cells', this.getCellsByTableName);
8504
+ };
8505
+ TreeGrid.prototype.getCellsByTableName = function (args) {
8506
+ if (!Array.isArray(args.elements)) {
8507
+ args.elements = [];
8508
+ }
8509
+ if (args.rowIndex < this.grid.getDataRows().length) {
8510
+ var cells = [].slice.call(this.grid.getDataRows()[parseInt(args.rowIndex.toString(), 10)].getElementsByClassName('e-rowcell'));
8511
+ Array.prototype.push.apply(args.elements, cells);
8512
+ }
7936
8513
  };
7937
8514
  TreeGrid.prototype.partialFilterUpdate = function (args) {
7938
8515
  var gridFiltered = args.gridFiltered;
@@ -8357,6 +8934,53 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
8357
8934
  this.rowDragAndDropModule[this.indentOutdentAction](record, 'outdent');
8358
8935
  }
8359
8936
  };
8937
+ /**
8938
+ * Calculates and returns the optimal page size that fits the current height of the TreeGrid's container.
8939
+ *
8940
+ * @param {number | string } containerHeight - (Optional) The height of the container - i.e. the complete TreeGrid height, which can be a number (in pixels) or a string.
8941
+ * @returns {number} returns the page size
8942
+ */
8943
+ TreeGrid.prototype.getPageSizeByHeight = function (containerHeight) {
8944
+ if (isNullOrUndefined(containerHeight)) {
8945
+ var treegridControlElement = document.getElementById(this.element.id);
8946
+ if (treegridControlElement) {
8947
+ containerHeight = treegridControlElement.clientHeight;
8948
+ }
8949
+ else {
8950
+ var root = this.element;
8951
+ containerHeight = root ? (root.offsetHeight || root.clientHeight || 0) : 0;
8952
+ }
8953
+ }
8954
+ if ((this.allowTextWrap && this.textWrapSettings.wrapMode === 'Header') || (!this.allowTextWrap)) {
8955
+ var pagesize = 0;
8956
+ if (typeof containerHeight === 'string' && containerHeight.indexOf('%') !== -1) {
8957
+ containerHeight = parseInt(containerHeight, 10) / 100 * this.element.clientHeight;
8958
+ }
8959
+ var nonContentHeight = this.grid['getNoncontentHeight']() + this.grid.getRowHeight();
8960
+ if (containerHeight > nonContentHeight) {
8961
+ var contentHeight = 0;
8962
+ var calcNonContentHeight = this.grid['getNoncontentHeight']();
8963
+ var pagerMsg = document.getElementsByClassName('e-pagerexternalmsg')[0];
8964
+ if (pagerMsg) {
8965
+ calcNonContentHeight += pagerMsg.clientHeight;
8966
+ }
8967
+ contentHeight = containerHeight - calcNonContentHeight;
8968
+ pagesize = (contentHeight / this.grid.getRowHeight());
8969
+ }
8970
+ if (this.frozenRows > 0) {
8971
+ pagesize = pagesize + this.frozenRows;
8972
+ }
8973
+ if (pagesize > 0) {
8974
+ return Math.floor(pagesize);
8975
+ }
8976
+ else {
8977
+ return 0;
8978
+ }
8979
+ }
8980
+ else {
8981
+ return 0;
8982
+ }
8983
+ };
8360
8984
  var TreeGrid_1;
8361
8985
  __decorate$c([
8362
8986
  Property(0)
@@ -8571,6 +9195,12 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
8571
9195
  __decorate$c([
8572
9196
  Property(false)
8573
9197
  ], TreeGrid.prototype, "allowPdfExport", void 0);
9198
+ __decorate$c([
9199
+ Property(false)
9200
+ ], TreeGrid.prototype, "enableColumnSpan", void 0);
9201
+ __decorate$c([
9202
+ Property(false)
9203
+ ], TreeGrid.prototype, "enableRowSpan", void 0);
8574
9204
  __decorate$c([
8575
9205
  Event()
8576
9206
  ], TreeGrid.prototype, "created", void 0);
@@ -9076,6 +9706,9 @@ var RowDD = /** @__PURE__ @class */ (function () {
9076
9706
  this.selectedItem = isNullOrUndefined(record) ?
9077
9707
  tObj.getCurrentViewRecords()[parseInt(selectedItemIndex.toString(), 10)] : record;
9078
9708
  var primaryKeyField = this.parent.getPrimaryKeyFieldNames()[0];
9709
+ if (!primaryKeyField) {
9710
+ return;
9711
+ }
9079
9712
  var rowIndex = this.parent.grid.getRowIndexByPrimaryKey(this.selectedItem["" + primaryKeyField]);
9080
9713
  this.selectedRow = this.parent[this.selectedRows] = selectedItemIndex !== -1 ?
9081
9714
  this.parent.getSelectedRows()[0]
@@ -12077,7 +12710,7 @@ var Aggregate = /** @__PURE__ @class */ (function () {
12077
12710
  var value_1 = types[parseInt(i.toString(), 10)] !== 'Custom' ? val["" + key] : val;
12078
12711
  single["" + disp] = single["" + disp] || {};
12079
12712
  single["" + disp]["" + key] = value_1;
12080
- single["" + disp][types[parseInt(i.toString(), 10)]] = !isNullOrUndefined(val) ? formatFn(value_1) : ' ';
12713
+ single["" + disp][types[parseInt(i.toString(), 10)]] = (!isNullOrUndefined(val) && !isNullOrUndefined(value_1)) ? formatFn(value_1) : ' ';
12081
12714
  }
12082
12715
  helper.format = summaryColumn.getFormatter();
12083
12716
  var cellElement = createElement('td', {
@@ -12304,6 +12937,7 @@ var ContextMenu = /** @__PURE__ @class */ (function () {
12304
12937
  ContextMenu.prototype.addEventListener = function () {
12305
12938
  this.parent.on('contextMenuOpen', this.contextMenuOpen, this);
12306
12939
  this.parent.on('contextMenuClick', this.contextMenuClick, this);
12940
+ this.parent.on('contextMenuItemClick', this.contextMenuItemClick, this);
12307
12941
  };
12308
12942
  /**
12309
12943
  * @hidden
@@ -12315,6 +12949,21 @@ var ContextMenu = /** @__PURE__ @class */ (function () {
12315
12949
  }
12316
12950
  this.parent.off('contextMenuOpen', this.contextMenuOpen);
12317
12951
  this.parent.off('contextMenuClick', this.contextMenuClick);
12952
+ this.parent.off('contextMenuItemClick', this.contextMenuItemClick);
12953
+ };
12954
+ ContextMenu.prototype.contextMenuItemClick = function (args) {
12955
+ var id = args.item && args.item.id ? args.item.id : '';
12956
+ var delId = this.parent.element.id + '_gridcontrol_cmenu_Delete';
12957
+ if (id !== delId) {
12958
+ return;
12959
+ }
12960
+ if (this.parent.getSelectedRecords()[0].hasChildRecords || this.parent.getSelectedRecords().length > 1) {
12961
+ this.parent.deleteRecord();
12962
+ }
12963
+ else {
12964
+ this.parent.deleteRow(this.parent.getSelectedRows()[0]);
12965
+ }
12966
+ args.cancel = true;
12318
12967
  };
12319
12968
  ContextMenu.prototype.contextMenuOpen = function (args) {
12320
12969
  var addRow = select('#' + this.parent.element.id + '_gridcontrol_cmenu_AddRow', args.element);
@@ -12703,13 +13352,22 @@ var BatchEdit = /** @__PURE__ @class */ (function () {
12703
13352
  focusModule.getContent().matrix.matrix = this.matrix;
12704
13353
  }
12705
13354
  else {
12706
- actualIndex = table.getElementsByClassName('e-batchrow')[0].rowIndex;
13355
+ if (this.parent.frozenRows) {
13356
+ actualIndex = this.batchIndex;
13357
+ }
13358
+ else if (this.parent.editModule.isAddedMultipleRowsByMethod) {
13359
+ actualIndex = e.index;
13360
+ }
13361
+ else {
13362
+ actualIndex = table.getElementsByClassName('e-batchrow')[0].rowIndex;
13363
+ }
12707
13364
  // if (this.parent.frozenRows || this.parent.frozenColumns) {
12708
13365
  // actualIndex = this.batchIndex;
12709
13366
  // }
12710
13367
  }
12711
13368
  focusModule.getContent().matrix.current = [actualIndex, focusModule.getContent().matrix.current[1]];
12712
- if (this.parent.editModule['isAddedRowByMethod'] && !isNullOrUndefined(this.parent.editModule['addRowIndex']) && !this.parent.editModule['isAddedRowByContextMenu']) {
13369
+ if (this.parent.editModule['isAddedRowByMethod'] && !isNullOrUndefined(this.parent.editModule['addRowIndex']) &&
13370
+ !this.parent.editModule['isAddedRowByContextMenu'] && !this.parent.editModule.isAddedMultipleRowsByMethod) {
12713
13371
  var newlyAddedRecords = this.parent.getBatchChanges()['addedRecords'];
12714
13372
  var index = parseInt(this.parent.getContentTable().getElementsByClassName('e-insertedrow')[newlyAddedRecords.length - 1].getAttribute('aria-rowindex'), 10) - 1;
12715
13373
  this.batchRecords.splice(index, 0, newlyAddedRecords[newlyAddedRecords.length - 1]);
@@ -12926,7 +13584,7 @@ var BatchEdit = /** @__PURE__ @class */ (function () {
12926
13584
  }
12927
13585
  else {
12928
13586
  var totalRecords = extendArray(data);
12929
- if (totalRecords.length) {
13587
+ if (totalRecords.length && currentViewRecords.length !== 0) {
12930
13588
  var startIndex = totalRecords.map(function (e) { return e["" + primarykey_1]; })
12931
13589
  .indexOf(currentViewRecords[0]["" + primarykey_1]);
12932
13590
  var endIndex = startIndex + this.parent.grid.pageSettings.pageSize;
@@ -12958,7 +13616,12 @@ var BatchEdit = /** @__PURE__ @class */ (function () {
12958
13616
  this.parent.editModule['previousNewRowPosition'] = rowPosition;
12959
13617
  }
12960
13618
  addRecords[parseInt(i.toString(), 10)].taskData = taskData;
12961
- addRowRecord_1 = this.batchAddRowRecord[parseInt(i.toString(), 10)];
13619
+ if (this.batchAddRowRecord.length > 1) {
13620
+ addRowRecord_1 = this.batchAddRowRecord[parseInt(i.toString(), 10)];
13621
+ }
13622
+ else {
13623
+ addRowRecord_1 = this.batchAddRowRecord[0];
13624
+ }
12962
13625
  if (isNullOrUndefined(addRowRecord_1)) {
12963
13626
  addRowRecord_1 = this.batchAddRowRecord[i - 1];
12964
13627
  }
@@ -12973,6 +13636,10 @@ var BatchEdit = /** @__PURE__ @class */ (function () {
12973
13636
  if (isNullOrUndefined(addRecords[parseInt(i.toString(), 10)].index)) {
12974
13637
  addRowIndex = 0;
12975
13638
  }
13639
+ if (this.parent.editModule.isAddedMultipleRowsByMethod && this.isSelfReference && (this.parent.editSettings.newRowPosition === 'Above' || this.parent.editSettings.newRowPosition === 'Below')) {
13640
+ addRowIndex = args.index;
13641
+ addRowRecord_1 = this.parent.flatData[args.index];
13642
+ }
12976
13643
  if (this.parent.editSettings.newRowPosition !== 'Top' && this.parent.editSettings.newRowPosition !== 'Bottom') {
12977
13644
  if (isNullOrUndefined(addRecords[parseInt(i.toString(), 10)].parentItem) && this.selectedIndex === -1) {
12978
13645
  selectedIndex = -1;
@@ -13102,6 +13769,7 @@ var Edit = /** @__PURE__ @class */ (function () {
13102
13769
  this.isAddedRowByMethod = false;
13103
13770
  this.isAddedRowByContextMenu = false;
13104
13771
  this.isIndexUndefined = false;
13772
+ this.isAddedMultipleRowsByMethod = false;
13105
13773
  Grid.Inject(Edit$1);
13106
13774
  this.parent = parent;
13107
13775
  this.isSelfReference = !isNullOrUndefined(parent.parentIdMapping);
@@ -13761,7 +14429,8 @@ var Edit = /** @__PURE__ @class */ (function () {
13761
14429
  }
13762
14430
  }
13763
14431
  }
13764
- if (this.parent.editSettings.mode === 'Batch' && !isNullOrUndefined(this.addRowIndex) && this.addRowIndex !== -1 && this['isAddedRowByMethod'] && !this.isAddedRowByContextMenu) {
14432
+ if (this.parent.editSettings.mode === 'Batch' && !isNullOrUndefined(this.addRowIndex) && this.addRowIndex !== -1 &&
14433
+ !this.isAddedMultipleRowsByMethod && this['isAddedRowByMethod'] && !this.isAddedRowByContextMenu) {
13765
14434
  index = this.batchEditModule.getAddRowIndex();
13766
14435
  this.selectedIndex = this.batchEditModule.getSelectedIndex();
13767
14436
  var batchAddedRecords = this.parent.getBatchChanges()['addedRecords'];
@@ -13783,6 +14452,28 @@ var Edit = /** @__PURE__ @class */ (function () {
13783
14452
  this.batchEditModule['batchAddRowRecord'].push(this.batchEditModule['addRowRecord']);
13784
14453
  this.batchEditModule['batchAddedRecords'].push(args['data']);
13785
14454
  }
14455
+ else if (this.parent.editSettings.mode === 'Batch' && this.isAddedMultipleRowsByMethod && (this.parent.editSettings.newRowPosition === 'Above' || this.parent.editSettings.newRowPosition === 'Below')) {
14456
+ index = this.multipleRowIndex;
14457
+ this.selectedIndex = this.multipleRowIndex;
14458
+ var batchAddedRecords = this.updatedRecords.addedRecords;
14459
+ var newlyAddedRecord = void 0;
14460
+ if (batchAddedRecords.length) {
14461
+ for (var i = 0; i < batchAddedRecords.length; i++) {
14462
+ if (isNullOrUndefined(batchAddedRecords[parseInt(i.toString(), 10)].uniqueID)) {
14463
+ newlyAddedRecord = batchAddedRecords[parseInt(i.toString(), 10)];
14464
+ }
14465
+ var args = {
14466
+ action: 'add',
14467
+ data: newlyAddedRecord,
14468
+ index: index,
14469
+ seletedRow: 0
14470
+ };
14471
+ this.beginAddEdit(args);
14472
+ this.batchEditModule['batchAddRowRecord'].push(this.batchEditModule['addRowRecord']);
14473
+ this.batchEditModule['batchAddedRecords'].push(args['data']);
14474
+ }
14475
+ }
14476
+ }
13786
14477
  };
13787
14478
  // private beforeDataBound(args: BeforeDataBoundArgs): void {
13788
14479
  // if (this.parent.grid.isEdit && this.parent.dataSource instanceof DataManager &&
@@ -13803,6 +14494,9 @@ var Edit = /** @__PURE__ @class */ (function () {
13803
14494
  // }
13804
14495
  // }
13805
14496
  Edit.prototype.beginEdit = function (args) {
14497
+ if (this.parent.flatData.length === 0 && !isNullOrUndefined(this.addRowRecord)) {
14498
+ this.addRowRecord = undefined;
14499
+ }
13806
14500
  if (args.requestType === 'refresh' && this.isOnBatch) {
13807
14501
  args.cancel = true;
13808
14502
  return;
@@ -14074,7 +14768,35 @@ var Edit = /** @__PURE__ @class */ (function () {
14074
14768
  if (isNullOrUndefined(index)) {
14075
14769
  this.isIndexUndefined = true;
14076
14770
  }
14077
- if (!this.isSelfReference && !isNullOrUndefined(data) && Object.hasOwnProperty.call(data, this.parent.childMapping)) {
14771
+ if (!isNullOrUndefined(data) && Array.isArray(data)) {
14772
+ var addRecords = [];
14773
+ var previousEditMode = this.parent.editSettings.mode;
14774
+ var previousGridEditMode = this.parent.grid.editSettings.mode;
14775
+ if (!this.isSelfReference && !isNullOrUndefined(data) && Object.hasOwnProperty.call(data, this.parent.childMapping)) {
14776
+ addRecords.push(data);
14777
+ }
14778
+ else if (Array.isArray(data)) {
14779
+ addRecords = data;
14780
+ }
14781
+ this.parent.setProperties({ editSettings: { mode: 'Batch' } }, true);
14782
+ this.parent.grid.setProperties({ editSettings: { mode: 'Batch' } }, true);
14783
+ if (!isNullOrUndefined(position)) {
14784
+ this.parent.setProperties({ editSettings: { newRowPosition: position } }, true);
14785
+ }
14786
+ this.updatedRecords = { addedRecords: addRecords, changedRecords: [], deletedRecords: [] };
14787
+ if ((position === 'Above' || position === 'Below') && this.isSelfReference) {
14788
+ this.isAddedMultipleRowsByMethod = true;
14789
+ this.multipleRowIndex = index;
14790
+ this.addRowIndex = index;
14791
+ this.parent.notify(batchAdd, { updatedRecords: this.updatedRecords, index: index });
14792
+ }
14793
+ var updatedRecords = this.updatedRecords;
14794
+ this.parent.notify(batchSave, { updatedRecords: updatedRecords, index: index });
14795
+ this.parent.setProperties({ editSettings: { mode: previousEditMode } }, true);
14796
+ this.parent.grid.setProperties({ editSettings: { mode: previousGridEditMode } }, true);
14797
+ this.parent.refresh();
14798
+ }
14799
+ else if (!this.isSelfReference && !isNullOrUndefined(data) && Object.hasOwnProperty.call(data, this.parent.childMapping)) {
14078
14800
  var addRecords = [];
14079
14801
  var previousEditMode = this.parent.editSettings.mode;
14080
14802
  var previousGridEditMode = this.parent.grid.editSettings.mode;
@@ -14084,7 +14806,8 @@ var Edit = /** @__PURE__ @class */ (function () {
14084
14806
  if (!isNullOrUndefined(position)) {
14085
14807
  this.parent.setProperties({ editSettings: { newRowPosition: position } }, true);
14086
14808
  }
14087
- var updatedRecords = { addedRecords: addRecords, changedRecords: [], deletedRecords: [] };
14809
+ this.updatedRecords = { addedRecords: addRecords, changedRecords: [], deletedRecords: [] };
14810
+ var updatedRecords = this.updatedRecords;
14088
14811
  this.parent.notify(batchSave, { updatedRecords: updatedRecords, index: index });
14089
14812
  this.parent.setProperties({ editSettings: { mode: previousEditMode } }, true);
14090
14813
  this.parent.grid.setProperties({ editSettings: { mode: previousGridEditMode } }, true);
@@ -14583,6 +15306,9 @@ var VirtualTreeContentRenderer = /** @__PURE__ @class */ (function (_super) {
14583
15306
  _super.prototype.renderTable.call(this);
14584
15307
  if (!(this.parent.dataSource instanceof DataManager && this.parent.dataSource.dataSource.url !== undefined
14585
15308
  && this.parent.dataSource.dataSource.offline && this.parent.dataSource.dataSource.url !== '') || !isCountRequired(this.parent)) {
15309
+ if (this.observers) {
15310
+ this.observers.disconnect();
15311
+ }
14586
15312
  getValue('observer', this).options.debounceEvent = false;
14587
15313
  this.observers = new TreeInterSectionObserver(getValue('observer', this).element, getValue('observer', this).options);
14588
15314
  this.contents = this.getPanel().firstChild;
@@ -15298,6 +16024,9 @@ var VirtualTreeContentRenderer = /** @__PURE__ @class */ (function (_super) {
15298
16024
  this.parent.off('refresh-virtual-editform-cells', this.refreshCell);
15299
16025
  this.parent.off('virtaul-cell-focus', this.cellFocus);
15300
16026
  this.parent.off('virtual-scroll-edit', this.restoreEditState);
16027
+ if (this.observers) {
16028
+ this.observers.disconnect();
16029
+ }
15301
16030
  };
15302
16031
  return VirtualTreeContentRenderer;
15303
16032
  }(VirtualContentRenderer));
@@ -15323,12 +16052,28 @@ var TreeInterSectionObserver = /** @__PURE__ @class */ (function (_super) {
15323
16052
  TreeInterSectionObserver.prototype.observes = function (callback, onEnterCallback, instance) {
15324
16053
  var containerRect = 'containerRect';
15325
16054
  _super.prototype["" + containerRect] = getValue('options', this).container.getBoundingClientRect();
15326
- EventHandler.add(getValue('options', this).container, 'scroll', this.virtualScrollHandlers(callback, onEnterCallback, instance), this);
16055
+ this.containerEl = getValue('options', this).container;
16056
+ this.containerScrollHandler = this.virtualScrollHandlers(callback, onEnterCallback, instance);
16057
+ EventHandler.add(this.containerEl, 'scroll', this.containerScrollHandler, this);
15327
16058
  if (getValue('options', this).movableContainer) {
15328
16059
  var movableContainerRect = 'movableContainerRect';
15329
16060
  _super.prototype["" + movableContainerRect] = getValue('options', this).movableContainer.getBoundingClientRect();
15330
- EventHandler.add(getValue('options', this).movableContainer, 'scroll', this.virtualScrollHandlers(callback, onEnterCallback, instance), this);
16061
+ this.movableContainerEl = getValue('options', this).movableContainer;
16062
+ this.movableScrollHandler = this.virtualScrollHandlers(callback, onEnterCallback, instance);
16063
+ EventHandler.add(this.movableContainerEl, 'scroll', this.movableScrollHandler, this);
16064
+ }
16065
+ };
16066
+ TreeInterSectionObserver.prototype.disconnect = function () {
16067
+ if (this.containerEl && this.containerScrollHandler) {
16068
+ EventHandler.remove(this.containerEl, 'scroll', this.containerScrollHandler);
16069
+ this.containerScrollHandler = null;
16070
+ }
16071
+ if (this.movableContainerEl && this.movableScrollHandler) {
16072
+ EventHandler.remove(this.movableContainerEl, 'scroll', this.movableScrollHandler);
16073
+ this.movableScrollHandler = null;
15331
16074
  }
16075
+ this.containerEl = null;
16076
+ this.movableContainerEl = null;
15332
16077
  };
15333
16078
  /**
15334
16079
  * Clears the last known position.
@@ -15552,9 +16297,12 @@ var VirtualScroll = /** @__PURE__ @class */ (function () {
15552
16297
  var dm = new DataManager(pageingDetails.result);
15553
16298
  var expanded = new Predicate$1('expanded', 'notequal', null).or('expanded', 'notequal', undefined);
15554
16299
  var parents = dm.executeLocal(new Query().where(expanded));
15555
- var visualData = parents.filter(function (e) {
15556
- return getExpandStatus(_this.parent, e);
15557
- });
16300
+ var isFiltering = pageingDetails.actionArgs.requestType === 'filtering';
16301
+ var isFlatHierarchy = this.parent.filterSettings.hierarchyMode === 'Child' ||
16302
+ this.parent.filterSettings.hierarchyMode === 'None';
16303
+ var visualData = isFiltering && isFlatHierarchy
16304
+ ? parents
16305
+ : parents.filter(function (e) { return getExpandStatus(_this.parent, e); });
15558
16306
  this.visualData = visualData;
15559
16307
  pageingDetails.count = visualData.length;
15560
16308
  this.parent.grid.notify(dataListener, { data: visualData });
@@ -15793,7 +16541,7 @@ var Freeze = /** @__PURE__ @class */ (function () {
15793
16541
  }
15794
16542
  var queryselector = args.action === 'e-childrow-hidden' ? '.e-treecolumn-container .e-treegridcollapse'
15795
16543
  : '.e-treecolumn-container .e-treegridexpand';
15796
- if (frozenrows[row.rowIndex].querySelector(queryselector)) {
16544
+ if (frozenrows[parseInt(row.getAttribute('aria-rowindex'), 10) - 1].querySelector(queryselector)) {
15797
16545
  var cRow = [];
15798
16546
  for (var i_1 = 0; i_1 < movableRows.length; i_1++) {
15799
16547
  if (movableRows[parseInt(i_1.toString(), 10)].querySelector('.e-gridrowindex' + rData.index + 'level' + (rData.level + 1))) {