@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.
@@ -6192,28 +6192,70 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
6192
6192
  */
6193
6193
  TreeGrid.prototype.expandRow = function (row, record, key, level) {
6194
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
+ }
6195
6201
  record = this.getCollapseExpandRecords(row, record);
6196
6202
  if (!isNullOrUndefined(row) && row.cells[0].classList.contains('e-lastrowcell')) {
6197
6203
  this.lastRowBorder(row, false);
6198
6204
  }
6199
- var args = { data: record, row: row, cancel: false };
6200
- this.trigger(expanding, args, function (expandingArgs) {
6201
- if (!expandingArgs.cancel) {
6202
- _this.expandCollapse('expand', row, record);
6203
- if (expandingArgs.expandAll) {
6204
- _this.expandCollapseAllChildren(record, 'expand', key, level);
6205
- }
6206
- var children = 'Children';
6207
- if (!(isRemoteData(_this) && !isOffline(_this)) && (!isCountRequired(_this) || !isNullOrUndefined(record["" + children]))) {
6208
- var collapseArgs = { data: record, row: row };
6209
- _this.setHeightForFrozenContent();
6210
- if (!isNullOrUndefined(_this.expandStateMapping)) {
6211
- _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);
6212
6234
  }
6213
- _this.trigger(expanded, collapseArgs);
6235
+ _this.expandRows(row, record, parentRec, key, level);
6214
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);
6215
6249
  }
6216
- });
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
+ }
6217
6259
  };
6218
6260
  TreeGrid.prototype.expandCollapseAllChildren = function (record, action, key, level) {
6219
6261
  if ((!isNullOrUndefined(key) && record[this.getPrimaryKeyFieldNames()[0]] !== key) ||
@@ -6271,31 +6313,65 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
6271
6313
  */
6272
6314
  TreeGrid.prototype.collapseRow = function (row, record, key) {
6273
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
+ }
6274
6322
  record = this.getCollapseExpandRecords(row, record);
6275
- var args = { data: record, row: row, cancel: false };
6276
- this.trigger(collapsing, args, function (collapsingArgs) {
6277
- if (!collapsingArgs.cancel) {
6278
- if (collapsingArgs.collapseAll) {
6279
- _this.expandCollapseAllChildren(record, 'collapse', key);
6280
- }
6281
- _this.expandCollapse('collapse', row, record);
6282
- var collapseArgs = { data: record, row: row };
6283
- if (!isRemoteData(_this)) {
6284
- _this.setHeightForFrozenContent();
6285
- if (!isNullOrUndefined(_this.expandStateMapping)) {
6286
- _this.updateExpandStateMapping(collapseArgs.data, false);
6287
- }
6288
- _this.trigger(collapsed, collapseArgs);
6289
- if (_this.enableInfiniteScrolling) {
6290
- var scrollHeight = _this.grid.getContent().firstElementChild.scrollHeight;
6291
- var scrollTop = _this.grid.getContent().firstElementChild.scrollTop;
6292
- if ((scrollHeight - scrollTop) < _this.grid.getRowHeight() + +_this.height) {
6293
- _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);
6294
6331
  }
6332
+ _this.collapseRows(row, record, parentRec, key);
6295
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);
6296
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);
6297
6358
  }
6298
- });
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
+ }
6299
6375
  };
6300
6376
  TreeGrid.prototype.updateExpandStateMapping = function (record, state) {
6301
6377
  var totalRecords = record;
@@ -6458,6 +6534,8 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
6458
6534
  * @returns {void}
6459
6535
  */
6460
6536
  TreeGrid.prototype.expandAll = function () {
6537
+ this.isExpandedEventTriggered = false;
6538
+ this.isExpandingEventTriggered = false;
6461
6539
  this.expandCollapseAll('expand');
6462
6540
  };
6463
6541
  /**
@@ -6466,6 +6544,8 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
6466
6544
  * @returns {void}
6467
6545
  */
6468
6546
  TreeGrid.prototype.collapseAll = function () {
6547
+ this.isCollapsedEventTriggered = false;
6548
+ this.isCollapsingEventTriggered = false;
6469
6549
  this.expandCollapseAll('collapse');
6470
6550
  };
6471
6551
  TreeGrid.prototype.expandCollapseAll = function (action) {
@@ -12856,7 +12936,8 @@ var VirtualTreeContentRenderer = /** @__PURE__ @class */ (function (_super) {
12856
12936
  this.startIndex = 0;
12857
12937
  this.endIndex = this.parent.pageSettings.pageSize - 1;
12858
12938
  }
12859
- if ((this.endIndex - this.startIndex !== this.parent.pageSettings.pageSize) && (this.totalRecords > this.parent.pageSettings.pageSize) &&
12939
+ if ((this.endIndex - this.startIndex !== this.parent.pageSettings.pageSize) &&
12940
+ (this.totalRecords > this.parent.pageSettings.pageSize) &&
12860
12941
  (this.endIndex === this.totalRecords)) {
12861
12942
  args.startIndex = this.endIndex - this.parent.pageSettings.pageSize;
12862
12943
  args.endIndex = this.endIndex;
@@ -13179,6 +13260,7 @@ var VirtualTreeContentRenderer = /** @__PURE__ @class */ (function (_super) {
13179
13260
  this.translateY = scrollArgs.offset.top - rowHeight * 2;
13180
13261
  }
13181
13262
  else {
13263
+ scrollArgs.offset.top = content$$1.scrollTop;
13182
13264
  this.translateY = scrollArgs.offset.top;
13183
13265
  }
13184
13266
  }
@@ -13199,7 +13281,7 @@ var VirtualTreeContentRenderer = /** @__PURE__ @class */ (function (_super) {
13199
13281
  lastIndex = nextSetResIndex +
13200
13282
  (this.totalRecords - nextSetResIndex);
13201
13283
  }
13202
- this.startIndex = !isLastBlock || isNullOrUndefined(this["" + selectedRowIndex]) ? lastIndex - this.parent.pageSettings.pageSize : nextSetResIndex;
13284
+ this.startIndex = !isLastBlock || isNullOrUndefined(this['' + selectedRowIndex]) ? lastIndex - this.parent.pageSettings.pageSize : nextSetResIndex;
13203
13285
  this.endIndex = lastIndex;
13204
13286
  if ((nextSetResIndex + this.parent.pageSettings.pageSize) > this.totalRecords && (this.endIndex - this.startIndex) <
13205
13287
  (this.parent.pageSettings.pageSize / 2) && (this.endIndex - nextSetResIndex) < (this.parent.pageSettings.pageSize / 2)) {