@syncfusion/ej2-treegrid 20.2.44 → 20.2.49

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.
@@ -1065,6 +1065,8 @@ class Selection {
1065
1065
  headerSelection(checkAll) {
1066
1066
  let index = -1;
1067
1067
  let length = 0;
1068
+ //This property used to maintain the check state of the currentview data after clear filtering
1069
+ let multiFilterCheckState = false;
1068
1070
  if (!isNullOrUndefined(this.parent.filterModule) && this.parent.filterModule.filteredResult.length > 0) {
1069
1071
  const filterResult = this.parent.filterModule.filteredResult;
1070
1072
  if (this.filteredList.length === 0) {
@@ -1073,6 +1075,10 @@ class Selection {
1073
1075
  else {
1074
1076
  if (this.filteredList !== filterResult) {
1075
1077
  this.filteredList = filterResult;
1078
+ multiFilterCheckState = true;
1079
+ }
1080
+ else {
1081
+ multiFilterCheckState = false;
1076
1082
  }
1077
1083
  }
1078
1084
  }
@@ -1091,6 +1097,9 @@ class Selection {
1091
1097
  if (data[i].checkboxState === 'check') {
1092
1098
  continue;
1093
1099
  }
1100
+ if (multiFilterCheckState) {
1101
+ continue;
1102
+ }
1094
1103
  data[i].checkboxState = 'check';
1095
1104
  this.updateSelectedItems(data[i], data[i].checkboxState);
1096
1105
  }
@@ -2080,7 +2089,7 @@ class DataManipulation {
2080
2089
  currentData.index = this.storedIndex;
2081
2090
  }
2082
2091
  if ((!isNullOrUndefined(currentData[this.parent.childMapping]) && !isCountRequired(this.parent)) ||
2083
- ((currentData[this.parent.hasChildMapping]) && isCountRequired(this.parent) && this.parent.initialRender)) {
2092
+ ((currentData[this.parent.hasChildMapping]) && isCountRequired(this.parent) && (this.parent.initialRender || isNullOrUndefined(this.parent['dataResults'].result)))) {
2084
2093
  currentData.hasChildRecords = true;
2085
2094
  if (this.parent.enableCollapseAll || !isNullOrUndefined(this.parent.dataStateChange)
2086
2095
  && isNullOrUndefined(currentData[this.parent.childMapping])) {
@@ -2636,7 +2645,7 @@ function editAction(details, control, isSelfReference, addRowIndex, selectedInde
2636
2645
  const childRecords = parentData ? parentData[control.childMapping] : [];
2637
2646
  for (let p = childRecords.length - 1; p >= 0; p--) {
2638
2647
  if (childRecords[p][control.idMapping] === currentData[control.idMapping]) {
2639
- if (!control.enableImmutableMode) {
2648
+ if (!control.enableImmutableMode && parentData.childRecords.length === parentData['Children'].length) {
2640
2649
  parentData['childRecords'].splice(p, 1);
2641
2650
  }
2642
2651
  childRecords.splice(p, 1);
@@ -4058,6 +4067,19 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
4058
4067
  if (args.requestType === 'save' && this.aggregates.map((ag) => ag.showChildSummary === true).length) {
4059
4068
  this.grid.refresh();
4060
4069
  }
4070
+ if (args.action === 'filter') {
4071
+ if (this.filterModule['currentFilterObject'] !== '' && this.enableVirtualization && !this.initialRender) {
4072
+ this.expandAll();
4073
+ }
4074
+ }
4075
+ if (args.requestType === 'searching') {
4076
+ if (this.searchSettings.key !== '' && this.enableVirtualization && !this.initialRender) {
4077
+ this.expandAll();
4078
+ }
4079
+ }
4080
+ if (args.action === 'clearFilter' && this.enableCollapseAll) {
4081
+ this.collapseAll();
4082
+ }
4061
4083
  if (this.action === 'indenting' || this.action === 'outdenting') {
4062
4084
  this.action = this.action === 'indenting' ? 'indented' : 'outdented';
4063
4085
  const selectedItem = [this.selectedRecords];
@@ -4336,7 +4358,7 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
4336
4358
  treeGridColumn[prop] = column[i][prop];
4337
4359
  }
4338
4360
  else if (prop === 'columns' && !isNullOrUndefined(column[i][prop])) {
4339
- gridColumn[prop] = this.getGridColumns(column[i][prop], false, index);
4361
+ gridColumn[prop] = this.getGridColumns(column[i][prop], false, this.columnModel.length - 1);
4340
4362
  treeGridColumn[prop] = column[i][prop];
4341
4363
  }
4342
4364
  else if (this.initialRender && !isNullOrUndefined(treeColumn) && this.enablePersistence && prop === 'edit') {
@@ -5126,15 +5148,15 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
5126
5148
  }
5127
5149
  }
5128
5150
  }
5129
- const merge$$1 = 'deepMerge';
5130
- this[merge$$1] = ['columns']; // Workaround for blazor updateModel
5151
+ const deepMerge = 'deepMerge';
5152
+ this[deepMerge] = ['columns']; // Workaround for blazor updateModel
5131
5153
  if (this.grid.columns.length !== this.columnModel.length) {
5132
5154
  this.stackedHeader = true;
5133
5155
  }
5134
5156
  if (!this.stackedHeader) {
5135
- this.setProperties({ columns: this.columnModel }, true);
5157
+ merge(this.columns, this.columnModel);
5136
5158
  }
5137
- this[merge$$1] = undefined; // Workaround for blazor updateModel
5159
+ this[deepMerge] = undefined; // Workaround for blazor updateModel
5138
5160
  return this.columnModel;
5139
5161
  }
5140
5162
  /**
@@ -8557,10 +8579,6 @@ class Filter$1 {
8557
8579
  }
8558
8580
  }
8559
8581
  else {
8560
- if ((!this.parent.enableCollapseAll || !this.parent.initialRender && isNullOrUndefined(this.parent['dataResults']['result']))
8561
- && parent['expanded'] === false && this.parent.getVisibleRecords().indexOf(record) === -1) {
8562
- this.parent.expandRow(this.parent.getRows()[parent['index']], parent);
8563
- }
8564
8582
  this.addParentRecord(parent);
8565
8583
  }
8566
8584
  }
@@ -9231,53 +9249,55 @@ class Toolbar$1 {
9231
9249
  this.parent.off(toolbarClick, this.toolbarClickHandler);
9232
9250
  }
9233
9251
  refreshToolbar(args) {
9234
- const tObj = this.parent;
9235
- let indentElement;
9236
- let outdentElement;
9237
- const indentID = tObj.element.id + '_gridcontrol_indent';
9238
- const outdentID = tObj.element.id + '_gridcontrol_outdent';
9239
9252
  const toolbarElement = this.parent.grid.toolbarModule.getToolbar();
9240
- const indentEle = toolbarElement.querySelector('#' + indentID);
9241
- const outdentEle = toolbarElement.querySelector('#' + outdentID);
9242
- let row = args.row;
9243
- const selectedrow = tObj.getSelectedRows()[0];
9244
- if (!isNullOrUndefined(row[0])) {
9245
- row = row[0];
9246
- }
9247
- row = (!isNullOrUndefined(selectedrow) && selectedrow.rowIndex !== row.rowIndex) ? selectedrow : row;
9248
- if (indentEle !== null && outdentEle !== null) {
9249
- indentElement = toolbarElement.querySelector('#' + indentID).parentElement;
9250
- outdentElement = toolbarElement.querySelector('#' + outdentID).parentElement;
9251
- if (row.rowIndex === 0 || tObj.getSelectedRowIndexes().length > 1) {
9252
- indentElement.classList.add('e-hidden');
9253
- outdentElement.classList.add('e-hidden');
9254
- }
9255
- else if (args['name'] !== 'rowDeselected' || (!isNullOrUndefined(selectedrow) && tObj.grid.isCheckBoxSelection)) {
9256
- const selectedItem = tObj.getCurrentViewRecords()[row.rowIndex];
9257
- if (!isNullOrUndefined(selectedItem)) {
9258
- if ((selectedItem.level > tObj.getCurrentViewRecords()[row.rowIndex - 1].level)) {
9259
- indentElement.classList.add('e-hidden');
9260
- }
9261
- else {
9262
- indentElement.classList.remove('e-hidden');
9253
+ if (!isNullOrUndefined(toolbarElement)) {
9254
+ const tObj = this.parent;
9255
+ let indentElement;
9256
+ let outdentElement;
9257
+ const indentID = tObj.element.id + '_gridcontrol_indent';
9258
+ const outdentID = tObj.element.id + '_gridcontrol_outdent';
9259
+ const indentEle = toolbarElement.querySelector('#' + indentID);
9260
+ const outdentEle = toolbarElement.querySelector('#' + outdentID);
9261
+ let row = args.row;
9262
+ const selectedrow = tObj.getSelectedRows()[0];
9263
+ if (!isNullOrUndefined(row[0])) {
9264
+ row = row[0];
9265
+ }
9266
+ row = (!isNullOrUndefined(selectedrow) && selectedrow.rowIndex !== row.rowIndex) ? selectedrow : row;
9267
+ if (indentEle !== null && outdentEle !== null) {
9268
+ indentElement = toolbarElement.querySelector('#' + indentID).parentElement;
9269
+ outdentElement = toolbarElement.querySelector('#' + outdentID).parentElement;
9270
+ if (row.rowIndex === 0 || tObj.getSelectedRowIndexes().length > 1) {
9271
+ indentElement.classList.add('e-hidden');
9272
+ outdentElement.classList.add('e-hidden');
9273
+ }
9274
+ else if (args['name'] !== 'rowDeselected' || (!isNullOrUndefined(selectedrow) && tObj.grid.isCheckBoxSelection)) {
9275
+ const selectedItem = tObj.getCurrentViewRecords()[row.rowIndex];
9276
+ if (!isNullOrUndefined(selectedItem)) {
9277
+ if ((selectedItem.level > tObj.getCurrentViewRecords()[row.rowIndex - 1].level)) {
9278
+ indentElement.classList.add('e-hidden');
9279
+ }
9280
+ else {
9281
+ indentElement.classList.remove('e-hidden');
9282
+ }
9283
+ if (selectedItem.level === tObj.getCurrentViewRecords()[row.rowIndex - 1].level) {
9284
+ indentElement.classList.remove('e-hidden');
9285
+ }
9286
+ if (selectedItem.level === 0) {
9287
+ outdentElement.classList.add('e-hidden');
9288
+ }
9289
+ if (selectedItem.level !== 0) {
9290
+ outdentElement.classList.remove('e-hidden');
9291
+ }
9263
9292
  }
9264
- if (selectedItem.level === tObj.getCurrentViewRecords()[row.rowIndex - 1].level) {
9265
- indentElement.classList.remove('e-hidden');
9293
+ }
9294
+ if (args['name'] === 'rowDeselected' && isNullOrUndefined(selectedrow) && !tObj.grid.isCheckBoxSelection) {
9295
+ if (this.parent.toolbar['includes']('Indent')) {
9296
+ indentElement.classList.add('e-hidden');
9266
9297
  }
9267
- if (selectedItem.level === 0) {
9298
+ if (this.parent.toolbar['includes']('Outdent')) {
9268
9299
  outdentElement.classList.add('e-hidden');
9269
9300
  }
9270
- if (selectedItem.level !== 0) {
9271
- outdentElement.classList.remove('e-hidden');
9272
- }
9273
- }
9274
- }
9275
- if (args['name'] === 'rowDeselected' && isNullOrUndefined(selectedrow) && !tObj.grid.isCheckBoxSelection) {
9276
- if (this.parent.toolbar['includes']('Indent')) {
9277
- indentElement.classList.add('e-hidden');
9278
- }
9279
- if (this.parent.toolbar['includes']('Outdent')) {
9280
- outdentElement.classList.add('e-hidden');
9281
9301
  }
9282
9302
  }
9283
9303
  }
@@ -9777,9 +9797,9 @@ class ContextMenu$1 {
9777
9797
  && !(isNullOrUndefined(editRecord)) && !(editRecord.classList.contains('e-menu-hide'))) {
9778
9798
  editRecord.style.display = 'none';
9779
9799
  }
9780
- if (indent || outdent) {
9781
- const tObj = this.parent;
9782
- const selectedrow = tObj.getSelectedRows()[0];
9800
+ const tObj = this.parent;
9801
+ const selectedrow = tObj.getSelectedRows()[0];
9802
+ if ((indent || outdent) && !isNullOrUndefined(selectedrow)) {
9783
9803
  const targetElement = args.event.target.closest('td');
9784
9804
  if (isNullOrUndefined(targetElement) || (!isNullOrUndefined(targetElement) && !targetElement.classList.contains('e-rowcell'))) {
9785
9805
  indent.style.display = outdent.style.display = 'none';
@@ -9791,31 +9811,32 @@ class ContextMenu$1 {
9791
9811
  else if (args['name'] !== 'rowDeselected' || (!isNullOrUndefined(selectedrow) && tObj.grid.isCheckBoxSelection)) {
9792
9812
  const selectedItem = tObj.getCurrentViewRecords()[selectedrow.rowIndex];
9793
9813
  if (!isNullOrUndefined(selectedItem)) {
9794
- if ((selectedItem.level > tObj.getCurrentViewRecords()[selectedrow.rowIndex - 1].level)) {
9814
+ if ((selectedItem.level > tObj.getCurrentViewRecords()[selectedrow.rowIndex - 1].level) || this.parent.editSettings.mode === 'Batch'
9815
+ || this.parent.editSettings.mode === 'Cell') {
9795
9816
  indent.style.display = 'none';
9796
9817
  }
9797
9818
  else {
9798
9819
  indent.style.display = 'block';
9799
9820
  }
9800
- if (selectedItem.level === tObj.getCurrentViewRecords()[selectedrow.rowIndex - 1].level) {
9821
+ if ((selectedItem.level === tObj.getCurrentViewRecords()[selectedrow.rowIndex - 1].level) && this.parent.editSettings.mode !== 'Batch'
9822
+ && this.parent.editSettings.mode !== 'Cell') {
9801
9823
  indent.style.display = 'block';
9802
9824
  }
9803
- if (selectedItem.level === 0) {
9825
+ if ((selectedItem.level === 0) || this.parent.editSettings.mode === 'Batch'
9826
+ || this.parent.editSettings.mode === 'Cell') {
9804
9827
  outdent.style.display = 'none';
9805
9828
  }
9806
- if (selectedItem.level !== 0) {
9829
+ else {
9807
9830
  outdent.style.display = 'block';
9808
9831
  }
9809
9832
  }
9810
9833
  }
9811
- if (args['name'] === 'rowDeselected' && isNullOrUndefined(selectedrow) && !tObj.grid.isCheckBoxSelection) {
9812
- if (this.parent.toolbar['includes']('Indent')) {
9813
- indent.style.display = 'none';
9814
- }
9815
- if (this.parent.toolbar['includes']('Outdent')) {
9816
- outdent.style.display = 'none';
9817
- }
9818
- }
9834
+ }
9835
+ }
9836
+ else {
9837
+ if (tObj.grid.isEdit && isNullOrUndefined(selectedrow)) {
9838
+ indent.style.display = 'none';
9839
+ outdent.style.display = 'none';
9819
9840
  }
9820
9841
  }
9821
9842
  }
@@ -11980,6 +12001,8 @@ class VirtualTreeContentRenderer extends VirtualContentRenderer {
11980
12001
  const upScroll = (scrollArgs.offset.top - this.translateY) < 0;
11981
12002
  const downScroll = Math.ceil(scrollArgs.offset.top - this.translateY) >= scrollHeight;
11982
12003
  const selectedRowIndex = 'selectedRowIndex';
12004
+ const currentViewData = this.parent.currentViewData;
12005
+ const indexValue = 'index';
11983
12006
  if (upScroll && (scrollArgs.direction !== 'right' && scrollArgs.direction !== 'left')) {
11984
12007
  const vHeight = +(this.parent.height.toString().indexOf('%') < 0 ? this.parent.height :
11985
12008
  this.parent.element.getBoundingClientRect().height);
@@ -11998,6 +12021,10 @@ class VirtualTreeContentRenderer extends VirtualContentRenderer {
11998
12021
  this.endIndex = lastInx;
11999
12022
  this.startIndex = (this.startIndex - remains) < 0 ? 0 : (this.startIndex - remains);
12000
12023
  }
12024
+ if (currentViewData.length && ((currentViewData[0][indexValue] - this.startIndex) < (this.parent.pageSettings.pageSize / 2))) {
12025
+ this.startIndex = currentViewData[0][indexValue] - (this.parent.pageSettings.pageSize / 2);
12026
+ this.endIndex = this.startIndex + this.parent.pageSettings.pageSize;
12027
+ }
12001
12028
  //var firsttdinx = parseInt(this.parent.getContent().querySelector('.e-content td').getAttribute('index'), 0);
12002
12029
  let rowPt = Math.ceil(scrollArgs.offset.top / this.parent.getRowHeight());
12003
12030
  rowPt = rowPt % this.parent.pageSettings.pageSize;
@@ -12036,6 +12063,10 @@ class VirtualTreeContentRenderer extends VirtualContentRenderer {
12036
12063
  }
12037
12064
  this.startIndex = !isLastBlock ? lastIndex - this.parent.pageSettings.pageSize : nextSetResIndex;
12038
12065
  this.endIndex = lastIndex;
12066
+ if (currentViewData.length && this.startIndex > currentViewData[0][indexValue] &&
12067
+ ((this.startIndex - currentViewData[0][indexValue]) < (this.parent.pageSettings.pageSize / 2))) {
12068
+ this.startIndex = currentViewData[0][indexValue] + (this.parent.pageSettings.pageSize / 2);
12069
+ }
12039
12070
  if (scrollArgs.offset.top > (this.parent.getRowHeight() * this.totalRecords)) {
12040
12071
  this.translateY = this.getTranslateY(scrollArgs.offset.top, content.getBoundingClientRect().height);
12041
12072
  }