@syncfusion/ej2-treegrid 20.2.40 → 20.2.45

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.
@@ -724,7 +724,7 @@ function findChildrenRecords(records) {
724
724
  return [];
725
725
  }
726
726
  if (!isNullOrUndefined(records.childRecords)) {
727
- const childRecords = records.childRecords.filter(items => !items.isSummaryRow);
727
+ const childRecords = records.childRecords.filter((item) => !item.isSummaryRow);
728
728
  const keys = Object.keys(childRecords);
729
729
  for (let i = 0, len = keys.length; i < len; i++) {
730
730
  datas.push(childRecords[i]);
@@ -2080,7 +2080,7 @@ class DataManipulation {
2080
2080
  currentData.index = this.storedIndex;
2081
2081
  }
2082
2082
  if ((!isNullOrUndefined(currentData[this.parent.childMapping]) && !isCountRequired(this.parent)) ||
2083
- ((currentData[this.parent.hasChildMapping]) && isCountRequired(this.parent) && this.parent.initialRender)) {
2083
+ ((currentData[this.parent.hasChildMapping]) && isCountRequired(this.parent) && (this.parent.initialRender || isNullOrUndefined(this.parent['dataResults'].result)))) {
2084
2084
  currentData.hasChildRecords = true;
2085
2085
  if (this.parent.enableCollapseAll || !isNullOrUndefined(this.parent.dataStateChange)
2086
2086
  && isNullOrUndefined(currentData[this.parent.childMapping])) {
@@ -2636,7 +2636,7 @@ function editAction(details, control, isSelfReference, addRowIndex, selectedInde
2636
2636
  const childRecords = parentData ? parentData[control.childMapping] : [];
2637
2637
  for (let p = childRecords.length - 1; p >= 0; p--) {
2638
2638
  if (childRecords[p][control.idMapping] === currentData[control.idMapping]) {
2639
- if (!control.enableImmutableMode) {
2639
+ if (!control.enableImmutableMode && parentData.childRecords.length === parentData['Children'].length) {
2640
2640
  parentData['childRecords'].splice(p, 1);
2641
2641
  }
2642
2642
  childRecords.splice(p, 1);
@@ -4336,7 +4336,7 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
4336
4336
  treeGridColumn[prop] = column[i][prop];
4337
4337
  }
4338
4338
  else if (prop === 'columns' && !isNullOrUndefined(column[i][prop])) {
4339
- gridColumn[prop] = this.getGridColumns(column[i][prop], false, index);
4339
+ gridColumn[prop] = this.getGridColumns(column[i][prop], false, this.columnModel.length - 1);
4340
4340
  treeGridColumn[prop] = column[i][prop];
4341
4341
  }
4342
4342
  else if (this.initialRender && !isNullOrUndefined(treeColumn) && this.enablePersistence && prop === 'edit') {
@@ -5126,15 +5126,15 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
5126
5126
  }
5127
5127
  }
5128
5128
  }
5129
- const merge$$1 = 'deepMerge';
5130
- this[merge$$1] = ['columns']; // Workaround for blazor updateModel
5129
+ const deepMerge = 'deepMerge';
5130
+ this[deepMerge] = ['columns']; // Workaround for blazor updateModel
5131
5131
  if (this.grid.columns.length !== this.columnModel.length) {
5132
5132
  this.stackedHeader = true;
5133
5133
  }
5134
5134
  if (!this.stackedHeader) {
5135
- this.setProperties({ columns: this.columnModel }, true);
5135
+ merge(this.columns, this.columnModel);
5136
5136
  }
5137
- this[merge$$1] = undefined; // Workaround for blazor updateModel
5137
+ this[deepMerge] = undefined; // Workaround for blazor updateModel
5138
5138
  return this.columnModel;
5139
5139
  }
5140
5140
  /**
@@ -8557,7 +8557,8 @@ class Filter$1 {
8557
8557
  }
8558
8558
  }
8559
8559
  else {
8560
- if (parent['expanded'] === false && this.parent.getVisibleRecords().indexOf(record) === -1 && isNullOrUndefined(this.parent['dataResults']['action'])) {
8560
+ if ((!this.parent.enableCollapseAll || !this.parent.initialRender && isNullOrUndefined(this.parent['dataResults']['result']))
8561
+ && parent['expanded'] === false && this.parent.getVisibleRecords().indexOf(record) === -1) {
8561
8562
  this.parent.expandRow(this.parent.getRows()[parent['index']], parent);
8562
8563
  }
8563
8564
  this.addParentRecord(parent);
@@ -9776,9 +9777,9 @@ class ContextMenu$1 {
9776
9777
  && !(isNullOrUndefined(editRecord)) && !(editRecord.classList.contains('e-menu-hide'))) {
9777
9778
  editRecord.style.display = 'none';
9778
9779
  }
9779
- if (indent || outdent) {
9780
- const tObj = this.parent;
9781
- const selectedrow = tObj.getSelectedRows()[0];
9780
+ const tObj = this.parent;
9781
+ const selectedrow = tObj.getSelectedRows()[0];
9782
+ if ((indent || outdent) && !isNullOrUndefined(selectedrow)) {
9782
9783
  const targetElement = args.event.target.closest('td');
9783
9784
  if (isNullOrUndefined(targetElement) || (!isNullOrUndefined(targetElement) && !targetElement.classList.contains('e-rowcell'))) {
9784
9785
  indent.style.display = outdent.style.display = 'none';
@@ -9790,31 +9791,32 @@ class ContextMenu$1 {
9790
9791
  else if (args['name'] !== 'rowDeselected' || (!isNullOrUndefined(selectedrow) && tObj.grid.isCheckBoxSelection)) {
9791
9792
  const selectedItem = tObj.getCurrentViewRecords()[selectedrow.rowIndex];
9792
9793
  if (!isNullOrUndefined(selectedItem)) {
9793
- if ((selectedItem.level > tObj.getCurrentViewRecords()[selectedrow.rowIndex - 1].level)) {
9794
+ if ((selectedItem.level > tObj.getCurrentViewRecords()[selectedrow.rowIndex - 1].level) || this.parent.editSettings.mode === 'Batch'
9795
+ || this.parent.editSettings.mode === 'Cell') {
9794
9796
  indent.style.display = 'none';
9795
9797
  }
9796
9798
  else {
9797
9799
  indent.style.display = 'block';
9798
9800
  }
9799
- if (selectedItem.level === tObj.getCurrentViewRecords()[selectedrow.rowIndex - 1].level) {
9801
+ if ((selectedItem.level === tObj.getCurrentViewRecords()[selectedrow.rowIndex - 1].level) && this.parent.editSettings.mode !== 'Batch'
9802
+ && this.parent.editSettings.mode !== 'Cell') {
9800
9803
  indent.style.display = 'block';
9801
9804
  }
9802
- if (selectedItem.level === 0) {
9805
+ if ((selectedItem.level === 0) || this.parent.editSettings.mode === 'Batch'
9806
+ || this.parent.editSettings.mode === 'Cell') {
9803
9807
  outdent.style.display = 'none';
9804
9808
  }
9805
- if (selectedItem.level !== 0) {
9809
+ else {
9806
9810
  outdent.style.display = 'block';
9807
9811
  }
9808
9812
  }
9809
9813
  }
9810
- if (args['name'] === 'rowDeselected' && isNullOrUndefined(selectedrow) && !tObj.grid.isCheckBoxSelection) {
9811
- if (this.parent.toolbar['includes']('Indent')) {
9812
- indent.style.display = 'none';
9813
- }
9814
- if (this.parent.toolbar['includes']('Outdent')) {
9815
- outdent.style.display = 'none';
9816
- }
9817
- }
9814
+ }
9815
+ }
9816
+ else {
9817
+ if (tObj.grid.isEdit && isNullOrUndefined(selectedrow)) {
9818
+ indent.style.display = 'none';
9819
+ outdent.style.display = 'none';
9818
9820
  }
9819
9821
  }
9820
9822
  }
@@ -10097,7 +10099,8 @@ class BatchEdit {
10097
10099
  !this.parent.editModule['isAddedRowByContextMenu'] && (this.parent.grid.selectedRowIndex === -1 || this.parent.editModule['batchEditModule'].isAdd)) {
10098
10100
  this.selectedIndex = this.parent.editModule['selectedIndex'];
10099
10101
  this.addRowIndex = this.parent.editModule['addRowIndex'];
10100
- this.addRowRecord = this.batchRecords.length ? this.batchRecords[this.selectedIndex] : this.parent.getCurrentViewRecords()[this.selectedIndex];
10102
+ this.addRowRecord = this.batchRecords.length ? this.batchRecords[this.selectedIndex]
10103
+ : this.parent.getCurrentViewRecords()[this.selectedIndex];
10101
10104
  }
10102
10105
  else {
10103
10106
  this.selectedIndex = this.parent.grid.selectedRowIndex;
@@ -11978,6 +11981,8 @@ class VirtualTreeContentRenderer extends VirtualContentRenderer {
11978
11981
  const upScroll = (scrollArgs.offset.top - this.translateY) < 0;
11979
11982
  const downScroll = Math.ceil(scrollArgs.offset.top - this.translateY) >= scrollHeight;
11980
11983
  const selectedRowIndex = 'selectedRowIndex';
11984
+ const currentViewData = this.parent.currentViewData;
11985
+ const indexValue = 'index';
11981
11986
  if (upScroll && (scrollArgs.direction !== 'right' && scrollArgs.direction !== 'left')) {
11982
11987
  const vHeight = +(this.parent.height.toString().indexOf('%') < 0 ? this.parent.height :
11983
11988
  this.parent.element.getBoundingClientRect().height);
@@ -11996,6 +12001,10 @@ class VirtualTreeContentRenderer extends VirtualContentRenderer {
11996
12001
  this.endIndex = lastInx;
11997
12002
  this.startIndex = (this.startIndex - remains) < 0 ? 0 : (this.startIndex - remains);
11998
12003
  }
12004
+ if (currentViewData.length && ((currentViewData[0][indexValue] - this.startIndex) < (this.parent.pageSettings.pageSize / 2))) {
12005
+ this.startIndex = currentViewData[0][indexValue] - (this.parent.pageSettings.pageSize / 2);
12006
+ this.endIndex = this.startIndex + this.parent.pageSettings.pageSize;
12007
+ }
11999
12008
  //var firsttdinx = parseInt(this.parent.getContent().querySelector('.e-content td').getAttribute('index'), 0);
12000
12009
  let rowPt = Math.ceil(scrollArgs.offset.top / this.parent.getRowHeight());
12001
12010
  rowPt = rowPt % this.parent.pageSettings.pageSize;
@@ -12034,6 +12043,10 @@ class VirtualTreeContentRenderer extends VirtualContentRenderer {
12034
12043
  }
12035
12044
  this.startIndex = !isLastBlock ? lastIndex - this.parent.pageSettings.pageSize : nextSetResIndex;
12036
12045
  this.endIndex = lastIndex;
12046
+ if (currentViewData.length && this.startIndex > currentViewData[0][indexValue] &&
12047
+ ((this.startIndex - currentViewData[0][indexValue]) < (this.parent.pageSettings.pageSize / 2))) {
12048
+ this.startIndex = currentViewData[0][indexValue] + (this.parent.pageSettings.pageSize / 2);
12049
+ }
12037
12050
  if (scrollArgs.offset.top > (this.parent.getRowHeight() * this.totalRecords)) {
12038
12051
  this.translateY = this.getTranslateY(scrollArgs.offset.top, content.getBoundingClientRect().height);
12039
12052
  }