@syncfusion/ej2-treegrid 20.3.48 → 20.3.50

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.
@@ -1644,7 +1644,12 @@ class Render {
1644
1644
  args.cell.querySelector('.e-treecell').innerHTML = summaryData;
1645
1645
  }
1646
1646
  else {
1647
- args.cell.innerHTML = summaryData;
1647
+ if (args.column.template) {
1648
+ args.cell.innerHTML = null;
1649
+ }
1650
+ else {
1651
+ args.cell.innerHTML = summaryData;
1652
+ }
1648
1653
  }
1649
1654
  }
1650
1655
  if (isNullOrUndefined(this.parent.rowTemplate)) {
@@ -1966,7 +1971,7 @@ class DataManipulation {
1966
1971
  }
1967
1972
  }
1968
1973
  else {
1969
- if (!isNullOrUndefined(records)) {
1974
+ if (!isNullOrUndefined(records) && !((this.parent.loadChildOnDemand) && isCountRequired(this.parent) && !isNullOrUndefined(this.parent['dataResults']['expandRecord']))) {
1970
1975
  this.convertToFlatData(records);
1971
1976
  }
1972
1977
  }
@@ -2117,8 +2122,8 @@ class DataManipulation {
2117
2122
  if (!Object.prototype.hasOwnProperty.call(currentData, 'index')) {
2118
2123
  currentData.index = this.storedIndex;
2119
2124
  }
2120
- if ((!isNullOrUndefined(currentData[this.parent.childMapping]) && !isCountRequired(this.parent)) || ((currentData[this.parent.hasChildMapping]) &&
2121
- isCountRequired(this.parent) && (this.parent.initialRender || isNullOrUndefined(this.parent['dataResults'].result) || this.parent.enableInfiniteScrolling))) {
2125
+ if ((!isNullOrUndefined(currentData[this.parent.childMapping]) && !isCountRequired(this.parent)) ||
2126
+ ((currentData[this.parent.hasChildMapping]) && isCountRequired(this.parent))) {
2122
2127
  currentData.hasChildRecords = true;
2123
2128
  if (this.parent.enableCollapseAll || !isNullOrUndefined(this.parent.dataStateChange)
2124
2129
  && isNullOrUndefined(currentData[this.parent.childMapping])) {
@@ -4070,7 +4075,7 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
4070
4075
  }
4071
4076
  this.notify('actionBegin', { editAction: args });
4072
4077
  if (!isRemoteData(this) && !isNullOrUndefined(this.filterModule) && !isCountRequired(this)
4073
- && (this.grid.filterSettings.columns.length === 0 || this.grid.searchSettings.key.length === 0)) {
4078
+ && (this.grid.filterSettings.columns.length === 0 && this.grid.searchSettings.key.length === 0)) {
4074
4079
  this.notify('clearFilters', { flatData: this.grid.dataSource });
4075
4080
  this.grid.setProperties({ dataSource: this.dataResults.result }, true);
4076
4081
  if (isNullOrUndefined(this.grid['changedProperties'].dataSource)) {
@@ -5765,11 +5770,13 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
5765
5770
  }
5766
5771
  });
5767
5772
  if (rows.length) {
5768
- if (action === 'collapse') {
5769
- this.collapseRow(rows[0]);
5770
- }
5771
- else {
5772
- this.expandRow(rows[0]);
5773
+ for (let i = 0; i < rows.length; i++) {
5774
+ if (action === 'collapse') {
5775
+ this.collapseRow(rows[i]);
5776
+ }
5777
+ else {
5778
+ this.expandRow(rows[i]);
5779
+ }
5773
5780
  }
5774
5781
  }
5775
5782
  else if (this.allowPaging) {
@@ -5798,7 +5805,7 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
5798
5805
  return e.parentUniqueID === record.uniqueID;
5799
5806
  });
5800
5807
  let targetEle;
5801
- if (!isRemoteData(this) && action === 'expand' && this.isSelfReference && isCountRequired(this) && !childRecords.length) {
5808
+ if ((!isRemoteData(this) && action === 'expand' && this.isSelfReference && isCountRequired(this) && !childRecords.length) || (action === 'collapse' || (this.isExpandAll && this.loadChildOnDemand) && !isRemoteData(this) && this.isSelfReference && isCountRequired(this))) {
5802
5809
  this.updateChildOnDemand(expandingArgs);
5803
5810
  }
5804
5811
  let gridRows = this.getRows();
@@ -5890,9 +5897,33 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
5890
5897
  }
5891
5898
  this.notify('rowExpandCollapse', { detailrows: detailrows, action: displayAction, record: record, row: row });
5892
5899
  this.updateAltRow(gridRows);
5900
+ this.updateGridRowsVisible();
5893
5901
  }
5894
5902
  }
5903
+ updateGridRowsVisible() {
5904
+ const rowsToRefresh = this.grid.getRowsObject();
5905
+ const rows = this.getRows();
5906
+ for (let i = 0; i < rows.length; i++) {
5907
+ for (let j = 0; j < rowsToRefresh.length; j++) {
5908
+ if (rows[i].dataset.uid === rowsToRefresh[j].uid) {
5909
+ rowsToRefresh[j].visible = rows[i].style.display === 'none' ? false : true;
5910
+ }
5911
+ }
5912
+ }
5913
+ this.grid.notify('refresh-Expand-and-Collapse', { rows: rowsToRefresh });
5914
+ }
5895
5915
  updateChildOnDemand(expandingArgs) {
5916
+ if (expandingArgs.requestType === 'collapse' && isCountRequired(this)) {
5917
+ const flatDataRecords = [...this.flatData];
5918
+ for (let i = 0; i < flatDataRecords.length; i++) {
5919
+ if (flatDataRecords[i]['parentUniqueID'] === expandingArgs.data['uniqueID']) {
5920
+ flatDataRecords.splice(i, 1);
5921
+ i = i - 1;
5922
+ }
5923
+ }
5924
+ this.dataResults.result = flatDataRecords;
5925
+ return;
5926
+ }
5896
5927
  const deff = new Deferred();
5897
5928
  const childDataBind = 'childDataBind';
5898
5929
  expandingArgs[childDataBind] = deff.resolve;
@@ -5900,7 +5931,12 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
5900
5931
  this.trigger(dataStateChange, expandingArgs);
5901
5932
  deff.promise.then(() => {
5902
5933
  if (expandingArgs.childData.length) {
5903
- this.flatData = this.infiniteScrollData;
5934
+ if (isCountRequired(this)) {
5935
+ this.flatData = this.dataResults.result;
5936
+ }
5937
+ if (this.enableInfiniteScrolling && isCountRequired(this)) {
5938
+ this.flatData = this.infiniteScrollData;
5939
+ }
5904
5940
  const currentData = (this.flatData);
5905
5941
  let index = 0;
5906
5942
  for (let i = 0; i < currentData.length; i++) {
@@ -5935,7 +5971,13 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
5935
5971
  (childData[i][this.hasChildMapping] && isCountRequired(this))) {
5936
5972
  childData[i].hasChildRecords = true;
5937
5973
  }
5938
- currentData.splice(index + 1 + i, record[this.childMapping] && record[this.childMapping][i] ? 1 : 0, childData[i]);
5974
+ if (isCountRequired(this) && record[this.childMapping] && record[this.childMapping][i]) {
5975
+ currentData.splice(index + 1 + i, 0, childData[i]);
5976
+ }
5977
+ else {
5978
+ currentData.splice(index + 1 + i, record[this.childMapping] &&
5979
+ record[this.childMapping][i] ? 1 : 0, childData[i]);
5980
+ }
5939
5981
  }
5940
5982
  else {
5941
5983
  currentData.splice(index + 1 + i, 1);
@@ -5949,6 +5991,10 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
5949
5991
  data.push(expandingArgs.childData[j]);
5950
5992
  }
5951
5993
  }
5994
+ if (isCountRequired(this) && this.loadChildOnDemand && expandingArgs.requestType === 'expand') {
5995
+ this.dataResults['expandRecord'] = {};
5996
+ this.dataResults['expandRecord'] = expandingArgs.data;
5997
+ }
5952
5998
  this.isExpandRefresh = true;
5953
5999
  const scrollHeightBeforeRefresh = this.getContentTable().parentElement.scrollTop;
5954
6000
  this.grid.refresh();
@@ -8147,7 +8193,12 @@ class RowDD$1 {
8147
8193
  }
8148
8194
  length = record.childRecords.length;
8149
8195
  for (let i = 0; i < length; i++) {
8150
- currentRecord = getValue('uniqueIDCollection.' + record.childRecords[i].uniqueID, tObj);
8196
+ if (!this.isMultipleGrid) {
8197
+ currentRecord = getValue('uniqueIDCollection.' + record.childRecords[i].uniqueID, tObj);
8198
+ }
8199
+ else {
8200
+ currentRecord = record.childRecords[i];
8201
+ }
8151
8202
  count++;
8152
8203
  tObj.flatData.splice(count, 0, currentRecord);
8153
8204
  setValue('uniqueIDCollection.' + currentRecord.uniqueID, currentRecord, this.parent);
@@ -8169,7 +8220,12 @@ class RowDD$1 {
8169
8220
  }
8170
8221
  length = record.childRecords.length;
8171
8222
  for (let i = 0; i < length; i++) {
8172
- currentRecord = getValue('uniqueIDCollection.' + record.childRecords[i].uniqueID, this.parent);
8223
+ if (!this.isMultipleGrid) {
8224
+ currentRecord = getValue('uniqueIDCollection.' + record.childRecords[i].uniqueID, this.parent);
8225
+ }
8226
+ else {
8227
+ currentRecord = record.childRecords[i];
8228
+ }
8173
8229
  let parentData;
8174
8230
  if (record.parentItem) {
8175
8231
  parentData = getParentData(this.parent, record.parentItem.uniqueID);
@@ -8432,7 +8488,11 @@ class TreeVirtualRowModelGenerator extends VirtualRowModelGenerator {
8432
8488
  const info = this.getDataInfo();
8433
8489
  if (!isNullOrUndefined(notifyArgs.virtualInfo)) {
8434
8490
  if (notifyArgs.virtualInfo.direction !== 'right' && notifyArgs.virtualInfo.direction !== 'left') {
8435
- notifyArgs.virtualInfo.blockIndexes = info.blockIndexes;
8491
+ if (!((this.parent.dataSource instanceof DataManager && this.parent.dataSource.dataSource.url !== undefined
8492
+ && !this.parent.dataSource.dataSource.offline && this.parent.dataSource.dataSource.url !== '') || isCountRequired(this.parent))
8493
+ || notifyArgs.virtualInfo.blockIndexes.length === 1) {
8494
+ notifyArgs.virtualInfo.blockIndexes = info.blockIndexes;
8495
+ }
8436
8496
  }
8437
8497
  else {
8438
8498
  notifyArgs.virtualInfo.blockIndexes = this.getBlockIndexes(notifyArgs.virtualInfo.page);
@@ -11879,7 +11939,7 @@ class VirtualTreeContentRenderer extends VirtualContentRenderer {
11879
11939
  this.parent[action]('data-ready', this.onDataReady, this);
11880
11940
  this.parent[action]('refresh-virtual-block', this.refreshContentRows, this);
11881
11941
  this.fn = () => {
11882
- this.observers.observes((scrollArgs) => this.scrollListeners(scrollArgs), this.onEnteredAction());
11942
+ this.observers.observes((scrollArgs) => this.scrollListeners(scrollArgs), this.onEnteredAction(), this.parent);
11883
11943
  this.parent.off('content-ready', this.fn);
11884
11944
  };
11885
11945
  this.parent.addEventListener('dataBound', this.dataBoundEvent.bind(this));
@@ -12207,7 +12267,9 @@ class VirtualTreeContentRenderer extends VirtualContentRenderer {
12207
12267
  }
12208
12268
  }
12209
12269
  if (((downScroll && (scrollArgs.offset.top < (this.parent.getRowHeight() * this.totalRecords)))
12210
- || (upScroll)) || (scrollArgs.direction === 'right' || scrollArgs.direction === 'left')) {
12270
+ || (upScroll)) || (scrollArgs.direction === 'right' || scrollArgs.direction === 'left') ||
12271
+ ((this.parent.dataSource instanceof DataManager && this.parent.dataSource.dataSource.url !== undefined
12272
+ && !this.parent.dataSource.dataSource.offline && this.parent.dataSource.dataSource.url !== '') || isCountRequired(this.parent))) {
12211
12273
  const viewInfo = this.currentInfo = getValue('getInfoFromView', this).apply(this, [scrollArgs.direction, info, scrollArgs.offset]);
12212
12274
  this.previousInfo = viewInfo;
12213
12275
  this.parent.setColumnIndexesInView(this.parent.enableColumnVirtualization ? viewInfo.columnIndexes : []);
@@ -12324,26 +12386,26 @@ class TreeInterSectionObserver extends InterSectionObserver {
12324
12386
  this.lastPos = 0;
12325
12387
  this.timer = 0;
12326
12388
  }
12327
- observes(callback, onEnterCallback) {
12389
+ observes(callback, onEnterCallback, instance) {
12328
12390
  const containerRect = 'containerRect';
12329
12391
  super[containerRect] = getValue('options', this).container.getBoundingClientRect();
12330
- EventHandler.add(getValue('options', this).container, 'scroll', this.virtualScrollHandlers(callback, onEnterCallback), this);
12392
+ EventHandler.add(getValue('options', this).container, 'scroll', this.virtualScrollHandlers(callback, onEnterCallback, instance), this);
12331
12393
  if (getValue('options', this).movableContainer) {
12332
12394
  const movableContainerRect = 'movableContainerRect';
12333
12395
  super[movableContainerRect] = getValue('options', this).movableContainer.getBoundingClientRect();
12334
- EventHandler.add(getValue('options', this).movableContainer, 'scroll', this.virtualScrollHandlers(callback, onEnterCallback), this);
12396
+ EventHandler.add(getValue('options', this).movableContainer, 'scroll', this.virtualScrollHandlers(callback, onEnterCallback, instance), this);
12335
12397
  }
12336
12398
  }
12337
12399
  clear() {
12338
12400
  this.lastPos = null;
12339
12401
  }
12340
- virtualScrollHandlers(callback, onEnterCallback) {
12402
+ virtualScrollHandlers(callback, onEnterCallback, instance) {
12341
12403
  const delay = Browser.info.name === 'chrome' ? 200 : 100;
12342
12404
  const options = 'options';
12343
12405
  const movableEle = 'movableEle';
12344
12406
  const element = 'element';
12345
12407
  const fromWheel = 'fromWheel';
12346
- const debounced100 = debounce(callback, delay);
12408
+ //const debounced100: Function = debounce(callback, delay);
12347
12409
  const debounced50 = debounce(callback, 50);
12348
12410
  this[options].prevTop = this[options].prevLeft = 0;
12349
12411
  return (e) => {
@@ -12381,15 +12443,23 @@ class TreeInterSectionObserver extends InterSectionObserver {
12381
12443
  }
12382
12444
  }
12383
12445
  if (check) {
12384
- let fn = debounced100;
12446
+ const fn = debounced50;
12385
12447
  if (current.axis === 'X') {
12386
- fn = debounced50;
12387
12448
  fn({ direction: direction, sentinel: current, offset: { top: top, left: left },
12388
12449
  focusElement: document.activeElement });
12389
12450
  }
12390
12451
  else {
12391
- callback({ direction: direction, sentinel: current, offset: { top: top, left: left },
12392
- focusElement: document.activeElement });
12452
+ if ((instance.dataSource instanceof DataManager && instance.dataSource.dataSource.url !== undefined
12453
+ && !instance.dataSource.dataSource.offline && instance.dataSource.dataSource.url !== '') || isCountRequired(instance)) {
12454
+ fn({ direction: direction, sentinel: current, offset: { top: top, left: left },
12455
+ focusElement: document.activeElement });
12456
+ }
12457
+ else {
12458
+ callback({
12459
+ direction: direction, sentinel: current, offset: { top: top, left: left },
12460
+ focusElement: document.activeElement
12461
+ });
12462
+ }
12393
12463
  }
12394
12464
  }
12395
12465
  this[fromWheel] = false;