@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.
@@ -1337,11 +1337,11 @@ var Selection = /** @__PURE__ @class */ (function () {
1337
1337
  }
1338
1338
  };
1339
1339
  Selection.prototype.updateSelectedItems = function (currentRecord, checkState) {
1340
- var record = this.parent.getCurrentViewRecords().filter(function (e) {
1340
+ var record = this.parent.grid.currentViewData.filter(function (e) {
1341
1341
  return e.uniqueID === currentRecord.uniqueID;
1342
1342
  });
1343
1343
  var checkedRecord;
1344
- var recordIndex = this.parent.getCurrentViewRecords().indexOf(record[0]);
1344
+ var recordIndex = this.parent.grid.currentViewData.indexOf(record[0]);
1345
1345
  var checkboxRecord = getParentData(this.parent, currentRecord.uniqueID);
1346
1346
  var tr = this.parent.getRows()[parseInt(recordIndex.toString(), 10)];
1347
1347
  var checkbox;
@@ -5886,21 +5886,7 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
5886
5886
  this.stackedHeader = true;
5887
5887
  }
5888
5888
  if (this.stackedHeader && this.allowResizing) {
5889
- for (var i = 0; i < this.columns.length; i++) {
5890
- if (!isNullOrUndefined(this.columns[parseInt(i.toString(), 10)].columns)) {
5891
- for (var j = 0; j < this.columns[parseInt(i.toString(), 10)].columns.length; j++) {
5892
- var stackedColumn = this.columns[parseInt(i.toString(), 10)]
5893
- .columns[parseInt(j.toString(), 10)];
5894
- var currentColumn = this.grid.getColumnByField(stackedColumn.field);
5895
- stackedColumn.width = currentColumn.width;
5896
- }
5897
- }
5898
- else if (!isNullOrUndefined(this.columns[parseInt(i.toString(), 10)].field)) {
5899
- var currentColumn = this.grid.getColumnByField(this.columns[parseInt(i.toString(), 10)]
5900
- .field);
5901
- this.columns[parseInt(i.toString(), 10)].width = currentColumn.width;
5902
- }
5903
- }
5889
+ this.updateColumnsWidth(this.columns);
5904
5890
  }
5905
5891
  if (!this.stackedHeader) {
5906
5892
  merge(this.columns, this.columnModel);
@@ -5908,6 +5894,18 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
5908
5894
  this["" + deepMerge] = undefined; // Workaround for blazor updateModel
5909
5895
  return this.columnModel;
5910
5896
  };
5897
+ TreeGrid.prototype.updateColumnsWidth = function (columns) {
5898
+ var _this = this;
5899
+ columns.forEach(function (column) {
5900
+ if (column.columns) {
5901
+ _this.updateColumnsWidth(column.columns);
5902
+ }
5903
+ else if (column.field) {
5904
+ var currentColumn = _this.grid.getColumnByField(column.field);
5905
+ column.width = currentColumn.width;
5906
+ }
5907
+ });
5908
+ };
5911
5909
  /**
5912
5910
  * Gets the content div of the TreeGrid.
5913
5911
  *
@@ -5960,7 +5958,8 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
5960
5958
  * @isGenericType true
5961
5959
  */
5962
5960
  TreeGrid.prototype.getCurrentViewRecords = function () {
5963
- return this.grid.currentViewData;
5961
+ var isSummaryRow = 'isSummaryRow';
5962
+ return this.grid.currentViewData.filter(function (e) { return isNullOrUndefined(e["" + isSummaryRow]); });
5964
5963
  };
5965
5964
  /**
5966
5965
  * Gets the added, edited,and deleted data before bulk save to the DataSource in batch mode.
@@ -6193,28 +6192,70 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
6193
6192
  */
6194
6193
  TreeGrid.prototype.expandRow = function (row, record, key, level) {
6195
6194
  var _this = this;
6195
+ var parentRec = this.parentData;
6196
+ if (!this.enableVirtualization) {
6197
+ parentRec = this.flatData.filter(function (e) {
6198
+ return e.hasChildRecords;
6199
+ });
6200
+ }
6196
6201
  record = this.getCollapseExpandRecords(row, record);
6197
6202
  if (!isNullOrUndefined(row) && row.cells[0].classList.contains('e-lastrowcell')) {
6198
6203
  this.lastRowBorder(row, false);
6199
6204
  }
6200
- var args = { data: record, row: row, cancel: false };
6201
- this.trigger(expanding, args, function (expandingArgs) {
6202
- if (!expandingArgs.cancel) {
6203
- _this.expandCollapse('expand', row, record);
6204
- if (expandingArgs.expandAll) {
6205
- _this.expandCollapseAllChildren(record, 'expand', key, level);
6206
- }
6207
- var children = 'Children';
6208
- if (!(isRemoteData(_this) && !isOffline(_this)) && (!isCountRequired(_this) || !isNullOrUndefined(record["" + children]))) {
6209
- var collapseArgs = { data: record, row: row };
6210
- _this.setHeightForFrozenContent();
6211
- if (!isNullOrUndefined(_this.expandStateMapping)) {
6212
- _this.updateExpandStateMapping(collapseArgs.data, true);
6205
+ if (this.isExpandAll && !isRemoteData(this)) {
6206
+ var args = { data: parentRec, row: row, cancel: false };
6207
+ var pagerValuePresent = false;
6208
+ if (this.grid.pagerModule && !isNullOrUndefined(this.grid.pagerModule.pagerObj.pagerdropdownModule)) {
6209
+ pagerValuePresent = this.grid.pagerModule.pagerObj.pagerdropdownModule['dropDownListObject'].value ? true : false;
6210
+ }
6211
+ if (!this.isExpandingEventTriggered) {
6212
+ this.trigger(expanding, args, function (expandingArgs) {
6213
+ _this.expandAllPrevent = expandingArgs.cancel;
6214
+ if (!expandingArgs.cancel) {
6215
+ if (expandingArgs.expandAll) {
6216
+ _this.expandCollapseAllChildren(record, 'expand', key, level);
6217
+ }
6218
+ _this.expandRows(row, record, parentRec, key, level);
6219
+ }
6220
+ });
6221
+ }
6222
+ else if ((!this.allowPaging || (pagerValuePresent && this.grid.pagerModule.pagerObj.pagerdropdownModule['dropDownListObject'].value === 'All')) &&
6223
+ !this.expandAllPrevent && this.isExpandingEventTriggered) {
6224
+ this.expandRows(row, record, parentRec, key, level);
6225
+ }
6226
+ this.isExpandingEventTriggered = true;
6227
+ }
6228
+ else if (!this.isExpandAll || (this.isExpandAll && isRemoteData(this))) {
6229
+ var args = { data: record, row: row, cancel: false };
6230
+ this.trigger(expanding, args, function (expandingArgs) {
6231
+ if (!expandingArgs.cancel) {
6232
+ if (expandingArgs.expandAll) {
6233
+ _this.expandCollapseAllChildren(record, 'expand', key, level);
6213
6234
  }
6214
- _this.trigger(expanded, collapseArgs);
6235
+ _this.expandRows(row, record, parentRec, key, level);
6215
6236
  }
6237
+ });
6238
+ }
6239
+ };
6240
+ // Internal method to handle the rows expand
6241
+ TreeGrid.prototype.expandRows = function (row, record, parentRec, key, level) {
6242
+ this.expandCollapse('expand', row, record);
6243
+ var children = 'Children';
6244
+ if (!(isRemoteData(this) && !isOffline(this)) && (!isCountRequired(this) || !isNullOrUndefined(record["" + children]))) {
6245
+ var expandArgs = { data: record, row: row };
6246
+ this.setHeightForFrozenContent();
6247
+ if (!isNullOrUndefined(this.expandStateMapping)) {
6248
+ this.updateExpandStateMapping(expandArgs.data, true);
6216
6249
  }
6217
- });
6250
+ if (this.isExpandAll && !this.isExpandedEventTriggered) {
6251
+ this.isExpandedEventTriggered = true;
6252
+ expandArgs = { data: parentRec, row: row };
6253
+ this.trigger(expanded, expandArgs);
6254
+ }
6255
+ else if (!this.isExpandAll) {
6256
+ this.trigger(expanded, expandArgs);
6257
+ }
6258
+ }
6218
6259
  };
6219
6260
  TreeGrid.prototype.expandCollapseAllChildren = function (record, action, key, level) {
6220
6261
  if ((!isNullOrUndefined(key) && record[this.getPrimaryKeyFieldNames()[0]] !== key) ||
@@ -6272,31 +6313,65 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
6272
6313
  */
6273
6314
  TreeGrid.prototype.collapseRow = function (row, record, key) {
6274
6315
  var _this = this;
6316
+ var parentRec = this.parentData;
6317
+ if (!this.enableVirtualization) {
6318
+ parentRec = this.flatData.filter(function (e) {
6319
+ return e.hasChildRecords;
6320
+ });
6321
+ }
6275
6322
  record = this.getCollapseExpandRecords(row, record);
6276
- var args = { data: record, row: row, cancel: false };
6277
- this.trigger(collapsing, args, function (collapsingArgs) {
6278
- if (!collapsingArgs.cancel) {
6279
- if (collapsingArgs.collapseAll) {
6280
- _this.expandCollapseAllChildren(record, 'collapse', key);
6281
- }
6282
- _this.expandCollapse('collapse', row, record);
6283
- var collapseArgs = { data: record, row: row };
6284
- if (!isRemoteData(_this)) {
6285
- _this.setHeightForFrozenContent();
6286
- if (!isNullOrUndefined(_this.expandStateMapping)) {
6287
- _this.updateExpandStateMapping(collapseArgs.data, false);
6288
- }
6289
- _this.trigger(collapsed, collapseArgs);
6290
- if (_this.enableInfiniteScrolling) {
6291
- var scrollHeight = _this.grid.getContent().firstElementChild.scrollHeight;
6292
- var scrollTop = _this.grid.getContent().firstElementChild.scrollTop;
6293
- if ((scrollHeight - scrollTop) < _this.grid.getRowHeight() + +_this.height) {
6294
- _this.grid.getContent().firstElementChild.scrollBy(0, _this.grid.getRowHeight());
6323
+ if (this.isCollapseAll && !isRemoteData(this)) {
6324
+ var args = { data: parentRec, row: row, cancel: false };
6325
+ if (!this.isCollapsingEventTriggered) {
6326
+ this.trigger(collapsing, args, function (collapsingArgs) {
6327
+ _this.collapseAllPrevent = collapsingArgs.cancel;
6328
+ if (!collapsingArgs.cancel) {
6329
+ if (collapsingArgs.collapseAll) {
6330
+ _this.expandCollapseAllChildren(record, 'collapse', key);
6295
6331
  }
6332
+ _this.collapseRows(row, record, parentRec, key);
6296
6333
  }
6334
+ });
6335
+ }
6336
+ else if (!this.allowPaging && !this.collapseAllPrevent && this.isCollapsingEventTriggered) {
6337
+ this.collapseRows(row, record, parentRec, key);
6338
+ }
6339
+ this.isCollapsingEventTriggered = true;
6340
+ }
6341
+ else if (!this.isCollapseAll || (this.isCollapseAll && isRemoteData(this))) {
6342
+ var args = { data: record, row: row, cancel: false };
6343
+ this.trigger(collapsing, args, function (collapsingArgs) {
6344
+ if (!collapsingArgs.cancel) {
6345
+ _this.collapseRows(row, record, parentRec, key);
6297
6346
  }
6347
+ });
6348
+ }
6349
+ };
6350
+ // Internal method for handling the rows collapse
6351
+ TreeGrid.prototype.collapseRows = function (row, record, parentRec, key) {
6352
+ this.expandCollapse('collapse', row, record);
6353
+ var collapseArgs = { data: record, row: row };
6354
+ if (!isRemoteData(this)) {
6355
+ this.setHeightForFrozenContent();
6356
+ if (!isNullOrUndefined(this.expandStateMapping)) {
6357
+ this.updateExpandStateMapping(collapseArgs.data, false);
6298
6358
  }
6299
- });
6359
+ if (this.isCollapseAll && !this.isCollapsedEventTriggered) {
6360
+ this.isCollapsedEventTriggered = true;
6361
+ collapseArgs = { data: parentRec, row: row };
6362
+ this.trigger(collapsed, collapseArgs);
6363
+ }
6364
+ else if (!this.isCollapseAll) {
6365
+ this.trigger(collapsed, collapseArgs);
6366
+ }
6367
+ if (this.enableInfiniteScrolling) {
6368
+ var scrollHeight = this.grid.getContent().firstElementChild.scrollHeight;
6369
+ var scrollTop = this.grid.getContent().firstElementChild.scrollTop;
6370
+ if ((scrollHeight - scrollTop) < this.grid.getRowHeight() + +this.height) {
6371
+ this.grid.getContent().firstElementChild.scrollBy(0, this.grid.getRowHeight());
6372
+ }
6373
+ }
6374
+ }
6300
6375
  };
6301
6376
  TreeGrid.prototype.updateExpandStateMapping = function (record, state) {
6302
6377
  var totalRecords = record;
@@ -6459,6 +6534,8 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
6459
6534
  * @returns {void}
6460
6535
  */
6461
6536
  TreeGrid.prototype.expandAll = function () {
6537
+ this.isExpandedEventTriggered = false;
6538
+ this.isExpandingEventTriggered = false;
6462
6539
  this.expandCollapseAll('expand');
6463
6540
  };
6464
6541
  /**
@@ -6467,6 +6544,8 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
6467
6544
  * @returns {void}
6468
6545
  */
6469
6546
  TreeGrid.prototype.collapseAll = function () {
6547
+ this.isCollapsedEventTriggered = false;
6548
+ this.isCollapsingEventTriggered = false;
6470
6549
  this.expandCollapseAll('collapse');
6471
6550
  };
6472
6551
  TreeGrid.prototype.expandCollapseAll = function (action) {
@@ -6524,7 +6603,7 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
6524
6603
  TreeGrid.prototype.expandCollapse = function (action, row, record, isChild) {
6525
6604
  var _this = this;
6526
6605
  var expandingArgs = { row: row, data: record, childData: [], requestType: action };
6527
- var childRecords = this.getCurrentViewRecords().filter(function (e) {
6606
+ var childRecords = this.grid.currentViewData.filter(function (e) {
6528
6607
  return e.parentUniqueID === record.uniqueID;
6529
6608
  });
6530
6609
  var targetEle;
@@ -6538,7 +6617,7 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
6538
6617
  }
6539
6618
  var rowIndex;
6540
6619
  if (isNullOrUndefined(row)) {
6541
- rowIndex = this.getCurrentViewRecords().indexOf(record);
6620
+ rowIndex = this.grid.currentViewData.indexOf(record);
6542
6621
  row = gridRows[parseInt(rowIndex.toString(), 10)];
6543
6622
  }
6544
6623
  else {
@@ -6766,7 +6845,7 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
6766
6845
  };
6767
6846
  TreeGrid.prototype.localExpand = function (action, row, record) {
6768
6847
  var rows;
6769
- var childRecords = this.getCurrentViewRecords().filter(function (e) {
6848
+ var childRecords = this.grid.currentViewData.filter(function (e) {
6770
6849
  return e.parentUniqueID === record.uniqueID;
6771
6850
  });
6772
6851
  if (this.isPixelHeight() && row.cells[0].classList.contains('e-lastrowcell')) {
@@ -6805,7 +6884,7 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
6805
6884
  });
6806
6885
  }
6807
6886
  var gridRowsObject = this.grid.getRowsObject();
6808
- var currentViewData = this.getCurrentViewRecords();
6887
+ var currentViewData = this.grid.currentViewData;
6809
6888
  var currentRecord = currentViewData.filter(function (e) {
6810
6889
  return e.uniqueID === record.uniqueID;
6811
6890
  });
@@ -12857,8 +12936,16 @@ var VirtualTreeContentRenderer = /** @__PURE__ @class */ (function (_super) {
12857
12936
  this.startIndex = 0;
12858
12937
  this.endIndex = this.parent.pageSettings.pageSize - 1;
12859
12938
  }
12860
- args.startIndex = this.startIndex;
12861
- args.endIndex = this.endIndex;
12939
+ if ((this.endIndex - this.startIndex !== this.parent.pageSettings.pageSize) &&
12940
+ (this.totalRecords > this.parent.pageSettings.pageSize) &&
12941
+ (this.endIndex === this.totalRecords)) {
12942
+ args.startIndex = this.endIndex - this.parent.pageSettings.pageSize;
12943
+ args.endIndex = this.endIndex;
12944
+ }
12945
+ else {
12946
+ args.startIndex = this.startIndex;
12947
+ args.endIndex = this.endIndex;
12948
+ }
12862
12949
  };
12863
12950
  VirtualTreeContentRenderer.prototype.eventListener = function (action) {
12864
12951
  var _this = this;
@@ -13173,6 +13260,7 @@ var VirtualTreeContentRenderer = /** @__PURE__ @class */ (function (_super) {
13173
13260
  this.translateY = scrollArgs.offset.top - rowHeight * 2;
13174
13261
  }
13175
13262
  else {
13263
+ scrollArgs.offset.top = content$$1.scrollTop;
13176
13264
  this.translateY = scrollArgs.offset.top;
13177
13265
  }
13178
13266
  }
@@ -13193,7 +13281,7 @@ var VirtualTreeContentRenderer = /** @__PURE__ @class */ (function (_super) {
13193
13281
  lastIndex = nextSetResIndex +
13194
13282
  (this.totalRecords - nextSetResIndex);
13195
13283
  }
13196
- this.startIndex = !isLastBlock ? lastIndex - this.parent.pageSettings.pageSize : nextSetResIndex;
13284
+ this.startIndex = !isLastBlock || isNullOrUndefined(this['' + selectedRowIndex]) ? lastIndex - this.parent.pageSettings.pageSize : nextSetResIndex;
13197
13285
  this.endIndex = lastIndex;
13198
13286
  if ((nextSetResIndex + this.parent.pageSettings.pageSize) > this.totalRecords && (this.endIndex - this.startIndex) <
13199
13287
  (this.parent.pageSettings.pageSize / 2) && (this.endIndex - nextSetResIndex) < (this.parent.pageSettings.pageSize / 2)) {
@@ -13860,10 +13948,6 @@ var Freeze$1 = /** @__PURE__ @class */ (function () {
13860
13948
  getValue('addRenderer', renderer)
13861
13949
  .apply(renderer, [RenderType.Content, new VirtualTreeFreezeRenderer(getValue('grid', this.parent), getValue('serviceLocator', this.parent.grid))]);
13862
13950
  }
13863
- else {
13864
- getValue('addRenderer', renderer)
13865
- .apply(renderer, [RenderType.Content, new FreezeContentRender(getValue('grid', this.parent), getValue('serviceLocator', this.parent.grid))]);
13866
- }
13867
13951
  }
13868
13952
  if (this.parent.getFrozenLeftColumnsCount() || this.parent.getFrozenRightColumnsCount()) {
13869
13953
  getValue('addRenderer', renderer)