@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.
@@ -1647,8 +1647,9 @@ class Render {
1647
1647
  if (args.column.template) {
1648
1648
  args.cell.innerHTML = null;
1649
1649
  }
1650
- else
1650
+ else {
1651
1651
  args.cell.innerHTML = summaryData;
1652
+ }
1652
1653
  }
1653
1654
  }
1654
1655
  if (isNullOrUndefined(this.parent.rowTemplate)) {
@@ -1970,7 +1971,7 @@ class DataManipulation {
1970
1971
  }
1971
1972
  }
1972
1973
  else {
1973
- if (!isNullOrUndefined(records)) {
1974
+ if (!isNullOrUndefined(records) && !((this.parent.loadChildOnDemand) && isCountRequired(this.parent) && !isNullOrUndefined(this.parent['dataResults']['expandRecord']))) {
1974
1975
  this.convertToFlatData(records);
1975
1976
  }
1976
1977
  }
@@ -2121,8 +2122,8 @@ class DataManipulation {
2121
2122
  if (!Object.prototype.hasOwnProperty.call(currentData, 'index')) {
2122
2123
  currentData.index = this.storedIndex;
2123
2124
  }
2124
- if ((!isNullOrUndefined(currentData[this.parent.childMapping]) && !isCountRequired(this.parent)) || ((currentData[this.parent.hasChildMapping]) &&
2125
- isCountRequired(this.parent) && (this.parent.initialRender || isNullOrUndefined(this.parent['dataResults'].result) || this.parent.enableInfiniteScrolling))) {
2125
+ if ((!isNullOrUndefined(currentData[this.parent.childMapping]) && !isCountRequired(this.parent)) ||
2126
+ ((currentData[this.parent.hasChildMapping]) && isCountRequired(this.parent))) {
2126
2127
  currentData.hasChildRecords = true;
2127
2128
  if (this.parent.enableCollapseAll || !isNullOrUndefined(this.parent.dataStateChange)
2128
2129
  && isNullOrUndefined(currentData[this.parent.childMapping])) {
@@ -4074,7 +4075,7 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
4074
4075
  }
4075
4076
  this.notify('actionBegin', { editAction: args });
4076
4077
  if (!isRemoteData(this) && !isNullOrUndefined(this.filterModule) && !isCountRequired(this)
4077
- && (this.grid.filterSettings.columns.length === 0 || this.grid.searchSettings.key.length === 0)) {
4078
+ && (this.grid.filterSettings.columns.length === 0 && this.grid.searchSettings.key.length === 0)) {
4078
4079
  this.notify('clearFilters', { flatData: this.grid.dataSource });
4079
4080
  this.grid.setProperties({ dataSource: this.dataResults.result }, true);
4080
4081
  if (isNullOrUndefined(this.grid['changedProperties'].dataSource)) {
@@ -5769,11 +5770,13 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
5769
5770
  }
5770
5771
  });
5771
5772
  if (rows.length) {
5772
- if (action === 'collapse') {
5773
- this.collapseRow(rows[0]);
5774
- }
5775
- else {
5776
- this.expandRow(rows[0]);
5773
+ for (let i = 0; i < rows.length; i++) {
5774
+ if (action === 'collapse') {
5775
+ this.collapseRow(rows[i]);
5776
+ }
5777
+ else {
5778
+ this.expandRow(rows[i]);
5779
+ }
5777
5780
  }
5778
5781
  }
5779
5782
  else if (this.allowPaging) {
@@ -5802,7 +5805,7 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
5802
5805
  return e.parentUniqueID === record.uniqueID;
5803
5806
  });
5804
5807
  let targetEle;
5805
- if (!isRemoteData(this) && action === 'expand' && this.isSelfReference && isCountRequired(this) && !childRecords.length) {
5808
+ if ((!isRemoteData(this) && action === 'expand' && this.isSelfReference && isCountRequired(this) && !childRecords.length) || (action === 'collapse' || (this.isExpandAll && this.loadChildOnDemand) && !isRemoteData(this) && this.isSelfReference && isCountRequired(this))) {
5806
5809
  this.updateChildOnDemand(expandingArgs);
5807
5810
  }
5808
5811
  let gridRows = this.getRows();
@@ -5894,9 +5897,33 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
5894
5897
  }
5895
5898
  this.notify('rowExpandCollapse', { detailrows: detailrows, action: displayAction, record: record, row: row });
5896
5899
  this.updateAltRow(gridRows);
5900
+ this.updateGridRowsVisible();
5897
5901
  }
5898
5902
  }
5903
+ updateGridRowsVisible() {
5904
+ const rowsToRefresh = this.grid.getRowsObject();
5905
+ const rows = this.getRows();
5906
+ for (let i = 0; i < rows.length; i++) {
5907
+ for (let j = 0; j < rowsToRefresh.length; j++) {
5908
+ if (rows[i].dataset.uid === rowsToRefresh[j].uid) {
5909
+ rowsToRefresh[j].visible = rows[i].style.display === 'none' ? false : true;
5910
+ }
5911
+ }
5912
+ }
5913
+ this.grid.notify('refresh-Expand-and-Collapse', { rows: rowsToRefresh });
5914
+ }
5899
5915
  updateChildOnDemand(expandingArgs) {
5916
+ if (expandingArgs.requestType === 'collapse' && isCountRequired(this)) {
5917
+ const flatDataRecords = [...this.flatData];
5918
+ for (let i = 0; i < flatDataRecords.length; i++) {
5919
+ if (flatDataRecords[i]['parentUniqueID'] === expandingArgs.data['uniqueID']) {
5920
+ flatDataRecords.splice(i, 1);
5921
+ i = i - 1;
5922
+ }
5923
+ }
5924
+ this.dataResults.result = flatDataRecords;
5925
+ return;
5926
+ }
5900
5927
  const deff = new Deferred();
5901
5928
  const childDataBind = 'childDataBind';
5902
5929
  expandingArgs[childDataBind] = deff.resolve;
@@ -5904,7 +5931,12 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
5904
5931
  this.trigger(dataStateChange, expandingArgs);
5905
5932
  deff.promise.then(() => {
5906
5933
  if (expandingArgs.childData.length) {
5907
- this.flatData = this.infiniteScrollData;
5934
+ if (isCountRequired(this)) {
5935
+ this.flatData = this.dataResults.result;
5936
+ }
5937
+ if (this.enableInfiniteScrolling && isCountRequired(this)) {
5938
+ this.flatData = this.infiniteScrollData;
5939
+ }
5908
5940
  const currentData = (this.flatData);
5909
5941
  let index = 0;
5910
5942
  for (let i = 0; i < currentData.length; i++) {
@@ -5939,7 +5971,13 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
5939
5971
  (childData[i][this.hasChildMapping] && isCountRequired(this))) {
5940
5972
  childData[i].hasChildRecords = true;
5941
5973
  }
5942
- currentData.splice(index + 1 + i, record[this.childMapping] && record[this.childMapping][i] ? 1 : 0, childData[i]);
5974
+ if (isCountRequired(this) && record[this.childMapping] && record[this.childMapping][i]) {
5975
+ currentData.splice(index + 1 + i, 0, childData[i]);
5976
+ }
5977
+ else {
5978
+ currentData.splice(index + 1 + i, record[this.childMapping] &&
5979
+ record[this.childMapping][i] ? 1 : 0, childData[i]);
5980
+ }
5943
5981
  }
5944
5982
  else {
5945
5983
  currentData.splice(index + 1 + i, 1);
@@ -5953,6 +5991,10 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
5953
5991
  data.push(expandingArgs.childData[j]);
5954
5992
  }
5955
5993
  }
5994
+ if (isCountRequired(this) && this.loadChildOnDemand && expandingArgs.requestType === 'expand') {
5995
+ this.dataResults['expandRecord'] = {};
5996
+ this.dataResults['expandRecord'] = expandingArgs.data;
5997
+ }
5956
5998
  this.isExpandRefresh = true;
5957
5999
  const scrollHeightBeforeRefresh = this.getContentTable().parentElement.scrollTop;
5958
6000
  this.grid.refresh();
@@ -12363,7 +12405,7 @@ class TreeInterSectionObserver extends InterSectionObserver {
12363
12405
  const movableEle = 'movableEle';
12364
12406
  const element = 'element';
12365
12407
  const fromWheel = 'fromWheel';
12366
- const debounced100 = debounce(callback, delay);
12408
+ //const debounced100: Function = debounce(callback, delay);
12367
12409
  const debounced50 = debounce(callback, 50);
12368
12410
  this[options].prevTop = this[options].prevLeft = 0;
12369
12411
  return (e) => {
@@ -12401,7 +12443,7 @@ class TreeInterSectionObserver extends InterSectionObserver {
12401
12443
  }
12402
12444
  }
12403
12445
  if (check) {
12404
- let fn = debounced50;
12446
+ const fn = debounced50;
12405
12447
  if (current.axis === 'X') {
12406
12448
  fn({ direction: direction, sentinel: current, offset: { top: top, left: left },
12407
12449
  focusElement: document.activeElement });
@@ -12412,9 +12454,12 @@ class TreeInterSectionObserver extends InterSectionObserver {
12412
12454
  fn({ direction: direction, sentinel: current, offset: { top: top, left: left },
12413
12455
  focusElement: document.activeElement });
12414
12456
  }
12415
- else
12416
- callback({ direction: direction, sentinel: current, offset: { top: top, left: left },
12417
- focusElement: document.activeElement });
12457
+ else {
12458
+ callback({
12459
+ direction: direction, sentinel: current, offset: { top: top, left: left },
12460
+ focusElement: document.activeElement
12461
+ });
12462
+ }
12418
12463
  }
12419
12464
  }
12420
12465
  this[fromWheel] = false;