@syncfusion/ej2-treegrid 33.1.47 → 33.2.3

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)))) {
@@ -4830,7 +4820,7 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
4830
4820
  const portals = 'portals';
4831
4821
  if (!(this.isReact && isNullOrUndefined(this[`${portals}`]))) {
4832
4822
  const isGantt = this['isFromGantt'] && !isNullOrUndefined(this['root'].clearTemplate) &&
4833
- this['root'].chartRowsModule['isGridRowRefreshed'];
4823
+ (this['root'].chartRowsModule['isGridRowRefreshed'] || this['root']['registeredTemplate']);
4834
4824
  if (isGantt) {
4835
4825
  this['root'].clearTemplate(args, index, callback);
4836
4826
  }
@@ -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,23 +11343,6 @@ class Filter {
11340
11343
  if (this.flatFilteredData.length > 0 && this.isHierarchyFilter) {
11341
11344
  this.updateFilterLevel();
11342
11345
  }
11343
- if (hierarchyMode === 'None') {
11344
- for (let i = 0; i < this.filteredResult.length; i++) {
11345
- const record = this.filteredResult[parseInt(i.toString(), 10)];
11346
- if (!isNullOrUndefined(record.parentItem)) {
11347
- const parentUID = record.parentItem.uniqueID;
11348
- const parentPresent = this.filteredResult.some((r) => {
11349
- return !isNullOrUndefined(r.uniqueID) && r.uniqueID === parentUID;
11350
- });
11351
- if (parentPresent) {
11352
- setValue('isCollapsedChild', !getExpandStatus(this.parent, record, this.parent.parentData), record);
11353
- }
11354
- else {
11355
- setValue('isCollapsedChild', false, record);
11356
- }
11357
- }
11358
- }
11359
- }
11360
11346
  this.parent.notify('updateAction', { result: this.filteredResult });
11361
11347
  }
11362
11348
  updateParentFilteredRecord(record) {
@@ -11481,9 +11467,6 @@ class Filter {
11481
11467
  currentRecord.hasFilteredChildRecords = null;
11482
11468
  currentRecord.filterLevel = null;
11483
11469
  }
11484
- if (!isNullOrUndefined(currentRecord.isCollapsedChild)) {
11485
- currentRecord.isCollapsedChild = null;
11486
- }
11487
11470
  }
11488
11471
  this.filteredResult = [];
11489
11472
  this.parent.notify('updateResults', { result: flatData, count: flatData.length });
@@ -15473,7 +15456,7 @@ class VirtualTreeContentRenderer extends VirtualContentRenderer {
15473
15456
  this.parent.root.scrollPosition = scrollArgs.offset;
15474
15457
  }
15475
15458
  const info = scrollArgs.sentinel;
15476
- const rowHeight = this.parent.getRowHeight();
15459
+ const rowHeight = parseInt(this.parent.getRowHeight().toString(), 10);
15477
15460
  const outBuffer = this.parent.pageSettings.pageSize - Math.ceil(this.parent.pageSettings.pageSize / 2);
15478
15461
  let content;
15479
15462
  if (!isNullOrUndefined(this.parent.contentModule)) {
@@ -16051,7 +16034,13 @@ class VirtualScroll {
16051
16034
  const isFlatHierarchy = this.parent.filterSettings.hierarchyMode === 'Child' ||
16052
16035
  this.parent.filterSettings.hierarchyMode === 'None';
16053
16036
  const visualData = isFiltering && isFlatHierarchy
16054
- ? 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
+ })
16055
16044
  : parents.filter((e) => getExpandStatus(this.parent, e));
16056
16045
  this.visualData = visualData;
16057
16046
  pageingDetails.count = visualData.length;
@@ -16107,27 +16096,9 @@ class VirtualScroll {
16107
16096
  endIndex = startIndex + this.parent.grid.pageSettings.pageSize;
16108
16097
  }
16109
16098
  if (!isNullOrUndefined(this.expandCollapseRec)) {
16110
- const resourceCount = this.parent.grid.pageSettings.pageSize;
16111
- let sIndex = visualData.indexOf(this.expandCollapseRec);
16112
- const tempdata = visualData.slice(sIndex, sIndex + resourceCount);
16113
- if (tempdata.length < resourceCount && sIndex >= 0 && startIndex !== 0) {
16114
- sIndex = visualData.length - resourceCount;
16115
- sIndex = sIndex > 0 ? sIndex : 0;
16116
- endIndex = visualData.length;
16117
- if (endIndex - startIndex < resourceCount) {
16118
- startIndex = sIndex;
16119
- if (visualData.indexOf(this.expandCollapseRec) > visualData.length - resourceCount / 2) {
16120
- const newTranslateY = startIndex * this.parent.grid.getRowHeight();
16121
- this.parent.grid.contentModule['translateY'] = newTranslateY;
16122
- this.parent.grid.contentModule.virtualEle.adjustTable(0, newTranslateY);
16123
- }
16124
- }
16125
- }
16126
- else if (getValue('isCollapseAll', this.parent)) {
16127
- startIndex = 0;
16128
- endIndex = this.parent.grid.pageSettings.pageSize - 1;
16129
- this.parent.grid.notify(virtualActionArgs, { setTop: true });
16130
- }
16099
+ const result = this.adjustRangeForExpandCollapse(startIndex, endIndex, visualData);
16100
+ startIndex = result.startIndex;
16101
+ endIndex = result.endIndex;
16131
16102
  }
16132
16103
  //}
16133
16104
  if (this.prevrequestType === 'collapseAll' && pageingDetails.actionArgs.requestType === 'virtualscroll'
@@ -16158,6 +16129,30 @@ class VirtualScroll {
16158
16129
  }
16159
16130
  this.parent.notify('updateAction', pageingDetails);
16160
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
+ }
16161
16156
  /**
16162
16157
  * To destroy the virtualScroll module
16163
16158
  *