@syncfusion/ej2-treegrid 20.1.47 → 20.1.48

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.
Files changed (61) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/ej2-treegrid.umd.min.js +2 -2
  3. package/dist/ej2-treegrid.umd.min.js.map +1 -1
  4. package/dist/es6/ej2-treegrid.es2015.js +74 -39
  5. package/dist/es6/ej2-treegrid.es2015.js.map +1 -1
  6. package/dist/es6/ej2-treegrid.es5.js +77 -46
  7. package/dist/es6/ej2-treegrid.es5.js.map +1 -1
  8. package/dist/global/ej2-treegrid.min.js +2 -2
  9. package/dist/global/ej2-treegrid.min.js.map +1 -1
  10. package/dist/global/index.d.ts +1 -1
  11. package/package.json +7 -7
  12. package/src/treegrid/actions/batch-edit.js +21 -4
  13. package/src/treegrid/actions/edit.js +15 -0
  14. package/src/treegrid/actions/filter.js +3 -0
  15. package/src/treegrid/actions/rowdragdrop.js +4 -9
  16. package/src/treegrid/base/treegrid-model.d.ts +1 -1
  17. package/src/treegrid/base/treegrid.d.ts +1 -6
  18. package/src/treegrid/base/treegrid.js +34 -33
  19. package/styles/bootstrap-dark.css +0 -8
  20. package/styles/bootstrap.css +0 -8
  21. package/styles/bootstrap4.css +0 -8
  22. package/styles/bootstrap5-dark.css +0 -8
  23. package/styles/bootstrap5.css +0 -8
  24. package/styles/fabric-dark.css +0 -8
  25. package/styles/fabric.css +0 -8
  26. package/styles/fluent-dark.css +1 -5
  27. package/styles/fluent.css +1 -5
  28. package/styles/highcontrast-light.css +0 -8
  29. package/styles/highcontrast.css +0 -8
  30. package/styles/material-dark.css +0 -8
  31. package/styles/material.css +0 -8
  32. package/styles/tailwind-dark.css +0 -8
  33. package/styles/tailwind.css +0 -8
  34. package/styles/treegrid/_bootstrap-dark-definition.scss +0 -2
  35. package/styles/treegrid/_bootstrap-definition.scss +0 -2
  36. package/styles/treegrid/_bootstrap4-definition.scss +0 -2
  37. package/styles/treegrid/_bootstrap5-definition.scss +0 -2
  38. package/styles/treegrid/_fabric-dark-definition.scss +0 -2
  39. package/styles/treegrid/_fabric-definition.scss +0 -2
  40. package/styles/treegrid/_fluent-definition.scss +0 -1
  41. package/styles/treegrid/_highcontrast-definition.scss +0 -2
  42. package/styles/treegrid/_highcontrast-light-definition.scss +0 -2
  43. package/styles/treegrid/_layout.scss +4 -6
  44. package/styles/treegrid/_material-dark-definition.scss +0 -2
  45. package/styles/treegrid/_material-definition.scss +0 -2
  46. package/styles/treegrid/_tailwind-definition.scss +0 -2
  47. package/styles/treegrid/bootstrap-dark.css +0 -8
  48. package/styles/treegrid/bootstrap.css +0 -8
  49. package/styles/treegrid/bootstrap4.css +0 -8
  50. package/styles/treegrid/bootstrap5-dark.css +0 -8
  51. package/styles/treegrid/bootstrap5.css +0 -8
  52. package/styles/treegrid/fabric-dark.css +0 -8
  53. package/styles/treegrid/fabric.css +0 -8
  54. package/styles/treegrid/fluent-dark.css +1 -5
  55. package/styles/treegrid/fluent.css +1 -5
  56. package/styles/treegrid/highcontrast-light.css +0 -8
  57. package/styles/treegrid/highcontrast.css +0 -8
  58. package/styles/treegrid/material-dark.css +0 -8
  59. package/styles/treegrid/material.css +0 -8
  60. package/styles/treegrid/tailwind-dark.css +0 -8
  61. package/styles/treegrid/tailwind.css +0 -8
@@ -1,5 +1,5 @@
1
1
  import { Browser, ChildProperty, Collection, Complex, Component, Event, EventHandler, Internationalization, KeyboardEvents, L10n, NotifyPropertyChanges, Property, addClass, classList, closest, compile, createElement, debounce, extend, getEnumValue, getValue, isNullOrUndefined, merge, remove, removeClass, select, setStyleAttribute, setValue } from '@syncfusion/ej2-base';
2
- import { Aggregate, Cell, CellRenderer, CellType, Clipboard, ColumnChooser, ColumnMenu, CommandColumn, ContextMenu, DetailRow, Edit, ExcelExport, Filter, Freeze, Grid, InfiniteScroll, InterSectionObserver, Logger, Page, PdfExport, Print, RenderType, Reorder, Resize, RowDD, RowDropSettings, RowRenderer, Scroll, Sort, Toolbar, VirtualContentRenderer, VirtualHeaderRenderer, VirtualRowModelGenerator, VirtualScroll, appendChildren, calculateAggregate, detailLists, extend as extend$1, getActualProperties, getObject, getUid, iterateArrayOrObject, parentsUntil, resetRowIndex, templateCompiler } from '@syncfusion/ej2-grids';
2
+ import { Aggregate, Cell, CellType, Clipboard, ColumnChooser, ColumnMenu, CommandColumn, ContextMenu, DetailRow, Edit, ExcelExport, Filter, Freeze, Grid, InfiniteScroll, InterSectionObserver, Logger, Page, PdfExport, Print, RenderType, Reorder, Resize, RowDD, RowDropSettings, RowRenderer, Scroll, Sort, Toolbar, VirtualContentRenderer, VirtualHeaderRenderer, VirtualRowModelGenerator, VirtualScroll, appendChildren, calculateAggregate, detailLists, extend as extend$1, getActualProperties, getObject, getUid, iterateArrayOrObject, parentsUntil, resetRowIndex, templateCompiler } from '@syncfusion/ej2-grids';
3
3
  import { createCheckBox } from '@syncfusion/ej2-buttons';
4
4
  import { CacheAdaptor, DataManager, DataUtil, Deferred, JsonAdaptor, ODataAdaptor, Predicate, Query, RemoteSaveAdaptor, UrlAdaptor, WebApiAdaptor, WebMethodAdaptor } from '@syncfusion/ej2-data';
5
5
  import { createSpinner, hideSpinner, showSpinner } from '@syncfusion/ej2-popups';
@@ -2891,17 +2891,12 @@ var RowDD$1 = /** @__PURE__ @class */ (function () {
2891
2891
  }
2892
2892
  };
2893
2893
  RowDD$$1.prototype.orderToIndex = function (currentData) {
2894
- var _loop_1 = function (i) {
2894
+ for (var i = 0; i < currentData.length; i++) {
2895
2895
  currentData[i].index = i;
2896
2896
  if (!isNullOrUndefined(currentData[i].parentItem)) {
2897
- var updatedParent = currentData.filter(function (data) {
2898
- return data.uniqueID === currentData[i].parentUniqueID;
2899
- })[0];
2897
+ var updatedParent = getValue('uniqueIDCollection.' + currentData[i].parentUniqueID, this.parent);
2900
2898
  currentData[i].parentItem.index = updatedParent.index;
2901
2899
  }
2902
- };
2903
- for (var i = 0; i < currentData.length; i++) {
2904
- _loop_1(i);
2905
2900
  }
2906
2901
  return currentData;
2907
2902
  };
@@ -3551,7 +3546,7 @@ var RowDD$1 = /** @__PURE__ @class */ (function () {
3551
3546
  if (!isNullOrUndefined(this.parent.idMapping)) {
3552
3547
  dragRecords.reverse();
3553
3548
  }
3554
- var _loop_2 = function (i) {
3549
+ var _loop_1 = function (i) {
3555
3550
  draggedRecord_2 = dragRecords[i];
3556
3551
  this_1.draggedRecord = draggedRecord_2;
3557
3552
  if (this_1.dropPosition !== 'Invalid') {
@@ -3638,7 +3633,7 @@ var RowDD$1 = /** @__PURE__ @class */ (function () {
3638
3633
  };
3639
3634
  var this_1 = this;
3640
3635
  for (var i = 0; i < dragLength; i++) {
3641
- _loop_2(i);
3636
+ _loop_1(i);
3642
3637
  }
3643
3638
  }
3644
3639
  };
@@ -6262,10 +6257,13 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
6262
6257
  rowData.parentUniqueID = record.parentUniqueID;
6263
6258
  rowData.expanded = record.expanded;
6264
6259
  this.grid.setRowData(key, rowData);
6265
- var table = this.getContentTable();
6266
- var sHeight = table.scrollHeight;
6267
- var clientHeight = this.getContent().clientHeight;
6268
- this.lastRowBorder(this.getRows()[record.index], sHeight <= clientHeight);
6260
+ var visibleRecords = this.getVisibleRecords();
6261
+ if (visibleRecords.length > 0 && key === (visibleRecords[visibleRecords.length - 1])[primaryKey]) {
6262
+ var table = this.getContentTable();
6263
+ var sHeight = table.scrollHeight;
6264
+ var clientHeight = this.getContent().clientHeight;
6265
+ this.lastRowBorder(this.getRows()[currentRecords.indexOf(record)], sHeight <= clientHeight);
6266
+ }
6269
6267
  };
6270
6268
  /**
6271
6269
  * Navigates to the specified target page.
@@ -6475,32 +6473,6 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
6475
6473
  this[merge$$1] = undefined; // Workaround for blazor updateModel
6476
6474
  return this.columnModel;
6477
6475
  };
6478
- /**
6479
- * @param {string} columnUid - Defines column uid
6480
- * @returns {void}
6481
- * @hidden
6482
- */
6483
- TreeGrid.prototype.refreshReactColumnTemplateByUid = function (columnUid) {
6484
- var _this = this;
6485
- if (this.isReact) {
6486
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
6487
- this.clearTemplate(['columnTemplate'], undefined, function () {
6488
- var cells = 'cells';
6489
- var rowIdx = 'index';
6490
- var rowsObj = _this.grid.getRowsObject();
6491
- var indent = _this.grid.getIndentCount();
6492
- var cellIndex = _this.grid.getNormalizedColumnIndex(columnUid);
6493
- for (var j = 0; j < rowsObj.length; j++) {
6494
- if (rowsObj[j].isDataRow && !isNullOrUndefined(rowsObj[j].index)) {
6495
- var cell = rowsObj[j][cells][cellIndex];
6496
- var cellRenderer = new CellRenderer(_this.grid, _this.grid.serviceLocator);
6497
- var td = _this.getCellFromIndex(rowsObj[j].index, cellIndex - indent);
6498
- cellRenderer.refreshTD(td, cell, rowsObj[j].data, { index: rowsObj[j][rowIdx] });
6499
- }
6500
- }
6501
- });
6502
- }
6503
- };
6504
6476
  /**
6505
6477
  * Gets the content div of the TreeGrid.
6506
6478
  *
@@ -6646,8 +6618,14 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
6646
6618
  this.uniqueIDCollection = {};
6647
6619
  this.convertTreeData(this.dataSource);
6648
6620
  if (!isCountRequired(this)) {
6649
- this.grid.dataSource = !(this.dataSource instanceof DataManager) ? this.flatData :
6650
- new DataManager(this.dataSource.dataSource, this.dataSource.defaultQuery, this.dataSource.adaptor);
6621
+ if (!(this.dataSource instanceof DataManager)) {
6622
+ this.grid.dataSource = this.flatData;
6623
+ }
6624
+ else {
6625
+ this.grid.setProperties({
6626
+ dataSource: new DataManager(this.dataSource.dataSource, this.dataSource.defaultQuery, this.dataSource.adaptor)
6627
+ }, true);
6628
+ }
6651
6629
  }
6652
6630
  this.grid.refresh();
6653
6631
  };
@@ -6791,6 +6769,9 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
6791
6769
  if (!(isRemoteData(_this) && !isOffline(_this)) && (!isCountRequired(_this) || !isNullOrUndefined(record[children]))) {
6792
6770
  var collapseArgs = { data: record, row: row };
6793
6771
  _this.setHeightForFrozenContent();
6772
+ if (!isNullOrUndefined(_this.expandStateMapping)) {
6773
+ _this.updateExpandStateMapping(collapseArgs.data, true);
6774
+ }
6794
6775
  _this.trigger(expanded, collapseArgs);
6795
6776
  }
6796
6777
  }
@@ -6853,6 +6834,9 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
6853
6834
  var collapseArgs = { data: record, row: row };
6854
6835
  if (!isRemoteData(_this)) {
6855
6836
  _this.setHeightForFrozenContent();
6837
+ if (!isNullOrUndefined(_this.expandStateMapping)) {
6838
+ _this.updateExpandStateMapping(collapseArgs.data, false);
6839
+ }
6856
6840
  _this.trigger(collapsed, collapseArgs);
6857
6841
  if (_this.enableInfiniteScrolling) {
6858
6842
  var scrollHeight = _this.grid.getContent().firstElementChild.scrollHeight;
@@ -6865,6 +6849,19 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
6865
6849
  }
6866
6850
  });
6867
6851
  };
6852
+ TreeGrid.prototype.updateExpandStateMapping = function (record, state) {
6853
+ var totalRecords = record;
6854
+ if (totalRecords.length) {
6855
+ for (var i = 0; i < totalRecords.length; i++) {
6856
+ totalRecords[i][this.expandStateMapping] = state;
6857
+ editAction({ value: totalRecords[i], action: 'edit' }, this, this.isSelfReference, totalRecords[i].index, this.grid.selectedRowIndex, this.expandStateMapping);
6858
+ }
6859
+ }
6860
+ else {
6861
+ record[this.expandStateMapping] = state;
6862
+ editAction({ value: record, action: 'edit' }, this, this.isSelfReference, record.index, this.grid.selectedRowIndex, this.expandStateMapping);
6863
+ }
6864
+ };
6868
6865
  /**
6869
6866
  * Expands the records at specific hierarchical level
6870
6867
  *
@@ -8577,6 +8574,9 @@ var Filter$1 = /** @__PURE__ @class */ (function () {
8577
8574
  }
8578
8575
  }
8579
8576
  else {
8577
+ if (parent['expanded'] === false && this.parent.getVisibleRecords().indexOf(record) === -1 && isNullOrUndefined(this.parent['dataResults']['action'])) {
8578
+ this.parent.expandRow(this.parent.getRows()[parent['index']], parent);
8579
+ }
8580
8580
  this.addParentRecord(parent);
8581
8581
  }
8582
8582
  }
@@ -10087,9 +10087,17 @@ var BatchEdit = /** @__PURE__ @class */ (function () {
10087
10087
  this.parent.editModule[isTabLastRow] = false;
10088
10088
  return;
10089
10089
  }
10090
- this.selectedIndex = this.parent.grid.selectedRowIndex;
10091
- this.addRowIndex = this.parent.grid.selectedRowIndex > -1 ? this.parent.grid.selectedRowIndex : 0;
10092
- this.addRowRecord = this.parent.getSelectedRecords()[0];
10090
+ if (this.parent.editModule['isAddedRowByMethod'] && !isNullOrUndefined(this.parent.editModule['addRowIndex']) && this.parent.grid.selectedRowIndex === -1) {
10091
+ this.selectedIndex = this.parent.editModule['selectedIndex'];
10092
+ this.addRowIndex = this.parent.editModule['addRowIndex'];
10093
+ this.addRowRecord = this.parent.getCurrentViewRecords()[this.selectedIndex];
10094
+ }
10095
+ else {
10096
+ this.selectedIndex = this.parent.grid.selectedRowIndex;
10097
+ this.addRowIndex = this.parent.grid.selectedRowIndex > -1 ? this.parent.grid.selectedRowIndex : 0;
10098
+ this.parent.editModule['addRowIndex'] = this.parent.grid.selectedRowIndex > -1 ? this.parent.grid.selectedRowIndex : 0;
10099
+ this.addRowRecord = this.parent.getSelectedRecords()[0];
10100
+ }
10093
10101
  };
10094
10102
  BatchEdit.prototype.batchAdd = function (e) {
10095
10103
  if (this.parent.editSettings.newRowPosition !== 'Bottom') {
@@ -10101,6 +10109,9 @@ var BatchEdit = /** @__PURE__ @class */ (function () {
10101
10109
  this.batchRecords = extendArray(this.parent.grid.getCurrentViewRecords());
10102
10110
  this.currentViewRecords = extendArray(this.parent.grid.getCurrentViewRecords());
10103
10111
  }
10112
+ if (this.parent.editModule['isAddedRowByMethod'] && !isNullOrUndefined(this.parent.editModule['addRowIndex'])) {
10113
+ classList(this.parent.grid.getDataRows()[0], ['e-batchrow'], []);
10114
+ }
10104
10115
  if (this.parent.editSettings.newRowPosition !== 'Top') {
10105
10116
  var records = this.parent.grid.getCurrentViewRecords();
10106
10117
  if (this.parent.editSettings.mode === 'Batch' && (this.parent.getBatchChanges()[this.addedRecords].length > 1
@@ -10324,6 +10335,10 @@ var BatchEdit = /** @__PURE__ @class */ (function () {
10324
10335
  }
10325
10336
  if (this.parent.editSettings.newRowPosition !== 'Bottom' && !Object.hasOwnProperty.call(args, 'updatedRecords')) {
10326
10337
  data.splice(data.length - addRecords.length, addRecords.length);
10338
+ if (this.parent.editModule['isAddedRowByMethod'] && addRecords.length && !isNullOrUndefined(this.parent.editModule['addRowIndex'])) {
10339
+ var index_1 = parseInt(this.parent.getContentTable().getElementsByClassName('e-insertedrow')[0].ariaRowIndex);
10340
+ data.splice(index_1, 0, addRecords[0]);
10341
+ }
10327
10342
  if (!this.parent.allowPaging && data.length !== currentViewRecords.length) {
10328
10343
  if (currentViewRecords.length > addRecords.length) {
10329
10344
  currentViewRecords.splice(currentViewRecords.length - addRecords.length, addRecords.length);
@@ -10375,7 +10390,8 @@ var BatchEdit = /** @__PURE__ @class */ (function () {
10375
10390
  }
10376
10391
  editAction({ value: addRecords[i], action: 'add' }, this.parent, this.isSelfReference, addRowIndex, selectedIndex, columnName, addRowRecord);
10377
10392
  selectedIndex = null;
10378
- if (this.parent.editSettings.newRowPosition === 'Child' && !isNullOrUndefined(addRecords[i][parentItem])) {
10393
+ if (this.parent.editSettings.newRowPosition === 'Child' && !isNullOrUndefined(addRecords[i][parentItem]) &&
10394
+ (isNullOrUndefined(this.parent.editModule['addRowIndex']) || this.isSelfReference)) {
10379
10395
  var indexValue = currentViewRecords.map(function (e) { return e[primarykey_1]; })
10380
10396
  .indexOf(addRecords[i][parentItem][primarykey_1]);
10381
10397
  var children = currentViewRecords[indexValue][childRecords];
@@ -11121,6 +11137,21 @@ var Edit$1 = /** @__PURE__ @class */ (function () {
11121
11137
  focussedElement.focus();
11122
11138
  }
11123
11139
  }
11140
+ if (this.parent.editSettings.mode === 'Batch' && !isNullOrUndefined(this.addRowIndex) && this.addRowIndex !== -1) {
11141
+ index = this.batchEditModule.getAddRowIndex();
11142
+ this.selectedIndex = this.batchEditModule.getSelectedIndex();
11143
+ if (this.parent.editModule['isAddedRowByMethod']) {
11144
+ var args = {
11145
+ action: "add",
11146
+ data: this.parent.getBatchChanges()['addedRecords'][0],
11147
+ index: index,
11148
+ seletedRow: 0
11149
+ };
11150
+ this.parent.editModule.beginAddEdit(args);
11151
+ this.parent.editModule.batchEditModule['batchAddRowRecord'].push(this.parent.editModule.batchEditModule['addRowRecord']);
11152
+ this.parent.editModule.batchEditModule['batchAddedRecords'].push(args['data']);
11153
+ }
11154
+ }
11124
11155
  };
11125
11156
  // private beforeDataBound(args: BeforeDataBoundArgs): void {
11126
11157
  // if (this.parent.grid.isEdit && this.parent.dataSource instanceof DataManager &&