@syncfusion/ej2-treegrid 22.1.36 → 22.1.37

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.
@@ -5884,28 +5884,70 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
5884
5884
  * @returns {void}
5885
5885
  */
5886
5886
  expandRow(row, record, key, level) {
5887
+ let parentRec = this.parentData;
5888
+ if (!this.enableVirtualization) {
5889
+ parentRec = this.flatData.filter((e) => {
5890
+ return e.hasChildRecords;
5891
+ });
5892
+ }
5887
5893
  record = this.getCollapseExpandRecords(row, record);
5888
5894
  if (!isNullOrUndefined(row) && row.cells[0].classList.contains('e-lastrowcell')) {
5889
5895
  this.lastRowBorder(row, false);
5890
5896
  }
5891
- const args = { data: record, row: row, cancel: false };
5892
- this.trigger(expanding, args, (expandingArgs) => {
5893
- if (!expandingArgs.cancel) {
5894
- this.expandCollapse('expand', row, record);
5895
- if (expandingArgs.expandAll) {
5896
- this.expandCollapseAllChildren(record, 'expand', key, level);
5897
- }
5898
- const children = 'Children';
5899
- if (!(isRemoteData(this) && !isOffline(this)) && (!isCountRequired(this) || !isNullOrUndefined(record[`${children}`]))) {
5900
- const collapseArgs = { data: record, row: row };
5901
- this.setHeightForFrozenContent();
5902
- if (!isNullOrUndefined(this.expandStateMapping)) {
5903
- this.updateExpandStateMapping(collapseArgs.data, true);
5897
+ if (this.isExpandAll && !isRemoteData(this)) {
5898
+ const args = { data: parentRec, row: row, cancel: false };
5899
+ let pagerValuePresent = false;
5900
+ if (this.grid.pagerModule && !isNullOrUndefined(this.grid.pagerModule.pagerObj.pagerdropdownModule)) {
5901
+ pagerValuePresent = this.grid.pagerModule.pagerObj.pagerdropdownModule['dropDownListObject'].value ? true : false;
5902
+ }
5903
+ if (!this.isExpandingEventTriggered) {
5904
+ this.trigger(expanding, args, (expandingArgs) => {
5905
+ this.expandAllPrevent = expandingArgs.cancel;
5906
+ if (!expandingArgs.cancel) {
5907
+ if (expandingArgs.expandAll) {
5908
+ this.expandCollapseAllChildren(record, 'expand', key, level);
5909
+ }
5910
+ this.expandRows(row, record, parentRec, key, level);
5911
+ }
5912
+ });
5913
+ }
5914
+ else if ((!this.allowPaging || (pagerValuePresent && this.grid.pagerModule.pagerObj.pagerdropdownModule['dropDownListObject'].value === 'All')) &&
5915
+ !this.expandAllPrevent && this.isExpandingEventTriggered) {
5916
+ this.expandRows(row, record, parentRec, key, level);
5917
+ }
5918
+ this.isExpandingEventTriggered = true;
5919
+ }
5920
+ else if (!this.isExpandAll || (this.isExpandAll && isRemoteData(this))) {
5921
+ const args = { data: record, row: row, cancel: false };
5922
+ this.trigger(expanding, args, (expandingArgs) => {
5923
+ if (!expandingArgs.cancel) {
5924
+ if (expandingArgs.expandAll) {
5925
+ this.expandCollapseAllChildren(record, 'expand', key, level);
5904
5926
  }
5905
- this.trigger(expanded, collapseArgs);
5927
+ this.expandRows(row, record, parentRec, key, level);
5906
5928
  }
5929
+ });
5930
+ }
5931
+ }
5932
+ // Internal method to handle the rows expand
5933
+ expandRows(row, record, parentRec, key, level) {
5934
+ this.expandCollapse('expand', row, record);
5935
+ const children = 'Children';
5936
+ if (!(isRemoteData(this) && !isOffline(this)) && (!isCountRequired(this) || !isNullOrUndefined(record[`${children}`]))) {
5937
+ let expandArgs = { data: record, row: row };
5938
+ this.setHeightForFrozenContent();
5939
+ if (!isNullOrUndefined(this.expandStateMapping)) {
5940
+ this.updateExpandStateMapping(expandArgs.data, true);
5907
5941
  }
5908
- });
5942
+ if (this.isExpandAll && !this.isExpandedEventTriggered) {
5943
+ this.isExpandedEventTriggered = true;
5944
+ expandArgs = { data: parentRec, row: row };
5945
+ this.trigger(expanded, expandArgs);
5946
+ }
5947
+ else if (!this.isExpandAll) {
5948
+ this.trigger(expanded, expandArgs);
5949
+ }
5950
+ }
5909
5951
  }
5910
5952
  expandCollapseAllChildren(record, action, key, level) {
5911
5953
  if ((!isNullOrUndefined(key) && record[this.getPrimaryKeyFieldNames()[0]] !== key) ||
@@ -5962,31 +6004,65 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
5962
6004
  * @returns {void}
5963
6005
  */
5964
6006
  collapseRow(row, record, key) {
6007
+ let parentRec = this.parentData;
6008
+ if (!this.enableVirtualization) {
6009
+ parentRec = this.flatData.filter((e) => {
6010
+ return e.hasChildRecords;
6011
+ });
6012
+ }
5965
6013
  record = this.getCollapseExpandRecords(row, record);
5966
- const args = { data: record, row: row, cancel: false };
5967
- this.trigger(collapsing, args, (collapsingArgs) => {
5968
- if (!collapsingArgs.cancel) {
5969
- if (collapsingArgs.collapseAll) {
5970
- this.expandCollapseAllChildren(record, 'collapse', key);
5971
- }
5972
- this.expandCollapse('collapse', row, record);
5973
- const collapseArgs = { data: record, row: row };
5974
- if (!isRemoteData(this)) {
5975
- this.setHeightForFrozenContent();
5976
- if (!isNullOrUndefined(this.expandStateMapping)) {
5977
- this.updateExpandStateMapping(collapseArgs.data, false);
5978
- }
5979
- this.trigger(collapsed, collapseArgs);
5980
- if (this.enableInfiniteScrolling) {
5981
- const scrollHeight = this.grid.getContent().firstElementChild.scrollHeight;
5982
- const scrollTop = this.grid.getContent().firstElementChild.scrollTop;
5983
- if ((scrollHeight - scrollTop) < this.grid.getRowHeight() + +this.height) {
5984
- this.grid.getContent().firstElementChild.scrollBy(0, this.grid.getRowHeight());
6014
+ if (this.isCollapseAll && !isRemoteData(this)) {
6015
+ const args = { data: parentRec, row: row, cancel: false };
6016
+ if (!this.isCollapsingEventTriggered) {
6017
+ this.trigger(collapsing, args, (collapsingArgs) => {
6018
+ this.collapseAllPrevent = collapsingArgs.cancel;
6019
+ if (!collapsingArgs.cancel) {
6020
+ if (collapsingArgs.collapseAll) {
6021
+ this.expandCollapseAllChildren(record, 'collapse', key);
5985
6022
  }
6023
+ this.collapseRows(row, record, parentRec, key);
5986
6024
  }
6025
+ });
6026
+ }
6027
+ else if (!this.allowPaging && !this.collapseAllPrevent && this.isCollapsingEventTriggered) {
6028
+ this.collapseRows(row, record, parentRec, key);
6029
+ }
6030
+ this.isCollapsingEventTriggered = true;
6031
+ }
6032
+ else if (!this.isCollapseAll || (this.isCollapseAll && isRemoteData(this))) {
6033
+ const args = { data: record, row: row, cancel: false };
6034
+ this.trigger(collapsing, args, (collapsingArgs) => {
6035
+ if (!collapsingArgs.cancel) {
6036
+ this.collapseRows(row, record, parentRec, key);
6037
+ }
6038
+ });
6039
+ }
6040
+ }
6041
+ // Internal method for handling the rows collapse
6042
+ collapseRows(row, record, parentRec, key) {
6043
+ this.expandCollapse('collapse', row, record);
6044
+ let collapseArgs = { data: record, row: row };
6045
+ if (!isRemoteData(this)) {
6046
+ this.setHeightForFrozenContent();
6047
+ if (!isNullOrUndefined(this.expandStateMapping)) {
6048
+ this.updateExpandStateMapping(collapseArgs.data, false);
6049
+ }
6050
+ if (this.isCollapseAll && !this.isCollapsedEventTriggered) {
6051
+ this.isCollapsedEventTriggered = true;
6052
+ collapseArgs = { data: parentRec, row: row };
6053
+ this.trigger(collapsed, collapseArgs);
6054
+ }
6055
+ else if (!this.isCollapseAll) {
6056
+ this.trigger(collapsed, collapseArgs);
6057
+ }
6058
+ if (this.enableInfiniteScrolling) {
6059
+ const scrollHeight = this.grid.getContent().firstElementChild.scrollHeight;
6060
+ const scrollTop = this.grid.getContent().firstElementChild.scrollTop;
6061
+ if ((scrollHeight - scrollTop) < this.grid.getRowHeight() + +this.height) {
6062
+ this.grid.getContent().firstElementChild.scrollBy(0, this.grid.getRowHeight());
5987
6063
  }
5988
6064
  }
5989
- });
6065
+ }
5990
6066
  }
5991
6067
  updateExpandStateMapping(record, state) {
5992
6068
  const totalRecords = record;
@@ -6143,6 +6219,8 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
6143
6219
  * @returns {void}
6144
6220
  */
6145
6221
  expandAll() {
6222
+ this.isExpandedEventTriggered = false;
6223
+ this.isExpandingEventTriggered = false;
6146
6224
  this.expandCollapseAll('expand');
6147
6225
  }
6148
6226
  /**
@@ -6151,6 +6229,8 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
6151
6229
  * @returns {void}
6152
6230
  */
6153
6231
  collapseAll() {
6232
+ this.isCollapsedEventTriggered = false;
6233
+ this.isCollapsingEventTriggered = false;
6154
6234
  this.expandCollapseAll('collapse');
6155
6235
  }
6156
6236
  expandCollapseAll(action) {
@@ -12431,7 +12511,8 @@ class VirtualTreeContentRenderer extends VirtualContentRenderer {
12431
12511
  this.startIndex = 0;
12432
12512
  this.endIndex = this.parent.pageSettings.pageSize - 1;
12433
12513
  }
12434
- if ((this.endIndex - this.startIndex !== this.parent.pageSettings.pageSize) && (this.totalRecords > this.parent.pageSettings.pageSize) &&
12514
+ if ((this.endIndex - this.startIndex !== this.parent.pageSettings.pageSize) &&
12515
+ (this.totalRecords > this.parent.pageSettings.pageSize) &&
12435
12516
  (this.endIndex === this.totalRecords)) {
12436
12517
  args.startIndex = this.endIndex - this.parent.pageSettings.pageSize;
12437
12518
  args.endIndex = this.endIndex;
@@ -12752,6 +12833,7 @@ class VirtualTreeContentRenderer extends VirtualContentRenderer {
12752
12833
  this.translateY = scrollArgs.offset.top - rowHeight * 2;
12753
12834
  }
12754
12835
  else {
12836
+ scrollArgs.offset.top = content$$1.scrollTop;
12755
12837
  this.translateY = scrollArgs.offset.top;
12756
12838
  }
12757
12839
  }
@@ -12772,7 +12854,7 @@ class VirtualTreeContentRenderer extends VirtualContentRenderer {
12772
12854
  lastIndex = nextSetResIndex +
12773
12855
  (this.totalRecords - nextSetResIndex);
12774
12856
  }
12775
- this.startIndex = !isLastBlock || isNullOrUndefined(this["" + selectedRowIndex]) ? lastIndex - this.parent.pageSettings.pageSize : nextSetResIndex;
12857
+ this.startIndex = !isLastBlock || isNullOrUndefined(this['' + selectedRowIndex]) ? lastIndex - this.parent.pageSettings.pageSize : nextSetResIndex;
12776
12858
  this.endIndex = lastIndex;
12777
12859
  if ((nextSetResIndex + this.parent.pageSettings.pageSize) > this.totalRecords && (this.endIndex - this.startIndex) <
12778
12860
  (this.parent.pageSettings.pageSize / 2) && (this.endIndex - nextSetResIndex) < (this.parent.pageSettings.pageSize / 2)) {