@syncfusion/ej2-treegrid 33.1.46 → 33.1.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.
@@ -2019,16 +2019,6 @@ class Render {
2019
2019
  }
2020
2020
  const data = args.data;
2021
2021
  const parentData = data.parentItem;
2022
- if (!isNullOrUndefined(parentData) && data.isCollapsedChild && !isNullOrUndefined(args.row)) {
2023
- this.parent['toggleRowVisibility'](args.row, 'e-childrow-hidden');
2024
- const rowsObj = this.parent.grid.getRowsObject();
2025
- if (!this.parent.grid.isFrozenGrid() && !isNullOrUndefined(args.row.getAttribute('data-uid'))) {
2026
- const row = rowsObj.filter((e) => e.uid === args.row.getAttribute('data-uid'))[0];
2027
- if (row) {
2028
- row.visible = false;
2029
- }
2030
- }
2031
- }
2032
2022
  if (!isNullOrUndefined(data.parentItem) && !isFilterChildHierarchy(this.parent) &&
2033
2023
  (!(this.parent.allowPaging && !(this.parent.pageSettings.pageSizeMode === 'Root')) ||
2034
2024
  (isRemoteData(this.parent) && !isOffline(this.parent)))) {
@@ -9822,7 +9812,7 @@ class RowDD {
9822
9812
  this.removeLastrowBorder(rowEle);
9823
9813
  for (let i = 0; i < args.rows.length; i++) {
9824
9814
  if (!isNullOrUndefined(rowEle) && rowEle.getAttribute('data-uid') === args.rows[parseInt(i.toString(), 10)].getAttribute('data-uid')
9825
- || !parentsUntil(args.target, 'e-gridcontent')) {
9815
+ || !parentsUntil(args.target, 'e-gridcontent') || rowEle.classList.contains('e-summaryrow')) {
9826
9816
  this.dropPosition = 'Invalid';
9827
9817
  this.addErrorElem();
9828
9818
  if (isNullOrUndefined(this.parent.rowDropSettings.targetID)) {
@@ -10332,8 +10322,10 @@ class RowDD {
10332
10322
  rowDropped(args) {
10333
10323
  if (!isNullOrUndefined(this.parent.aggregates[0]) && this.parent.aggregates[0].showChildSummary) {
10334
10324
  const records = this.parent.grid.getCurrentViewRecords();
10335
- args.fromIndex = records[args.fromIndex].index;
10336
- args.dropIndex = records[args.dropIndex].index;
10325
+ if (!isNullOrUndefined(records[records[args.fromIndex].index]) && !isNullOrUndefined(records[records[args.dropIndex].index])) {
10326
+ args.fromIndex = records[args.fromIndex].index;
10327
+ args.dropIndex = records[args.dropIndex].index;
10328
+ }
10337
10329
  }
10338
10330
  const tObj = this.parent;
10339
10331
  const parentItem = 'parentItem';
@@ -10852,14 +10844,16 @@ class RowDD {
10852
10844
  else {
10853
10845
  currentRecord = record.childRecords[parseInt(i.toString(), 10)];
10854
10846
  }
10855
- count++;
10856
- tObj.flatData.splice(count, 0, currentRecord);
10857
- setValue('uniqueIDCollection.' + currentRecord.uniqueID, currentRecord, this.parent);
10858
- if (tObj.parentIdMapping) {
10859
- this.treeData.splice(count, 0, currentRecord.taskData);
10860
- }
10861
- if (currentRecord.hasChildRecords) {
10862
- count = this.updateChildRecord(currentRecord, count);
10847
+ if (!isNullOrUndefined(currentRecord)) {
10848
+ count++;
10849
+ tObj.flatData.splice(count, 0, currentRecord);
10850
+ setValue('uniqueIDCollection.' + currentRecord.uniqueID, currentRecord, this.parent);
10851
+ if (tObj.parentIdMapping) {
10852
+ this.treeData.splice(count, 0, currentRecord.taskData);
10853
+ }
10854
+ if (currentRecord.hasChildRecords) {
10855
+ count = this.updateChildRecord(currentRecord, count);
10856
+ }
10863
10857
  }
10864
10858
  }
10865
10859
  return count;
@@ -10886,17 +10880,19 @@ class RowDD {
10886
10880
  else {
10887
10881
  currentRecord = record.childRecords[parseInt(i.toString(), 10)];
10888
10882
  }
10889
- let parentData;
10890
- if (record.parentItem) {
10891
- parentData = getParentData(this.parent, record.parentItem.uniqueID);
10892
- }
10893
- if (isNullOrUndefined(parentData) && !isNullOrUndefined(record.parentItem)) {
10894
- parentData = record.parentItem;
10895
- }
10896
- currentRecord.level = record.parentItem ? parentData.level + level : record.level + 1;
10897
- if (currentRecord.hasChildRecords) {
10898
- level--;
10899
- level = this.updateChildRecordLevel(currentRecord, level);
10883
+ if (!isNullOrUndefined(currentRecord)) {
10884
+ let parentData;
10885
+ if (record.parentItem) {
10886
+ parentData = getParentData(this.parent, record.parentItem.uniqueID);
10887
+ }
10888
+ if (isNullOrUndefined(parentData) && !isNullOrUndefined(record.parentItem)) {
10889
+ parentData = record.parentItem;
10890
+ }
10891
+ currentRecord.level = record.parentItem ? parentData.level + level : record.level + 1;
10892
+ if (currentRecord.hasChildRecords) {
10893
+ level--;
10894
+ level = this.updateChildRecordLevel(currentRecord, level);
10895
+ }
10900
10896
  }
10901
10897
  }
10902
10898
  return level;
@@ -11025,22 +11021,29 @@ class RowDD {
11025
11021
  treeGridData = this.parent.dataSource;
11026
11022
  }
11027
11023
  for (let i = 0; i < treeGridData.length; i++) {
11028
- if (treeGridData[parseInt(i.toString(), 10)][this.parent.idMapping] === currentRecord.taskData[this.parent.idMapping]) {
11029
- idx = i;
11024
+ if (!isNullOrUndefined(currentRecord.taskData)) {
11025
+ if (treeGridData[parseInt(i.toString(), 10)][this.parent.idMapping] === currentRecord.taskData[this.parent.idMapping]) {
11026
+ idx = i;
11027
+ break;
11028
+ }
11030
11029
  }
11031
11030
  }
11032
11031
  for (let i = 0; i < this.treeGridData.length; i++) {
11033
- if (this.treeGridData[parseInt(i.toString(), 10)][this.parent.idMapping]
11034
- === currentRecord.taskData[this.parent.idMapping]) {
11035
- idz = i;
11036
- break;
11032
+ if (!isNullOrUndefined(currentRecord.taskData)) {
11033
+ if (this.treeGridData[parseInt(i.toString(), 10)][this.parent.idMapping]
11034
+ === currentRecord.taskData[this.parent.idMapping]) {
11035
+ idz = i;
11036
+ break;
11037
+ }
11037
11038
  }
11038
11039
  }
11039
11040
  if (idx !== -1 && !isNullOrUndefined(idx)) {
11040
11041
  dataSource.splice(idx, 1);
11042
+ idx = -1;
11041
11043
  }
11042
11044
  if (idz !== -1 && !isNullOrUndefined(idz)) {
11043
11045
  this.treeGridData.splice(idz, 1);
11046
+ idz = -1;
11044
11047
  }
11045
11048
  if (currentRecord.hasChildRecords) {
11046
11049
  this.removeChildItem(currentRecord);
@@ -11061,7 +11064,7 @@ class RowDD {
11061
11064
  }
11062
11065
  for (let i = 0; i < record.childRecords.length; i++) {
11063
11066
  currentRecord = record.childRecords[parseInt(i.toString(), 10)];
11064
- count++;
11067
+ count = currentRecord.isSummaryRow ? count : count + 1;
11065
11068
  if (currentRecord.hasChildRecords) {
11066
11069
  count = this.getChildCount(currentRecord, count);
11067
11070
  }
@@ -11340,21 +11343,6 @@ class Filter {
11340
11343
  if (this.flatFilteredData.length > 0 && this.isHierarchyFilter) {
11341
11344
  this.updateFilterLevel();
11342
11345
  }
11343
- for (let i = 0; i < this.filteredResult.length; i++) {
11344
- const record = this.filteredResult[parseInt(i.toString(), 10)];
11345
- if (!isNullOrUndefined(record.parentItem)) {
11346
- const parentUID = record.parentItem.uniqueID;
11347
- const parentPresent = this.filteredResult.some((r) => {
11348
- return !isNullOrUndefined(r.uniqueID) && r.uniqueID === parentUID;
11349
- });
11350
- if (parentPresent) {
11351
- record.isCollapsedChild = !getExpandStatus(this.parent, record, this.parent.parentData);
11352
- }
11353
- else {
11354
- record.isCollapsedChild = false;
11355
- }
11356
- }
11357
- }
11358
11346
  this.parent.notify('updateAction', { result: this.filteredResult });
11359
11347
  }
11360
11348
  updateParentFilteredRecord(record) {
@@ -15468,7 +15456,7 @@ class VirtualTreeContentRenderer extends VirtualContentRenderer {
15468
15456
  this.parent.root.scrollPosition = scrollArgs.offset;
15469
15457
  }
15470
15458
  const info = scrollArgs.sentinel;
15471
- const rowHeight = this.parent.getRowHeight();
15459
+ const rowHeight = parseInt(this.parent.getRowHeight().toString(), 10);
15472
15460
  const outBuffer = this.parent.pageSettings.pageSize - Math.ceil(this.parent.pageSettings.pageSize / 2);
15473
15461
  let content;
15474
15462
  if (!isNullOrUndefined(this.parent.contentModule)) {
@@ -16046,7 +16034,13 @@ class VirtualScroll {
16046
16034
  const isFlatHierarchy = this.parent.filterSettings.hierarchyMode === 'Child' ||
16047
16035
  this.parent.filterSettings.hierarchyMode === 'None';
16048
16036
  const visualData = isFiltering && isFlatHierarchy
16049
- ? parents
16037
+ ? parents.filter((e) => {
16038
+ if (isNullOrUndefined(e.parentItem)) {
16039
+ return true;
16040
+ }
16041
+ const hasParentInFilteredList = parents.some((p) => p.uniqueID === e.parentItem.uniqueID);
16042
+ return hasParentInFilteredList ? getExpandStatus(this.parent, e) : true;
16043
+ })
16050
16044
  : parents.filter((e) => getExpandStatus(this.parent, e));
16051
16045
  this.visualData = visualData;
16052
16046
  pageingDetails.count = visualData.length;
@@ -16102,27 +16096,9 @@ class VirtualScroll {
16102
16096
  endIndex = startIndex + this.parent.grid.pageSettings.pageSize;
16103
16097
  }
16104
16098
  if (!isNullOrUndefined(this.expandCollapseRec)) {
16105
- const resourceCount = this.parent.grid.pageSettings.pageSize;
16106
- let sIndex = visualData.indexOf(this.expandCollapseRec);
16107
- const tempdata = visualData.slice(sIndex, sIndex + resourceCount);
16108
- if (tempdata.length < resourceCount && sIndex >= 0 && startIndex !== 0) {
16109
- sIndex = visualData.length - resourceCount;
16110
- sIndex = sIndex > 0 ? sIndex : 0;
16111
- endIndex = visualData.length;
16112
- if (endIndex - startIndex < resourceCount) {
16113
- startIndex = sIndex;
16114
- if (visualData.indexOf(this.expandCollapseRec) > visualData.length - resourceCount / 2) {
16115
- const newTranslateY = startIndex * this.parent.grid.getRowHeight();
16116
- this.parent.grid.contentModule['translateY'] = newTranslateY;
16117
- this.parent.grid.contentModule.virtualEle.adjustTable(0, newTranslateY);
16118
- }
16119
- }
16120
- }
16121
- else if (getValue('isCollapseAll', this.parent)) {
16122
- startIndex = 0;
16123
- endIndex = this.parent.grid.pageSettings.pageSize - 1;
16124
- this.parent.grid.notify(virtualActionArgs, { setTop: true });
16125
- }
16099
+ const result = this.adjustRangeForExpandCollapse(startIndex, endIndex, visualData);
16100
+ startIndex = result.startIndex;
16101
+ endIndex = result.endIndex;
16126
16102
  }
16127
16103
  //}
16128
16104
  if (this.prevrequestType === 'collapseAll' && pageingDetails.actionArgs.requestType === 'virtualscroll'
@@ -16153,6 +16129,30 @@ class VirtualScroll {
16153
16129
  }
16154
16130
  this.parent.notify('updateAction', pageingDetails);
16155
16131
  }
16132
+ adjustRangeForExpandCollapse(startIndex, endIndex, visualData) {
16133
+ const pageSize = this.parent.grid.pageSettings.pageSize;
16134
+ const expandedRecordIndex = visualData.indexOf(this.expandCollapseRec);
16135
+ const pageWindowRecords = visualData.slice(expandedRecordIndex, expandedRecordIndex + pageSize);
16136
+ if (pageWindowRecords.length < pageSize && expandedRecordIndex >= 0 && startIndex !== 0) {
16137
+ let startForLastPage = visualData.length - pageSize;
16138
+ startForLastPage = startForLastPage > 0 ? startForLastPage : 0;
16139
+ endIndex = visualData.length;
16140
+ if (endIndex - startIndex < pageSize) {
16141
+ startIndex = startForLastPage;
16142
+ if (expandedRecordIndex > visualData.length - pageSize / 2) {
16143
+ const viewportTranslateY = startIndex * this.parent.grid.getRowHeight();
16144
+ this.parent.grid.contentModule['translateY'] = viewportTranslateY;
16145
+ this.parent.grid.contentModule.virtualEle.adjustTable(0, viewportTranslateY);
16146
+ }
16147
+ }
16148
+ }
16149
+ else if (getValue('isCollapseAll', this.parent)) {
16150
+ startIndex = 0;
16151
+ endIndex = this.parent.grid.pageSettings.pageSize - 1;
16152
+ this.parent.grid.notify(virtualActionArgs, { setTop: true });
16153
+ }
16154
+ return { startIndex: startIndex, endIndex: endIndex };
16155
+ }
16156
16156
  /**
16157
16157
  * To destroy the virtualScroll module
16158
16158
  *