@syncfusion/ej2-treegrid 20.2.43 → 20.2.46

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.
@@ -799,7 +799,7 @@ function findChildrenRecords(records) {
799
799
  return [];
800
800
  }
801
801
  if (!isNullOrUndefined(records.childRecords)) {
802
- var childRecords = records.childRecords.filter(function (items) { return !items.isSummaryRow; });
802
+ var childRecords = records.childRecords.filter(function (item) { return !item.isSummaryRow; });
803
803
  var keys = Object.keys(childRecords);
804
804
  for (var i = 0, len = keys.length; i < len; i++) {
805
805
  datas.push(childRecords[i]);
@@ -2202,7 +2202,7 @@ var DataManipulation = /** @__PURE__ @class */ (function () {
2202
2202
  currentData.index = this.storedIndex;
2203
2203
  }
2204
2204
  if ((!isNullOrUndefined(currentData[this.parent.childMapping]) && !isCountRequired(this.parent)) ||
2205
- ((currentData[this.parent.hasChildMapping]) && isCountRequired(this.parent) && this.parent.initialRender)) {
2205
+ ((currentData[this.parent.hasChildMapping]) && isCountRequired(this.parent) && (this.parent.initialRender || isNullOrUndefined(this.parent['dataResults'].result)))) {
2206
2206
  currentData.hasChildRecords = true;
2207
2207
  if (this.parent.enableCollapseAll || !isNullOrUndefined(this.parent.dataStateChange)
2208
2208
  && isNullOrUndefined(currentData[this.parent.childMapping])) {
@@ -2842,7 +2842,7 @@ function editAction(details, control, isSelfReference, addRowIndex, selectedInde
2842
2842
  var childRecords = parentData ? parentData[control.childMapping] : [];
2843
2843
  for (var p = childRecords.length - 1; p >= 0; p--) {
2844
2844
  if (childRecords[p][control.idMapping] === currentData_1[control.idMapping]) {
2845
- if (!control.enableImmutableMode) {
2845
+ if (!control.enableImmutableMode && parentData.childRecords.length === parentData['Children'].length) {
2846
2846
  parentData['childRecords'].splice(p, 1);
2847
2847
  }
2848
2848
  childRecords.splice(p, 1);
@@ -4593,7 +4593,7 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
4593
4593
  treeGridColumn[prop] = column[i][prop];
4594
4594
  }
4595
4595
  else if (prop === 'columns' && !isNullOrUndefined(column[i][prop])) {
4596
- gridColumn[prop] = this.getGridColumns(column[i][prop], false, index);
4596
+ gridColumn[prop] = this.getGridColumns(column[i][prop], false, this.columnModel.length - 1);
4597
4597
  treeGridColumn[prop] = column[i][prop];
4598
4598
  }
4599
4599
  else if (this.initialRender && !isNullOrUndefined(treeColumn) && this.enablePersistence && prop === 'edit') {
@@ -5385,15 +5385,15 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
5385
5385
  }
5386
5386
  }
5387
5387
  }
5388
- var merge$$1 = 'deepMerge';
5389
- this[merge$$1] = ['columns']; // Workaround for blazor updateModel
5388
+ var deepMerge = 'deepMerge';
5389
+ this[deepMerge] = ['columns']; // Workaround for blazor updateModel
5390
5390
  if (this.grid.columns.length !== this.columnModel.length) {
5391
5391
  this.stackedHeader = true;
5392
5392
  }
5393
5393
  if (!this.stackedHeader) {
5394
- this.setProperties({ columns: this.columnModel }, true);
5394
+ merge(this.columns, this.columnModel);
5395
5395
  }
5396
- this[merge$$1] = undefined; // Workaround for blazor updateModel
5396
+ this[deepMerge] = undefined; // Workaround for blazor updateModel
5397
5397
  return this.columnModel;
5398
5398
  };
5399
5399
  /**
@@ -8885,7 +8885,8 @@ var Filter$1 = /** @__PURE__ @class */ (function () {
8885
8885
  }
8886
8886
  }
8887
8887
  else {
8888
- if (parent['expanded'] === false && this.parent.getVisibleRecords().indexOf(record) === -1 && isNullOrUndefined(this.parent['dataResults']['action'])) {
8888
+ if ((!this.parent.enableCollapseAll || !this.parent.initialRender && isNullOrUndefined(this.parent['dataResults']['result']))
8889
+ && parent['expanded'] === false && this.parent.getVisibleRecords().indexOf(record) === -1) {
8889
8890
  this.parent.expandRow(this.parent.getRows()[parent['index']], parent);
8890
8891
  }
8891
8892
  this.addParentRecord(parent);
@@ -10124,9 +10125,9 @@ var ContextMenu$1 = /** @__PURE__ @class */ (function () {
10124
10125
  && !(isNullOrUndefined(editRecord)) && !(editRecord.classList.contains('e-menu-hide'))) {
10125
10126
  editRecord.style.display = 'none';
10126
10127
  }
10127
- if (indent || outdent) {
10128
- var tObj = this.parent;
10129
- var selectedrow = tObj.getSelectedRows()[0];
10128
+ var tObj = this.parent;
10129
+ var selectedrow = tObj.getSelectedRows()[0];
10130
+ if ((indent || outdent) && !isNullOrUndefined(selectedrow)) {
10130
10131
  var targetElement = args.event.target.closest('td');
10131
10132
  if (isNullOrUndefined(targetElement) || (!isNullOrUndefined(targetElement) && !targetElement.classList.contains('e-rowcell'))) {
10132
10133
  indent.style.display = outdent.style.display = 'none';
@@ -10138,31 +10139,32 @@ var ContextMenu$1 = /** @__PURE__ @class */ (function () {
10138
10139
  else if (args['name'] !== 'rowDeselected' || (!isNullOrUndefined(selectedrow) && tObj.grid.isCheckBoxSelection)) {
10139
10140
  var selectedItem = tObj.getCurrentViewRecords()[selectedrow.rowIndex];
10140
10141
  if (!isNullOrUndefined(selectedItem)) {
10141
- if ((selectedItem.level > tObj.getCurrentViewRecords()[selectedrow.rowIndex - 1].level)) {
10142
+ if ((selectedItem.level > tObj.getCurrentViewRecords()[selectedrow.rowIndex - 1].level) || this.parent.editSettings.mode === 'Batch'
10143
+ || this.parent.editSettings.mode === 'Cell') {
10142
10144
  indent.style.display = 'none';
10143
10145
  }
10144
10146
  else {
10145
10147
  indent.style.display = 'block';
10146
10148
  }
10147
- if (selectedItem.level === tObj.getCurrentViewRecords()[selectedrow.rowIndex - 1].level) {
10149
+ if ((selectedItem.level === tObj.getCurrentViewRecords()[selectedrow.rowIndex - 1].level) && this.parent.editSettings.mode !== 'Batch'
10150
+ && this.parent.editSettings.mode !== 'Cell') {
10148
10151
  indent.style.display = 'block';
10149
10152
  }
10150
- if (selectedItem.level === 0) {
10153
+ if ((selectedItem.level === 0) || this.parent.editSettings.mode === 'Batch'
10154
+ || this.parent.editSettings.mode === 'Cell') {
10151
10155
  outdent.style.display = 'none';
10152
10156
  }
10153
- if (selectedItem.level !== 0) {
10157
+ else {
10154
10158
  outdent.style.display = 'block';
10155
10159
  }
10156
10160
  }
10157
10161
  }
10158
- if (args['name'] === 'rowDeselected' && isNullOrUndefined(selectedrow) && !tObj.grid.isCheckBoxSelection) {
10159
- if (this.parent.toolbar['includes']('Indent')) {
10160
- indent.style.display = 'none';
10161
- }
10162
- if (this.parent.toolbar['includes']('Outdent')) {
10163
- outdent.style.display = 'none';
10164
- }
10165
- }
10162
+ }
10163
+ }
10164
+ else {
10165
+ if (tObj.grid.isEdit && isNullOrUndefined(selectedrow)) {
10166
+ indent.style.display = 'none';
10167
+ outdent.style.display = 'none';
10166
10168
  }
10167
10169
  }
10168
10170
  };
@@ -10446,7 +10448,8 @@ var BatchEdit = /** @__PURE__ @class */ (function () {
10446
10448
  !this.parent.editModule['isAddedRowByContextMenu'] && (this.parent.grid.selectedRowIndex === -1 || this.parent.editModule['batchEditModule'].isAdd)) {
10447
10449
  this.selectedIndex = this.parent.editModule['selectedIndex'];
10448
10450
  this.addRowIndex = this.parent.editModule['addRowIndex'];
10449
- this.addRowRecord = this.batchRecords.length ? this.batchRecords[this.selectedIndex] : this.parent.getCurrentViewRecords()[this.selectedIndex];
10451
+ this.addRowRecord = this.batchRecords.length ? this.batchRecords[this.selectedIndex]
10452
+ : this.parent.getCurrentViewRecords()[this.selectedIndex];
10450
10453
  }
10451
10454
  else {
10452
10455
  this.selectedIndex = this.parent.grid.selectedRowIndex;
@@ -12355,6 +12358,8 @@ var VirtualTreeContentRenderer = /** @__PURE__ @class */ (function (_super) {
12355
12358
  var upScroll = (scrollArgs.offset.top - this.translateY) < 0;
12356
12359
  var downScroll = Math.ceil(scrollArgs.offset.top - this.translateY) >= scrollHeight;
12357
12360
  var selectedRowIndex = 'selectedRowIndex';
12361
+ var currentViewData = this.parent.currentViewData;
12362
+ var indexValue = 'index';
12358
12363
  if (upScroll && (scrollArgs.direction !== 'right' && scrollArgs.direction !== 'left')) {
12359
12364
  var vHeight = +(this.parent.height.toString().indexOf('%') < 0 ? this.parent.height :
12360
12365
  this.parent.element.getBoundingClientRect().height);
@@ -12373,6 +12378,10 @@ var VirtualTreeContentRenderer = /** @__PURE__ @class */ (function (_super) {
12373
12378
  this.endIndex = lastInx;
12374
12379
  this.startIndex = (this.startIndex - remains) < 0 ? 0 : (this.startIndex - remains);
12375
12380
  }
12381
+ if (currentViewData.length && ((currentViewData[0][indexValue] - this.startIndex) < (this.parent.pageSettings.pageSize / 2))) {
12382
+ this.startIndex = currentViewData[0][indexValue] - (this.parent.pageSettings.pageSize / 2);
12383
+ this.endIndex = this.startIndex + this.parent.pageSettings.pageSize;
12384
+ }
12376
12385
  //var firsttdinx = parseInt(this.parent.getContent().querySelector('.e-content td').getAttribute('index'), 0);
12377
12386
  var rowPt = Math.ceil(scrollArgs.offset.top / this.parent.getRowHeight());
12378
12387
  rowPt = rowPt % this.parent.pageSettings.pageSize;
@@ -12411,6 +12420,10 @@ var VirtualTreeContentRenderer = /** @__PURE__ @class */ (function (_super) {
12411
12420
  }
12412
12421
  this.startIndex = !isLastBlock ? lastIndex - this.parent.pageSettings.pageSize : nextSetResIndex;
12413
12422
  this.endIndex = lastIndex;
12423
+ if (currentViewData.length && this.startIndex > currentViewData[0][indexValue] &&
12424
+ ((this.startIndex - currentViewData[0][indexValue]) < (this.parent.pageSettings.pageSize / 2))) {
12425
+ this.startIndex = currentViewData[0][indexValue] + (this.parent.pageSettings.pageSize / 2);
12426
+ }
12414
12427
  if (scrollArgs.offset.top > (this.parent.getRowHeight() * this.totalRecords)) {
12415
12428
  this.translateY = this.getTranslateY(scrollArgs.offset.top, content.getBoundingClientRect().height);
12416
12429
  }