@syncfusion/ej2-treegrid 20.3.49 → 20.3.50

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.
@@ -1763,8 +1763,9 @@ var Render = /** @__PURE__ @class */ (function () {
1763
1763
  if (args.column.template) {
1764
1764
  args.cell.innerHTML = null;
1765
1765
  }
1766
- else
1766
+ else {
1767
1767
  args.cell.innerHTML = summaryData;
1768
+ }
1768
1769
  }
1769
1770
  }
1770
1771
  if (isNullOrUndefined(this.parent.rowTemplate)) {
@@ -2089,7 +2090,7 @@ var DataManipulation = /** @__PURE__ @class */ (function () {
2089
2090
  }
2090
2091
  }
2091
2092
  else {
2092
- if (!isNullOrUndefined(records)) {
2093
+ if (!isNullOrUndefined(records) && !((this.parent.loadChildOnDemand) && isCountRequired(this.parent) && !isNullOrUndefined(this.parent['dataResults']['expandRecord']))) {
2093
2094
  this.convertToFlatData(records);
2094
2095
  }
2095
2096
  }
@@ -2243,8 +2244,8 @@ var DataManipulation = /** @__PURE__ @class */ (function () {
2243
2244
  if (!Object.prototype.hasOwnProperty.call(currentData, 'index')) {
2244
2245
  currentData.index = this.storedIndex;
2245
2246
  }
2246
- if ((!isNullOrUndefined(currentData[this.parent.childMapping]) && !isCountRequired(this.parent)) || ((currentData[this.parent.hasChildMapping]) &&
2247
- isCountRequired(this.parent) && (this.parent.initialRender || isNullOrUndefined(this.parent['dataResults'].result) || this.parent.enableInfiniteScrolling))) {
2247
+ if ((!isNullOrUndefined(currentData[this.parent.childMapping]) && !isCountRequired(this.parent)) ||
2248
+ ((currentData[this.parent.hasChildMapping]) && isCountRequired(this.parent))) {
2248
2249
  currentData.hasChildRecords = true;
2249
2250
  if (this.parent.enableCollapseAll || !isNullOrUndefined(this.parent.dataStateChange)
2250
2251
  && isNullOrUndefined(currentData[this.parent.childMapping])) {
@@ -4326,7 +4327,7 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
4326
4327
  }
4327
4328
  _this.notify('actionBegin', { editAction: args });
4328
4329
  if (!isRemoteData(_this) && !isNullOrUndefined(_this.filterModule) && !isCountRequired(_this)
4329
- && (_this.grid.filterSettings.columns.length === 0 || _this.grid.searchSettings.key.length === 0)) {
4330
+ && (_this.grid.filterSettings.columns.length === 0 && _this.grid.searchSettings.key.length === 0)) {
4330
4331
  _this.notify('clearFilters', { flatData: _this.grid.dataSource });
4331
4332
  _this.grid.setProperties({ dataSource: _this.dataResults.result }, true);
4332
4333
  if (isNullOrUndefined(_this.grid['changedProperties'].dataSource)) {
@@ -6037,11 +6038,13 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
6037
6038
  }
6038
6039
  });
6039
6040
  if (rows.length) {
6040
- if (action === 'collapse') {
6041
- this.collapseRow(rows[0]);
6042
- }
6043
- else {
6044
- this.expandRow(rows[0]);
6041
+ for (var i = 0; i < rows.length; i++) {
6042
+ if (action === 'collapse') {
6043
+ this.collapseRow(rows[i]);
6044
+ }
6045
+ else {
6046
+ this.expandRow(rows[i]);
6047
+ }
6045
6048
  }
6046
6049
  }
6047
6050
  else if (this.allowPaging) {
@@ -6070,7 +6073,7 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
6070
6073
  return e.parentUniqueID === record.uniqueID;
6071
6074
  });
6072
6075
  var targetEle;
6073
- if (!isRemoteData(this) && action === 'expand' && this.isSelfReference && isCountRequired(this) && !childRecords.length) {
6076
+ if ((!isRemoteData(this) && action === 'expand' && this.isSelfReference && isCountRequired(this) && !childRecords.length) || (action === 'collapse' || (this.isExpandAll && this.loadChildOnDemand) && !isRemoteData(this) && this.isSelfReference && isCountRequired(this))) {
6074
6077
  this.updateChildOnDemand(expandingArgs);
6075
6078
  }
6076
6079
  var gridRows = this.getRows();
@@ -6164,10 +6167,34 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
6164
6167
  }
6165
6168
  this.notify('rowExpandCollapse', { detailrows: detailrows, action: displayAction, record: record, row: row });
6166
6169
  this.updateAltRow(gridRows);
6170
+ this.updateGridRowsVisible();
6167
6171
  }
6168
6172
  };
6173
+ TreeGrid.prototype.updateGridRowsVisible = function () {
6174
+ var rowsToRefresh = this.grid.getRowsObject();
6175
+ var rows = this.getRows();
6176
+ for (var i = 0; i < rows.length; i++) {
6177
+ for (var j = 0; j < rowsToRefresh.length; j++) {
6178
+ if (rows[i].dataset.uid === rowsToRefresh[j].uid) {
6179
+ rowsToRefresh[j].visible = rows[i].style.display === 'none' ? false : true;
6180
+ }
6181
+ }
6182
+ }
6183
+ this.grid.notify('refresh-Expand-and-Collapse', { rows: rowsToRefresh });
6184
+ };
6169
6185
  TreeGrid.prototype.updateChildOnDemand = function (expandingArgs) {
6170
6186
  var _this = this;
6187
+ if (expandingArgs.requestType === 'collapse' && isCountRequired(this)) {
6188
+ var flatDataRecords = this.flatData.slice();
6189
+ for (var i = 0; i < flatDataRecords.length; i++) {
6190
+ if (flatDataRecords[i]['parentUniqueID'] === expandingArgs.data['uniqueID']) {
6191
+ flatDataRecords.splice(i, 1);
6192
+ i = i - 1;
6193
+ }
6194
+ }
6195
+ this.dataResults.result = flatDataRecords;
6196
+ return;
6197
+ }
6171
6198
  var deff = new Deferred();
6172
6199
  var childDataBind = 'childDataBind';
6173
6200
  expandingArgs[childDataBind] = deff.resolve;
@@ -6175,7 +6202,12 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
6175
6202
  this.trigger(dataStateChange, expandingArgs);
6176
6203
  deff.promise.then(function () {
6177
6204
  if (expandingArgs.childData.length) {
6178
- _this.flatData = _this.infiniteScrollData;
6205
+ if (isCountRequired(_this)) {
6206
+ _this.flatData = _this.dataResults.result;
6207
+ }
6208
+ if (_this.enableInfiniteScrolling && isCountRequired(_this)) {
6209
+ _this.flatData = _this.infiniteScrollData;
6210
+ }
6179
6211
  var currentData = (_this.flatData);
6180
6212
  var index = 0;
6181
6213
  for (var i = 0; i < currentData.length; i++) {
@@ -6210,7 +6242,13 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
6210
6242
  (childData[i][_this.hasChildMapping] && isCountRequired(_this))) {
6211
6243
  childData[i].hasChildRecords = true;
6212
6244
  }
6213
- currentData.splice(index + 1 + i, record[_this.childMapping] && record[_this.childMapping][i] ? 1 : 0, childData[i]);
6245
+ if (isCountRequired(_this) && record[_this.childMapping] && record[_this.childMapping][i]) {
6246
+ currentData.splice(index + 1 + i, 0, childData[i]);
6247
+ }
6248
+ else {
6249
+ currentData.splice(index + 1 + i, record[_this.childMapping] &&
6250
+ record[_this.childMapping][i] ? 1 : 0, childData[i]);
6251
+ }
6214
6252
  }
6215
6253
  else {
6216
6254
  currentData.splice(index + 1 + i, 1);
@@ -6224,6 +6262,10 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
6224
6262
  data_1.push(expandingArgs.childData[j]);
6225
6263
  }
6226
6264
  }
6265
+ if (isCountRequired(_this) && _this.loadChildOnDemand && expandingArgs.requestType === 'expand') {
6266
+ _this.dataResults['expandRecord'] = {};
6267
+ _this.dataResults['expandRecord'] = expandingArgs.data;
6268
+ }
6227
6269
  _this.isExpandRefresh = true;
6228
6270
  var scrollHeightBeforeRefresh = _this.getContentTable().parentElement.scrollTop;
6229
6271
  _this.grid.refresh();
@@ -12744,7 +12786,7 @@ var TreeInterSectionObserver = /** @__PURE__ @class */ (function (_super) {
12744
12786
  var movableEle = 'movableEle';
12745
12787
  var element = 'element';
12746
12788
  var fromWheel = 'fromWheel';
12747
- var debounced100 = debounce(callback, delay);
12789
+ //const debounced100: Function = debounce(callback, delay);
12748
12790
  var debounced50 = debounce(callback, 50);
12749
12791
  this[options].prevTop = this[options].prevLeft = 0;
12750
12792
  return function (e) {
@@ -12793,9 +12835,12 @@ var TreeInterSectionObserver = /** @__PURE__ @class */ (function (_super) {
12793
12835
  fn({ direction: direction, sentinel: current, offset: { top: top, left: left },
12794
12836
  focusElement: document.activeElement });
12795
12837
  }
12796
- else
12797
- callback({ direction: direction, sentinel: current, offset: { top: top, left: left },
12798
- focusElement: document.activeElement });
12838
+ else {
12839
+ callback({
12840
+ direction: direction, sentinel: current, offset: { top: top, left: left },
12841
+ focusElement: document.activeElement
12842
+ });
12843
+ }
12799
12844
  }
12800
12845
  }
12801
12846
  _this[fromWheel] = false;