@syncfusion/ej2-treegrid 22.1.34 → 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.
@@ -1219,11 +1219,11 @@ class Selection {
1219
1219
  }
1220
1220
  }
1221
1221
  updateSelectedItems(currentRecord, checkState) {
1222
- const record = this.parent.getCurrentViewRecords().filter((e) => {
1222
+ const record = this.parent.grid.currentViewData.filter((e) => {
1223
1223
  return e.uniqueID === currentRecord.uniqueID;
1224
1224
  });
1225
1225
  let checkedRecord;
1226
- const recordIndex = this.parent.getCurrentViewRecords().indexOf(record[0]);
1226
+ const recordIndex = this.parent.grid.currentViewData.indexOf(record[0]);
1227
1227
  const checkboxRecord = getParentData(this.parent, currentRecord.uniqueID);
1228
1228
  const tr = this.parent.getRows()[parseInt(recordIndex.toString(), 10)];
1229
1229
  let checkbox;
@@ -5581,21 +5581,7 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
5581
5581
  this.stackedHeader = true;
5582
5582
  }
5583
5583
  if (this.stackedHeader && this.allowResizing) {
5584
- for (let i = 0; i < this.columns.length; i++) {
5585
- if (!isNullOrUndefined(this.columns[parseInt(i.toString(), 10)].columns)) {
5586
- for (let j = 0; j < this.columns[parseInt(i.toString(), 10)].columns.length; j++) {
5587
- const stackedColumn = this.columns[parseInt(i.toString(), 10)]
5588
- .columns[parseInt(j.toString(), 10)];
5589
- const currentColumn = this.grid.getColumnByField(stackedColumn.field);
5590
- stackedColumn.width = currentColumn.width;
5591
- }
5592
- }
5593
- else if (!isNullOrUndefined(this.columns[parseInt(i.toString(), 10)].field)) {
5594
- const currentColumn = this.grid.getColumnByField(this.columns[parseInt(i.toString(), 10)]
5595
- .field);
5596
- this.columns[parseInt(i.toString(), 10)].width = currentColumn.width;
5597
- }
5598
- }
5584
+ this.updateColumnsWidth(this.columns);
5599
5585
  }
5600
5586
  if (!this.stackedHeader) {
5601
5587
  merge(this.columns, this.columnModel);
@@ -5603,6 +5589,17 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
5603
5589
  this[`${deepMerge}`] = undefined; // Workaround for blazor updateModel
5604
5590
  return this.columnModel;
5605
5591
  }
5592
+ updateColumnsWidth(columns) {
5593
+ columns.forEach((column) => {
5594
+ if (column.columns) {
5595
+ this.updateColumnsWidth(column.columns);
5596
+ }
5597
+ else if (column.field) {
5598
+ const currentColumn = this.grid.getColumnByField(column.field);
5599
+ column.width = currentColumn.width;
5600
+ }
5601
+ });
5602
+ }
5606
5603
  /**
5607
5604
  * Gets the content div of the TreeGrid.
5608
5605
  *
@@ -5655,7 +5652,8 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
5655
5652
  * @isGenericType true
5656
5653
  */
5657
5654
  getCurrentViewRecords() {
5658
- return this.grid.currentViewData;
5655
+ const isSummaryRow = 'isSummaryRow';
5656
+ return this.grid.currentViewData.filter((e) => isNullOrUndefined(e[`${isSummaryRow}`]));
5659
5657
  }
5660
5658
  /**
5661
5659
  * Gets the added, edited,and deleted data before bulk save to the DataSource in batch mode.
@@ -5886,28 +5884,70 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
5886
5884
  * @returns {void}
5887
5885
  */
5888
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
+ }
5889
5893
  record = this.getCollapseExpandRecords(row, record);
5890
5894
  if (!isNullOrUndefined(row) && row.cells[0].classList.contains('e-lastrowcell')) {
5891
5895
  this.lastRowBorder(row, false);
5892
5896
  }
5893
- const args = { data: record, row: row, cancel: false };
5894
- this.trigger(expanding, args, (expandingArgs) => {
5895
- if (!expandingArgs.cancel) {
5896
- this.expandCollapse('expand', row, record);
5897
- if (expandingArgs.expandAll) {
5898
- this.expandCollapseAllChildren(record, 'expand', key, level);
5899
- }
5900
- const children = 'Children';
5901
- if (!(isRemoteData(this) && !isOffline(this)) && (!isCountRequired(this) || !isNullOrUndefined(record[`${children}`]))) {
5902
- const collapseArgs = { data: record, row: row };
5903
- this.setHeightForFrozenContent();
5904
- if (!isNullOrUndefined(this.expandStateMapping)) {
5905
- 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);
5906
5911
  }
5907
- this.trigger(expanded, collapseArgs);
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);
5926
+ }
5927
+ this.expandRows(row, record, parentRec, key, level);
5908
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);
5909
5941
  }
5910
- });
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
+ }
5911
5951
  }
5912
5952
  expandCollapseAllChildren(record, action, key, level) {
5913
5953
  if ((!isNullOrUndefined(key) && record[this.getPrimaryKeyFieldNames()[0]] !== key) ||
@@ -5964,31 +6004,65 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
5964
6004
  * @returns {void}
5965
6005
  */
5966
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
+ }
5967
6013
  record = this.getCollapseExpandRecords(row, record);
5968
- const args = { data: record, row: row, cancel: false };
5969
- this.trigger(collapsing, args, (collapsingArgs) => {
5970
- if (!collapsingArgs.cancel) {
5971
- if (collapsingArgs.collapseAll) {
5972
- this.expandCollapseAllChildren(record, 'collapse', key);
5973
- }
5974
- this.expandCollapse('collapse', row, record);
5975
- const collapseArgs = { data: record, row: row };
5976
- if (!isRemoteData(this)) {
5977
- this.setHeightForFrozenContent();
5978
- if (!isNullOrUndefined(this.expandStateMapping)) {
5979
- this.updateExpandStateMapping(collapseArgs.data, false);
5980
- }
5981
- this.trigger(collapsed, collapseArgs);
5982
- if (this.enableInfiniteScrolling) {
5983
- const scrollHeight = this.grid.getContent().firstElementChild.scrollHeight;
5984
- const scrollTop = this.grid.getContent().firstElementChild.scrollTop;
5985
- if ((scrollHeight - scrollTop) < this.grid.getRowHeight() + +this.height) {
5986
- 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);
5987
6022
  }
6023
+ this.collapseRows(row, record, parentRec, key);
5988
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);
5989
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);
5990
6049
  }
5991
- });
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());
6063
+ }
6064
+ }
6065
+ }
5992
6066
  }
5993
6067
  updateExpandStateMapping(record, state) {
5994
6068
  const totalRecords = record;
@@ -6145,6 +6219,8 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
6145
6219
  * @returns {void}
6146
6220
  */
6147
6221
  expandAll() {
6222
+ this.isExpandedEventTriggered = false;
6223
+ this.isExpandingEventTriggered = false;
6148
6224
  this.expandCollapseAll('expand');
6149
6225
  }
6150
6226
  /**
@@ -6153,6 +6229,8 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
6153
6229
  * @returns {void}
6154
6230
  */
6155
6231
  collapseAll() {
6232
+ this.isCollapsedEventTriggered = false;
6233
+ this.isCollapsingEventTriggered = false;
6156
6234
  this.expandCollapseAll('collapse');
6157
6235
  }
6158
6236
  expandCollapseAll(action) {
@@ -6209,7 +6287,7 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
6209
6287
  }
6210
6288
  expandCollapse(action, row, record, isChild) {
6211
6289
  const expandingArgs = { row: row, data: record, childData: [], requestType: action };
6212
- const childRecords = this.getCurrentViewRecords().filter((e) => {
6290
+ const childRecords = this.grid.currentViewData.filter((e) => {
6213
6291
  return e.parentUniqueID === record.uniqueID;
6214
6292
  });
6215
6293
  let targetEle;
@@ -6223,7 +6301,7 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
6223
6301
  }
6224
6302
  let rowIndex;
6225
6303
  if (isNullOrUndefined(row)) {
6226
- rowIndex = this.getCurrentViewRecords().indexOf(record);
6304
+ rowIndex = this.grid.currentViewData.indexOf(record);
6227
6305
  row = gridRows[parseInt(rowIndex.toString(), 10)];
6228
6306
  }
6229
6307
  else {
@@ -6446,7 +6524,7 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
6446
6524
  }
6447
6525
  localExpand(action, row, record) {
6448
6526
  let rows;
6449
- const childRecords = this.getCurrentViewRecords().filter((e) => {
6527
+ const childRecords = this.grid.currentViewData.filter((e) => {
6450
6528
  return e.parentUniqueID === record.uniqueID;
6451
6529
  });
6452
6530
  if (this.isPixelHeight() && row.cells[0].classList.contains('e-lastrowcell')) {
@@ -6479,7 +6557,7 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
6479
6557
  freezeRightRows = this.getFrozenRightRows().filter((r) => r.querySelector('.e-gridrowindex' + record.index + 'level' + (record.level + 1)));
6480
6558
  }
6481
6559
  const gridRowsObject = this.grid.getRowsObject();
6482
- const currentViewData = this.getCurrentViewRecords();
6560
+ const currentViewData = this.grid.currentViewData;
6483
6561
  const currentRecord = currentViewData.filter((e) => {
6484
6562
  return e.uniqueID === record.uniqueID;
6485
6563
  });
@@ -12433,8 +12511,16 @@ class VirtualTreeContentRenderer extends VirtualContentRenderer {
12433
12511
  this.startIndex = 0;
12434
12512
  this.endIndex = this.parent.pageSettings.pageSize - 1;
12435
12513
  }
12436
- args.startIndex = this.startIndex;
12437
- args.endIndex = this.endIndex;
12514
+ if ((this.endIndex - this.startIndex !== this.parent.pageSettings.pageSize) &&
12515
+ (this.totalRecords > this.parent.pageSettings.pageSize) &&
12516
+ (this.endIndex === this.totalRecords)) {
12517
+ args.startIndex = this.endIndex - this.parent.pageSettings.pageSize;
12518
+ args.endIndex = this.endIndex;
12519
+ }
12520
+ else {
12521
+ args.startIndex = this.startIndex;
12522
+ args.endIndex = this.endIndex;
12523
+ }
12438
12524
  }
12439
12525
  eventListener(action) {
12440
12526
  if (!(this.parent.dataSource instanceof DataManager && this.parent.dataSource.dataSource.url !== undefined
@@ -12747,6 +12833,7 @@ class VirtualTreeContentRenderer extends VirtualContentRenderer {
12747
12833
  this.translateY = scrollArgs.offset.top - rowHeight * 2;
12748
12834
  }
12749
12835
  else {
12836
+ scrollArgs.offset.top = content$$1.scrollTop;
12750
12837
  this.translateY = scrollArgs.offset.top;
12751
12838
  }
12752
12839
  }
@@ -12767,7 +12854,7 @@ class VirtualTreeContentRenderer extends VirtualContentRenderer {
12767
12854
  lastIndex = nextSetResIndex +
12768
12855
  (this.totalRecords - nextSetResIndex);
12769
12856
  }
12770
- this.startIndex = !isLastBlock ? lastIndex - this.parent.pageSettings.pageSize : nextSetResIndex;
12857
+ this.startIndex = !isLastBlock || isNullOrUndefined(this['' + selectedRowIndex]) ? lastIndex - this.parent.pageSettings.pageSize : nextSetResIndex;
12771
12858
  this.endIndex = lastIndex;
12772
12859
  if ((nextSetResIndex + this.parent.pageSettings.pageSize) > this.totalRecords && (this.endIndex - this.startIndex) <
12773
12860
  (this.parent.pageSettings.pageSize / 2) && (this.endIndex - nextSetResIndex) < (this.parent.pageSettings.pageSize / 2)) {
@@ -13387,10 +13474,6 @@ class Freeze$1 {
13387
13474
  getValue('addRenderer', renderer)
13388
13475
  .apply(renderer, [RenderType.Content, new VirtualTreeFreezeRenderer(getValue('grid', this.parent), getValue('serviceLocator', this.parent.grid))]);
13389
13476
  }
13390
- else {
13391
- getValue('addRenderer', renderer)
13392
- .apply(renderer, [RenderType.Content, new FreezeContentRender(getValue('grid', this.parent), getValue('serviceLocator', this.parent.grid))]);
13393
- }
13394
13477
  }
13395
13478
  if (this.parent.getFrozenLeftColumnsCount() || this.parent.getFrozenRightColumnsCount()) {
13396
13479
  getValue('addRenderer', renderer)