@syncfusion/ej2-treegrid 20.3.48 → 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.
@@ -1760,7 +1760,12 @@ var Render = /** @__PURE__ @class */ (function () {
1760
1760
  args.cell.querySelector('.e-treecell').innerHTML = summaryData;
1761
1761
  }
1762
1762
  else {
1763
- args.cell.innerHTML = summaryData;
1763
+ if (args.column.template) {
1764
+ args.cell.innerHTML = null;
1765
+ }
1766
+ else {
1767
+ args.cell.innerHTML = summaryData;
1768
+ }
1764
1769
  }
1765
1770
  }
1766
1771
  if (isNullOrUndefined(this.parent.rowTemplate)) {
@@ -2085,7 +2090,7 @@ var DataManipulation = /** @__PURE__ @class */ (function () {
2085
2090
  }
2086
2091
  }
2087
2092
  else {
2088
- if (!isNullOrUndefined(records)) {
2093
+ if (!isNullOrUndefined(records) && !((this.parent.loadChildOnDemand) && isCountRequired(this.parent) && !isNullOrUndefined(this.parent['dataResults']['expandRecord']))) {
2089
2094
  this.convertToFlatData(records);
2090
2095
  }
2091
2096
  }
@@ -2239,8 +2244,8 @@ var DataManipulation = /** @__PURE__ @class */ (function () {
2239
2244
  if (!Object.prototype.hasOwnProperty.call(currentData, 'index')) {
2240
2245
  currentData.index = this.storedIndex;
2241
2246
  }
2242
- if ((!isNullOrUndefined(currentData[this.parent.childMapping]) && !isCountRequired(this.parent)) || ((currentData[this.parent.hasChildMapping]) &&
2243
- 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))) {
2244
2249
  currentData.hasChildRecords = true;
2245
2250
  if (this.parent.enableCollapseAll || !isNullOrUndefined(this.parent.dataStateChange)
2246
2251
  && isNullOrUndefined(currentData[this.parent.childMapping])) {
@@ -4322,7 +4327,7 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
4322
4327
  }
4323
4328
  _this.notify('actionBegin', { editAction: args });
4324
4329
  if (!isRemoteData(_this) && !isNullOrUndefined(_this.filterModule) && !isCountRequired(_this)
4325
- && (_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)) {
4326
4331
  _this.notify('clearFilters', { flatData: _this.grid.dataSource });
4327
4332
  _this.grid.setProperties({ dataSource: _this.dataResults.result }, true);
4328
4333
  if (isNullOrUndefined(_this.grid['changedProperties'].dataSource)) {
@@ -6033,11 +6038,13 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
6033
6038
  }
6034
6039
  });
6035
6040
  if (rows.length) {
6036
- if (action === 'collapse') {
6037
- this.collapseRow(rows[0]);
6038
- }
6039
- else {
6040
- 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
+ }
6041
6048
  }
6042
6049
  }
6043
6050
  else if (this.allowPaging) {
@@ -6066,7 +6073,7 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
6066
6073
  return e.parentUniqueID === record.uniqueID;
6067
6074
  });
6068
6075
  var targetEle;
6069
- 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))) {
6070
6077
  this.updateChildOnDemand(expandingArgs);
6071
6078
  }
6072
6079
  var gridRows = this.getRows();
@@ -6160,10 +6167,34 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
6160
6167
  }
6161
6168
  this.notify('rowExpandCollapse', { detailrows: detailrows, action: displayAction, record: record, row: row });
6162
6169
  this.updateAltRow(gridRows);
6170
+ this.updateGridRowsVisible();
6163
6171
  }
6164
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
+ };
6165
6185
  TreeGrid.prototype.updateChildOnDemand = function (expandingArgs) {
6166
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
+ }
6167
6198
  var deff = new Deferred();
6168
6199
  var childDataBind = 'childDataBind';
6169
6200
  expandingArgs[childDataBind] = deff.resolve;
@@ -6171,7 +6202,12 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
6171
6202
  this.trigger(dataStateChange, expandingArgs);
6172
6203
  deff.promise.then(function () {
6173
6204
  if (expandingArgs.childData.length) {
6174
- _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
+ }
6175
6211
  var currentData = (_this.flatData);
6176
6212
  var index = 0;
6177
6213
  for (var i = 0; i < currentData.length; i++) {
@@ -6206,7 +6242,13 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
6206
6242
  (childData[i][_this.hasChildMapping] && isCountRequired(_this))) {
6207
6243
  childData[i].hasChildRecords = true;
6208
6244
  }
6209
- 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
+ }
6210
6252
  }
6211
6253
  else {
6212
6254
  currentData.splice(index + 1 + i, 1);
@@ -6220,6 +6262,10 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
6220
6262
  data_1.push(expandingArgs.childData[j]);
6221
6263
  }
6222
6264
  }
6265
+ if (isCountRequired(_this) && _this.loadChildOnDemand && expandingArgs.requestType === 'expand') {
6266
+ _this.dataResults['expandRecord'] = {};
6267
+ _this.dataResults['expandRecord'] = expandingArgs.data;
6268
+ }
6223
6269
  _this.isExpandRefresh = true;
6224
6270
  var scrollHeightBeforeRefresh = _this.getContentTable().parentElement.scrollTop;
6225
6271
  _this.grid.refresh();
@@ -8439,7 +8485,12 @@ var RowDD$1 = /** @__PURE__ @class */ (function () {
8439
8485
  }
8440
8486
  length = record.childRecords.length;
8441
8487
  for (var i = 0; i < length; i++) {
8442
- currentRecord = getValue('uniqueIDCollection.' + record.childRecords[i].uniqueID, tObj);
8488
+ if (!this.isMultipleGrid) {
8489
+ currentRecord = getValue('uniqueIDCollection.' + record.childRecords[i].uniqueID, tObj);
8490
+ }
8491
+ else {
8492
+ currentRecord = record.childRecords[i];
8493
+ }
8443
8494
  count++;
8444
8495
  tObj.flatData.splice(count, 0, currentRecord);
8445
8496
  setValue('uniqueIDCollection.' + currentRecord.uniqueID, currentRecord, this.parent);
@@ -8461,7 +8512,12 @@ var RowDD$1 = /** @__PURE__ @class */ (function () {
8461
8512
  }
8462
8513
  length = record.childRecords.length;
8463
8514
  for (var i = 0; i < length; i++) {
8464
- currentRecord = getValue('uniqueIDCollection.' + record.childRecords[i].uniqueID, this.parent);
8515
+ if (!this.isMultipleGrid) {
8516
+ currentRecord = getValue('uniqueIDCollection.' + record.childRecords[i].uniqueID, this.parent);
8517
+ }
8518
+ else {
8519
+ currentRecord = record.childRecords[i];
8520
+ }
8465
8521
  var parentData = void 0;
8466
8522
  if (record.parentItem) {
8467
8523
  parentData = getParentData(this.parent, record.parentItem.uniqueID);
@@ -8759,7 +8815,11 @@ var TreeVirtualRowModelGenerator = /** @__PURE__ @class */ (function (_super) {
8759
8815
  var info = this.getDataInfo();
8760
8816
  if (!isNullOrUndefined(notifyArgs.virtualInfo)) {
8761
8817
  if (notifyArgs.virtualInfo.direction !== 'right' && notifyArgs.virtualInfo.direction !== 'left') {
8762
- notifyArgs.virtualInfo.blockIndexes = info.blockIndexes;
8818
+ if (!((this.parent.dataSource instanceof DataManager && this.parent.dataSource.dataSource.url !== undefined
8819
+ && !this.parent.dataSource.dataSource.offline && this.parent.dataSource.dataSource.url !== '') || isCountRequired(this.parent))
8820
+ || notifyArgs.virtualInfo.blockIndexes.length === 1) {
8821
+ notifyArgs.virtualInfo.blockIndexes = info.blockIndexes;
8822
+ }
8763
8823
  }
8764
8824
  else {
8765
8825
  notifyArgs.virtualInfo.blockIndexes = this.getBlockIndexes(notifyArgs.virtualInfo.page);
@@ -12255,7 +12315,7 @@ var VirtualTreeContentRenderer = /** @__PURE__ @class */ (function (_super) {
12255
12315
  this.parent[action]('data-ready', this.onDataReady, this);
12256
12316
  this.parent[action]('refresh-virtual-block', this.refreshContentRows, this);
12257
12317
  this.fn = function () {
12258
- _this.observers.observes(function (scrollArgs) { return _this.scrollListeners(scrollArgs); }, _this.onEnteredAction());
12318
+ _this.observers.observes(function (scrollArgs) { return _this.scrollListeners(scrollArgs); }, _this.onEnteredAction(), _this.parent);
12259
12319
  _this.parent.off('content-ready', _this.fn);
12260
12320
  };
12261
12321
  this.parent.addEventListener('dataBound', this.dataBoundEvent.bind(this));
@@ -12584,7 +12644,9 @@ var VirtualTreeContentRenderer = /** @__PURE__ @class */ (function (_super) {
12584
12644
  }
12585
12645
  }
12586
12646
  if (((downScroll && (scrollArgs.offset.top < (this.parent.getRowHeight() * this.totalRecords)))
12587
- || (upScroll)) || (scrollArgs.direction === 'right' || scrollArgs.direction === 'left')) {
12647
+ || (upScroll)) || (scrollArgs.direction === 'right' || scrollArgs.direction === 'left') ||
12648
+ ((this.parent.dataSource instanceof DataManager && this.parent.dataSource.dataSource.url !== undefined
12649
+ && !this.parent.dataSource.dataSource.offline && this.parent.dataSource.dataSource.url !== '') || isCountRequired(this.parent))) {
12588
12650
  var viewInfo = this.currentInfo = getValue('getInfoFromView', this).apply(this, [scrollArgs.direction, info, scrollArgs.offset]);
12589
12651
  this.previousInfo = viewInfo;
12590
12652
  this.parent.setColumnIndexesInView(this.parent.enableColumnVirtualization ? viewInfo.columnIndexes : []);
@@ -12704,27 +12766,27 @@ var TreeInterSectionObserver = /** @__PURE__ @class */ (function (_super) {
12704
12766
  _this.timer = 0;
12705
12767
  return _this;
12706
12768
  }
12707
- TreeInterSectionObserver.prototype.observes = function (callback, onEnterCallback) {
12769
+ TreeInterSectionObserver.prototype.observes = function (callback, onEnterCallback, instance) {
12708
12770
  var containerRect = 'containerRect';
12709
12771
  _super.prototype[containerRect] = getValue('options', this).container.getBoundingClientRect();
12710
- EventHandler.add(getValue('options', this).container, 'scroll', this.virtualScrollHandlers(callback, onEnterCallback), this);
12772
+ EventHandler.add(getValue('options', this).container, 'scroll', this.virtualScrollHandlers(callback, onEnterCallback, instance), this);
12711
12773
  if (getValue('options', this).movableContainer) {
12712
12774
  var movableContainerRect = 'movableContainerRect';
12713
12775
  _super.prototype[movableContainerRect] = getValue('options', this).movableContainer.getBoundingClientRect();
12714
- EventHandler.add(getValue('options', this).movableContainer, 'scroll', this.virtualScrollHandlers(callback, onEnterCallback), this);
12776
+ EventHandler.add(getValue('options', this).movableContainer, 'scroll', this.virtualScrollHandlers(callback, onEnterCallback, instance), this);
12715
12777
  }
12716
12778
  };
12717
12779
  TreeInterSectionObserver.prototype.clear = function () {
12718
12780
  this.lastPos = null;
12719
12781
  };
12720
- TreeInterSectionObserver.prototype.virtualScrollHandlers = function (callback, onEnterCallback) {
12782
+ TreeInterSectionObserver.prototype.virtualScrollHandlers = function (callback, onEnterCallback, instance) {
12721
12783
  var _this = this;
12722
12784
  var delay = Browser.info.name === 'chrome' ? 200 : 100;
12723
12785
  var options = 'options';
12724
12786
  var movableEle = 'movableEle';
12725
12787
  var element = 'element';
12726
12788
  var fromWheel = 'fromWheel';
12727
- var debounced100 = debounce(callback, delay);
12789
+ //const debounced100: Function = debounce(callback, delay);
12728
12790
  var debounced50 = debounce(callback, 50);
12729
12791
  this[options].prevTop = this[options].prevLeft = 0;
12730
12792
  return function (e) {
@@ -12762,15 +12824,23 @@ var TreeInterSectionObserver = /** @__PURE__ @class */ (function (_super) {
12762
12824
  }
12763
12825
  }
12764
12826
  if (check) {
12765
- var fn = debounced100;
12827
+ var fn = debounced50;
12766
12828
  if (current.axis === 'X') {
12767
- fn = debounced50;
12768
12829
  fn({ direction: direction, sentinel: current, offset: { top: top, left: left },
12769
12830
  focusElement: document.activeElement });
12770
12831
  }
12771
12832
  else {
12772
- callback({ direction: direction, sentinel: current, offset: { top: top, left: left },
12773
- focusElement: document.activeElement });
12833
+ if ((instance.dataSource instanceof DataManager && instance.dataSource.dataSource.url !== undefined
12834
+ && !instance.dataSource.dataSource.offline && instance.dataSource.dataSource.url !== '') || isCountRequired(instance)) {
12835
+ fn({ direction: direction, sentinel: current, offset: { top: top, left: left },
12836
+ focusElement: document.activeElement });
12837
+ }
12838
+ else {
12839
+ callback({
12840
+ direction: direction, sentinel: current, offset: { top: top, left: left },
12841
+ focusElement: document.activeElement
12842
+ });
12843
+ }
12774
12844
  }
12775
12845
  }
12776
12846
  _this[fromWheel] = false;