@syncfusion/ej2-treegrid 19.4.56 → 20.1.51

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 (80) hide show
  1. package/CHANGELOG.md +11 -57
  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 +446 -156
  5. package/dist/es6/ej2-treegrid.es2015.js.map +1 -1
  6. package/dist/es6/ej2-treegrid.es5.js +451 -164
  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 +9 -9
  12. package/src/treegrid/actions/batch-edit.js +21 -4
  13. package/src/treegrid/actions/crud-actions.js +9 -2
  14. package/src/treegrid/actions/edit.js +16 -1
  15. package/src/treegrid/actions/filter.js +3 -0
  16. package/src/treegrid/actions/rowdragdrop.d.ts +15 -0
  17. package/src/treegrid/actions/rowdragdrop.js +181 -30
  18. package/src/treegrid/actions/toolbar.d.ts +0 -1
  19. package/src/treegrid/actions/toolbar.js +50 -79
  20. package/src/treegrid/actions/virtual-scroll.js +1 -1
  21. package/src/treegrid/base/treegrid-model.d.ts +1 -1
  22. package/src/treegrid/base/treegrid.d.ts +33 -6
  23. package/src/treegrid/base/treegrid.js +136 -39
  24. package/src/treegrid/models/column.d.ts +6 -6
  25. package/src/treegrid/models/column.js +7 -7
  26. package/src/treegrid/models/rowdrop-settings.d.ts +9 -1
  27. package/src/treegrid/renderer/render.d.ts +6 -0
  28. package/src/treegrid/renderer/render.js +27 -1
  29. package/src/treegrid/renderer/virtual-tree-content-render.js +1 -1
  30. package/styles/bootstrap-dark.css +27 -12
  31. package/styles/bootstrap.css +27 -12
  32. package/styles/bootstrap4.css +21 -12
  33. package/styles/bootstrap5-dark.css +43 -27
  34. package/styles/bootstrap5.css +43 -27
  35. package/styles/fabric-dark.css +27 -12
  36. package/styles/fabric.css +27 -12
  37. package/styles/fluent-dark.css +556 -0
  38. package/styles/fluent-dark.scss +1 -0
  39. package/styles/fluent.css +556 -0
  40. package/styles/fluent.scss +1 -0
  41. package/styles/highcontrast-light.css +27 -12
  42. package/styles/highcontrast.css +27 -12
  43. package/styles/material-dark.css +19 -10
  44. package/styles/material.css +19 -10
  45. package/styles/tailwind-dark.css +41 -88
  46. package/styles/tailwind.css +26 -73
  47. package/styles/treegrid/_bootstrap-dark-definition.scss +0 -2
  48. package/styles/treegrid/_bootstrap-definition.scss +0 -2
  49. package/styles/treegrid/_bootstrap4-definition.scss +0 -2
  50. package/styles/treegrid/_bootstrap5-definition.scss +3 -5
  51. package/styles/treegrid/_fabric-dark-definition.scss +0 -2
  52. package/styles/treegrid/_fabric-definition.scss +0 -2
  53. package/styles/treegrid/_fluent-dark-definition.scss +1 -0
  54. package/styles/treegrid/_fluent-definition.scss +3 -4
  55. package/styles/treegrid/_highcontrast-definition.scss +0 -2
  56. package/styles/treegrid/_highcontrast-light-definition.scss +0 -2
  57. package/styles/treegrid/_layout.scss +66 -13
  58. package/styles/treegrid/_material-dark-definition.scss +0 -2
  59. package/styles/treegrid/_material-definition.scss +0 -2
  60. package/styles/treegrid/_tailwind-definition.scss +3 -5
  61. package/styles/treegrid/bootstrap-dark.css +27 -12
  62. package/styles/treegrid/bootstrap.css +27 -12
  63. package/styles/treegrid/bootstrap4.css +21 -12
  64. package/styles/treegrid/bootstrap5-dark.css +43 -27
  65. package/styles/treegrid/bootstrap5.css +43 -27
  66. package/styles/treegrid/fabric-dark.css +27 -12
  67. package/styles/treegrid/fabric.css +27 -12
  68. package/styles/treegrid/fluent-dark.css +556 -0
  69. package/styles/treegrid/fluent-dark.scss +18 -0
  70. package/styles/treegrid/fluent.css +556 -0
  71. package/styles/treegrid/fluent.scss +18 -0
  72. package/styles/treegrid/highcontrast-light.css +27 -12
  73. package/styles/treegrid/highcontrast.css +27 -12
  74. package/styles/treegrid/icons/_fluent-dark.scss +1 -0
  75. package/styles/treegrid/icons/_tailwind-dark.scss +5 -5
  76. package/styles/treegrid/icons/_tailwind.scss +5 -5
  77. package/styles/treegrid/material-dark.css +19 -10
  78. package/styles/treegrid/material.css +19 -10
  79. package/styles/treegrid/tailwind-dark.css +41 -88
  80. package/styles/treegrid/tailwind.css +26 -73
@@ -1,4 +1,4 @@
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, setValue } from '@syncfusion/ej2-base';
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
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';
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';
@@ -77,12 +77,12 @@ var Column = /** @__PURE__ @class */ (function () {
77
77
  merge(this, options);
78
78
  }
79
79
  /**
80
- * Update the State changes reflected for TreeGrid columndirective in react platform.
81
- *
82
- * @param {Column} column - specifies the column
83
- * @returns {void}
84
- * @hidden
85
- */
80
+ * Update the State changes reflected for TreeGrid columndirective in react platform.
81
+ *
82
+ * @param {Column} column - specifies the column
83
+ * @returns {void}
84
+ * @hidden
85
+ */
86
86
  Column.prototype.setProperties = function (column) {
87
87
  //Angular two way binding
88
88
  var keys = Object.keys(column);
@@ -91,7 +91,7 @@ var Column = /** @__PURE__ @class */ (function () {
91
91
  //Refresh the react columnTemplates on state change
92
92
  if (this.parent && this.parent['isReact'] && keys[i] === 'template') {
93
93
  var refreshReactColumnTemplateByUid = 'refreshReactColumnTemplateByUid';
94
- this.parent.clipboardModule['treeGridParent'][refreshReactColumnTemplateByUid](this.uid);
94
+ this.parent.clipboardModule['treeGridParent'].renderModule[refreshReactColumnTemplateByUid](this.uid);
95
95
  }
96
96
  }
97
97
  };
@@ -1774,6 +1774,32 @@ var Render = /** @__PURE__ @class */ (function () {
1774
1774
  args.cell.innerHTML = '';
1775
1775
  }
1776
1776
  };
1777
+ /**
1778
+ * @param {string} columnUid - Defines column uid
1779
+ * @returns {void}
1780
+ * @hidden
1781
+ */
1782
+ Render.prototype.refreshReactColumnTemplateByUid = function (columnUid) {
1783
+ var _this = this;
1784
+ if (this.parent.isReact) {
1785
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1786
+ this.parent.clearTemplate(['columnTemplate'], undefined, function () {
1787
+ var cells = 'cells';
1788
+ var rowIdx = 'index';
1789
+ var rowsObj = _this.parent.grid.getRowsObject();
1790
+ var indent = _this.parent.grid.getIndentCount();
1791
+ var cellIndex = _this.parent.grid.getNormalizedColumnIndex(columnUid);
1792
+ for (var j = 0; j < rowsObj.length; j++) {
1793
+ if (rowsObj[j].isDataRow && !isNullOrUndefined(rowsObj[j].index)) {
1794
+ var cell = rowsObj[j][cells][cellIndex];
1795
+ var cellRenderer = new CellRenderer(_this.parent.grid, _this.parent.grid.serviceLocator);
1796
+ var td = _this.parent.getCellFromIndex(rowsObj[j].index, cellIndex - indent);
1797
+ cellRenderer.refreshTD(td, cell, rowsObj[j].data, { index: rowsObj[j][rowIdx] });
1798
+ }
1799
+ }
1800
+ });
1801
+ }
1802
+ };
1777
1803
  Render.prototype.columnTemplateResult = function (args) {
1778
1804
  this.templateResult = args.template;
1779
1805
  };
@@ -2791,7 +2817,9 @@ function editAction(details, control, isSelfReference, addRowIndex, selectedInde
2791
2817
  var childRecords = parentData ? parentData[control.childMapping] : [];
2792
2818
  for (var p = childRecords.length - 1; p >= 0; p--) {
2793
2819
  if (childRecords[p][control.idMapping] === currentData_1[control.idMapping]) {
2794
- parentData['childRecords'].splice(p, 1);
2820
+ if (!control.enableImmutableMode) {
2821
+ parentData['childRecords'].splice(p, 1);
2822
+ }
2795
2823
  childRecords.splice(p, 1);
2796
2824
  if (!childRecords.length) {
2797
2825
  parentData.hasChildRecords = false;
@@ -3089,7 +3117,12 @@ function updateParentRow(key, record, action, control, isSelfReference, child) {
3089
3117
  control.grid.setRowData(key, record);
3090
3118
  var row = control.getRowByIndex(index_1);
3091
3119
  if (control.editSettings.mode === 'Batch') {
3092
- row = control.getRows()[control.grid.getRowIndexByPrimaryKey(record[key])];
3120
+ if (action === 'add') {
3121
+ row = control.getRows()[control.grid.getCurrentViewRecords().indexOf(record)];
3122
+ }
3123
+ else {
3124
+ row = control.getRows()[control.grid.getRowIndexByPrimaryKey(record[key])];
3125
+ }
3093
3126
  }
3094
3127
  var movableRow = void 0;
3095
3128
  if (control.frozenRows || control.getFrozenColumns()) {
@@ -3193,6 +3226,8 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
3193
3226
  _this.changedRecords = 'changedRecords';
3194
3227
  _this.deletedRecords = 'deletedRecords';
3195
3228
  _this.addedRecords = 'addedRecords';
3229
+ _this.indentOutdentAction = 'indentOutdentAction';
3230
+ _this.modifiedRecords = [];
3196
3231
  _this.objectEqualityChecker = function (old, current) {
3197
3232
  if (old) {
3198
3233
  var keys = Object.keys(old);
@@ -3601,7 +3636,14 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
3601
3636
  return modules;
3602
3637
  };
3603
3638
  TreeGrid.prototype.extendRequiredModules = function (modules) {
3604
- if (this.allowRowDragAndDrop) {
3639
+ var IsRowDDInjected = this.injectedModules.filter(function (e) {
3640
+ return e.name === 'RowDD';
3641
+ });
3642
+ if (this.allowRowDragAndDrop || IsRowDDInjected.length) {
3643
+ if ((!isNullOrUndefined(this.toolbar) && (this.toolbar['includes']('Indent') ||
3644
+ this.toolbar['includes']('Outdent')))) {
3645
+ this.isIndentEnabled = true;
3646
+ }
3605
3647
  modules.push({
3606
3648
  member: 'rowDragAndDrop',
3607
3649
  args: [this]
@@ -3727,7 +3769,12 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
3727
3769
  }
3728
3770
  return modules;
3729
3771
  };
3772
+ var root = 'root';
3773
+ this.grid[root] = this[root] ? this[root] : this;
3730
3774
  this.grid.appendTo(gridContainer);
3775
+ if (this.isIndentEnabled) {
3776
+ this.refreshToolbarItems();
3777
+ }
3731
3778
  this.wireEvents();
3732
3779
  this.renderComplete();
3733
3780
  var destroyTemplate = 'destroyTemplate';
@@ -3741,6 +3788,15 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
3741
3788
  }
3742
3789
  };
3743
3790
  };
3791
+ TreeGrid.prototype.refreshToolbarItems = function () {
3792
+ var toolbarElement = this.toolbarModule.getToolbar();
3793
+ var indentID = this.element.id + '_gridcontrol_indent';
3794
+ var outdentID = this.element.id + '_gridcontrol_outdent';
3795
+ var indentElement = toolbarElement.querySelector('#' + indentID).parentElement;
3796
+ var outdentElement = toolbarElement.querySelector('#' + outdentID).parentElement;
3797
+ indentElement.classList.add('e-hidden');
3798
+ outdentElement.classList.add('e-hidden');
3799
+ };
3744
3800
  TreeGrid.prototype.afterGridRender = function () {
3745
3801
  if (!isNullOrUndefined(this.grid.clipboardModule)) {
3746
3802
  this.grid.clipboardModule.destroy();
@@ -4220,14 +4276,24 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
4220
4276
  }
4221
4277
  if (_this.action === 'indenting' || _this.action === 'outdenting') {
4222
4278
  _this.action = _this.action === 'indenting' ? 'indented' : 'outdented';
4279
+ var selectedItem_1 = [_this.selectedRecords];
4223
4280
  var actionArgs = {
4281
+ data: selectedItem_1,
4282
+ dropIndex: _this.dropIndex,
4283
+ dropPosition: _this.dropPosition,
4284
+ modifiedRecords: _this.modifiedRecords,
4224
4285
  requestType: _this.action,
4225
- data: _this.selectedRecords,
4226
4286
  row: _this.selectedRows
4227
4287
  };
4228
4288
  _this.trigger(actionComplete, actionArgs);
4289
+ var currentPageItem = _this.getCurrentViewRecords().filter(function (e) {
4290
+ return e.uniqueID === selectedItem_1[0].uniqueID;
4291
+ });
4292
+ if (!currentPageItem.length) {
4293
+ _this.refreshToolbarItems();
4294
+ }
4229
4295
  _this.action = '';
4230
- _this.selectedRecords = _this.selectedRows = [];
4296
+ _this.selectedRecords = _this.selectedRows = _this.modifiedRecords = [];
4231
4297
  }
4232
4298
  else {
4233
4299
  _this.trigger(actionComplete, args);
@@ -4431,7 +4497,7 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
4431
4497
  case ToolbarItem.RowIndent:
4432
4498
  tooltipText = this.l10n.getConstant('RowIndent');
4433
4499
  items.push({
4434
- text: tooltipText, tooltipText: tooltipText, disabled: true,
4500
+ text: tooltipText, tooltipText: tooltipText,
4435
4501
  prefixIcon: 'e-indent', id: this.element.id + '_gridcontrol_indent'
4436
4502
  });
4437
4503
  break;
@@ -4439,7 +4505,7 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
4439
4505
  case ToolbarItem.RowOutdent:
4440
4506
  tooltipText = this.l10n.getConstant('RowOutdent');
4441
4507
  items.push({
4442
- text: tooltipText, tooltipText: tooltipText, disabled: true,
4508
+ text: tooltipText, tooltipText: tooltipText,
4443
4509
  prefixIcon: 'e-outdent', id: this.element.id + '_gridcontrol_outdent'
4444
4510
  });
4445
4511
  break;
@@ -4492,6 +4558,15 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
4492
4558
  this.columnModel.push(new Column(treeGridColumn));
4493
4559
  }
4494
4560
  gridColumnCollection.push(gridColumn);
4561
+ if (!isNullOrUndefined(this.columnModel[this.treeColumnIndex]) && this.enableRtl) {
4562
+ if (gridColumn.field === this.columnModel[this.treeColumnIndex].field) {
4563
+ if (isNullOrUndefined(this.treeColumnTextAlign)) {
4564
+ this.treeColumnTextAlign = this.columnModel[this.treeColumnIndex].textAlign;
4565
+ this.treeColumnField = this.columnModel[this.treeColumnIndex].field;
4566
+ }
4567
+ gridColumn.textAlign = 'Right';
4568
+ }
4569
+ }
4495
4570
  }
4496
4571
  return gridColumnCollection;
4497
4572
  };
@@ -4664,6 +4739,9 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
4664
4739
  this.grid.allowPdfExport = this.allowPdfExport;
4665
4740
  break;
4666
4741
  case 'enableRtl':
4742
+ if (!isNullOrUndefined(this.treeColumnField)) {
4743
+ this.updateTreeColumnTextAlign();
4744
+ }
4667
4745
  this.grid.enableRtl = this.enableRtl;
4668
4746
  break;
4669
4747
  case 'allowReordering':
@@ -4704,6 +4782,11 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
4704
4782
  }
4705
4783
  }
4706
4784
  };
4785
+ TreeGrid.prototype.updateTreeColumnTextAlign = function () {
4786
+ var gridColumn = this.grid.getColumnByField(this.treeColumnField);
4787
+ gridColumn.textAlign = this.enableRtl ? 'Right' : this.treeColumnTextAlign;
4788
+ this.grid.refreshColumns();
4789
+ };
4707
4790
  /**
4708
4791
  * Destroys the component (detaches/removes all event handlers, attributes, classes, and empties the component element).
4709
4792
  *
@@ -5041,10 +5124,13 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
5041
5124
  rowData.parentUniqueID = record.parentUniqueID;
5042
5125
  rowData.expanded = record.expanded;
5043
5126
  this.grid.setRowData(key, rowData);
5044
- var table = this.getContentTable();
5045
- var sHeight = table.scrollHeight;
5046
- var clientHeight = this.getContent().clientHeight;
5047
- this.lastRowBorder(this.getRows()[record.index], sHeight <= clientHeight);
5127
+ var visibleRecords = this.getVisibleRecords();
5128
+ if (visibleRecords.length > 0 && key === (visibleRecords[visibleRecords.length - 1])[primaryKey]) {
5129
+ var table = this.getContentTable();
5130
+ var sHeight = table.scrollHeight;
5131
+ var clientHeight = this.getContent().clientHeight;
5132
+ this.lastRowBorder(this.getRows()[currentRecords.indexOf(record)], sHeight <= clientHeight);
5133
+ }
5048
5134
  };
5049
5135
  /**
5050
5136
  * Navigates to the specified target page.
@@ -5254,32 +5340,6 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
5254
5340
  this[merge$$1] = undefined; // Workaround for blazor updateModel
5255
5341
  return this.columnModel;
5256
5342
  };
5257
- /**
5258
- * @param {string} columnUid - Defines column uid
5259
- * @returns {void}
5260
- * @hidden
5261
- */
5262
- TreeGrid.prototype.refreshReactColumnTemplateByUid = function (columnUid) {
5263
- var _this = this;
5264
- if (this.isReact) {
5265
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
5266
- this.clearTemplate(['columnTemplate'], undefined, function () {
5267
- var cells = 'cells';
5268
- var rowIdx = 'index';
5269
- var rowsObj = _this.grid.getRowsObject();
5270
- var indent = _this.grid.getIndentCount();
5271
- var cellIndex = _this.grid.getNormalizedColumnIndex(columnUid);
5272
- for (var j = 0; j < rowsObj.length; j++) {
5273
- if (rowsObj[j].isDataRow && !isNullOrUndefined(rowsObj[j].index)) {
5274
- var cell = rowsObj[j][cells][cellIndex];
5275
- var cellRenderer = new CellRenderer(_this.grid, _this.grid.serviceLocator);
5276
- var td = _this.getCellFromIndex(rowsObj[j].index, cellIndex - indent);
5277
- cellRenderer.refreshTD(td, cell, rowsObj[j].data, { index: rowsObj[j][rowIdx] });
5278
- }
5279
- }
5280
- });
5281
- }
5282
- };
5283
5343
  /**
5284
5344
  * Gets the content div of the TreeGrid.
5285
5345
  *
@@ -5425,8 +5485,14 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
5425
5485
  this.uniqueIDCollection = {};
5426
5486
  this.convertTreeData(this.dataSource);
5427
5487
  if (!isCountRequired(this)) {
5428
- this.grid.dataSource = !(this.dataSource instanceof DataManager) ? this.flatData :
5429
- new DataManager(this.dataSource.dataSource, this.dataSource.defaultQuery, this.dataSource.adaptor);
5488
+ if (!(this.dataSource instanceof DataManager)) {
5489
+ this.grid.dataSource = this.flatData;
5490
+ }
5491
+ else {
5492
+ this.grid.setProperties({
5493
+ dataSource: new DataManager(this.dataSource.dataSource, this.dataSource.defaultQuery, this.dataSource.adaptor)
5494
+ }, true);
5495
+ }
5430
5496
  }
5431
5497
  this.grid.refresh();
5432
5498
  };
@@ -5570,6 +5636,9 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
5570
5636
  if (!(isRemoteData(_this) && !isOffline(_this)) && (!isCountRequired(_this) || !isNullOrUndefined(record[children]))) {
5571
5637
  var collapseArgs = { data: record, row: row };
5572
5638
  _this.setHeightForFrozenContent();
5639
+ if (!isNullOrUndefined(_this.expandStateMapping)) {
5640
+ _this.updateExpandStateMapping(collapseArgs.data, true);
5641
+ }
5573
5642
  _this.trigger(expanded, collapseArgs);
5574
5643
  }
5575
5644
  }
@@ -5632,6 +5701,9 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
5632
5701
  var collapseArgs = { data: record, row: row };
5633
5702
  if (!isRemoteData(_this)) {
5634
5703
  _this.setHeightForFrozenContent();
5704
+ if (!isNullOrUndefined(_this.expandStateMapping)) {
5705
+ _this.updateExpandStateMapping(collapseArgs.data, false);
5706
+ }
5635
5707
  _this.trigger(collapsed, collapseArgs);
5636
5708
  if (_this.enableInfiniteScrolling) {
5637
5709
  var scrollHeight = _this.grid.getContent().firstElementChild.scrollHeight;
@@ -5644,6 +5716,19 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
5644
5716
  }
5645
5717
  });
5646
5718
  };
5719
+ TreeGrid.prototype.updateExpandStateMapping = function (record, state) {
5720
+ var totalRecords = record;
5721
+ if (totalRecords.length) {
5722
+ for (var i = 0; i < totalRecords.length; i++) {
5723
+ totalRecords[i][this.expandStateMapping] = state;
5724
+ editAction({ value: totalRecords[i], action: 'edit' }, this, this.isSelfReference, totalRecords[i].index, this.grid.selectedRowIndex, this.expandStateMapping);
5725
+ }
5726
+ }
5727
+ else {
5728
+ record[this.expandStateMapping] = state;
5729
+ editAction({ value: record, action: 'edit' }, this, this.isSelfReference, record.index, this.grid.selectedRowIndex, this.expandStateMapping);
5730
+ }
5731
+ };
5647
5732
  /**
5648
5733
  * Expands the records at specific hierarchical level
5649
5734
  *
@@ -6086,7 +6171,7 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
6086
6171
  freezeRightRows[i].style.display = displayAction;
6087
6172
  }
6088
6173
  this.notify('childRowExpand', { row: rows[i] });
6089
- if (!isNullOrUndefined(childRecords[i].childRecords) && (action !== 'expand' ||
6174
+ if ((!isNullOrUndefined(childRecords[i].childRecords) && childRecords[i].childRecords.length > 0) && (action !== 'expand' ||
6090
6175
  isNullOrUndefined(childRecords[i].expanded) || childRecords[i].expanded)) {
6091
6176
  this.expandCollapse(action, rows[i], childRecords[i], true);
6092
6177
  if (this.frozenColumns <= this.treeColumnIndex && !isNullOrUndefined(movableRows)) {
@@ -6185,6 +6270,28 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
6185
6270
  }
6186
6271
  }
6187
6272
  };
6273
+ /**
6274
+ * Updates the rows and cells
6275
+ *
6276
+ * @param {Object[]} records - Updates the given records
6277
+ * @param {HTMLTableRowElement[]} rows - Updates the given rows
6278
+ * @param {number} index - Updates the given cell index
6279
+ * @returns {void}
6280
+ */
6281
+ TreeGrid.prototype.updateRowAndCellElements = function (records, rows, index) {
6282
+ for (var i = 0; i < records.length; i++) {
6283
+ this.renderModule.cellRender({
6284
+ data: records[i], cell: rows[i].cells[index],
6285
+ column: this.grid.getColumns()[this.treeColumnIndex],
6286
+ requestType: 'rowDragAndDrop'
6287
+ });
6288
+ if (this['action'] === 'indenting' || this['action'] === 'outdenting') {
6289
+ this.renderModule.RowModifier({
6290
+ data: records[i], row: rows[i]
6291
+ });
6292
+ }
6293
+ }
6294
+ };
6188
6295
  /**
6189
6296
  * @hidden
6190
6297
  * @returns {void}
@@ -6538,6 +6645,30 @@ var TreeGrid = /** @__PURE__ @class */ (function (_super) {
6538
6645
  TreeGrid.prototype.reorderRows = function (fromIndexes, toIndex, position) {
6539
6646
  this.rowDragAndDropModule.reorderRows(fromIndexes, toIndex, position);
6540
6647
  };
6648
+ /**
6649
+ * Indents the record to one level of hierarchy. Moves the selected row as the last child of its previous row.
6650
+ *
6651
+ * @param {Object} record – specifies the record to do indented
6652
+ * @returns {void}
6653
+ */
6654
+ TreeGrid.prototype.indent = function (record) {
6655
+ if (!isNullOrUndefined(this.rowDragAndDropModule)) {
6656
+ record = record;
6657
+ this.rowDragAndDropModule[this.indentOutdentAction](record, 'indent');
6658
+ }
6659
+ };
6660
+ /**
6661
+ * Outdent the record to one level of hierarchy. Moves the selected row as sibling to its parent row.
6662
+ *
6663
+ * @param {Object} record – specifies the record to do outdented
6664
+ * @returns {void}
6665
+ */
6666
+ TreeGrid.prototype.outdent = function (record) {
6667
+ if (!isNullOrUndefined(this.rowDragAndDropModule)) {
6668
+ record = record;
6669
+ this.rowDragAndDropModule[this.indentOutdentAction](record, 'outdent');
6670
+ }
6671
+ };
6541
6672
  var TreeGrid_1;
6542
6673
  __decorate([
6543
6674
  Property(0)
@@ -7056,6 +7187,14 @@ var RowDD$1 = /** @__PURE__ @class */ (function () {
7056
7187
  /** @hidden */
7057
7188
  this.isDraggedWithChild = false;
7058
7189
  /** @hidden */
7190
+ this.modifiedRecords = 'modifiedRecords';
7191
+ /** @hidden */
7192
+ this.selectedRecords = 'selectedRecords';
7193
+ /** @hidden */
7194
+ this.selectedRows = 'selectedRows';
7195
+ /** @hidden */
7196
+ this.hasDropItem = true;
7197
+ /** @hidden */
7059
7198
  this.isaddtoBottom = false;
7060
7199
  Grid.Inject(RowDD);
7061
7200
  this.parent = parent;
@@ -7095,6 +7234,8 @@ var RowDD$1 = /** @__PURE__ @class */ (function () {
7095
7234
  RowDD$$1.prototype.reorderRows = function (fromIndexes, toIndex, position) {
7096
7235
  var tObj = this.parent;
7097
7236
  var action = 'action';
7237
+ var dropPosition = 'dropPosition';
7238
+ var updateRowAndCellElements = 'updateRowAndCellElements';
7098
7239
  if (fromIndexes[0] !== toIndex && ['above', 'below', 'child'].indexOf(position) !== -1) {
7099
7240
  if (position === 'above') {
7100
7241
  this.dropPosition = 'topSegment';
@@ -7105,6 +7246,7 @@ var RowDD$1 = /** @__PURE__ @class */ (function () {
7105
7246
  if (position === 'child') {
7106
7247
  this.dropPosition = 'middleSegment';
7107
7248
  }
7249
+ this.parent[dropPosition] = this.dropPosition;
7108
7250
  var data = [];
7109
7251
  for (var i = 0; i < fromIndexes.length; i++) {
7110
7252
  data[i] = this.parent.getCurrentViewRecords()[fromIndexes[i]];
@@ -7128,7 +7270,13 @@ var RowDD$1 = /** @__PURE__ @class */ (function () {
7128
7270
  }
7129
7271
  this.parent.grid.refresh();
7130
7272
  if (this.parent.enableImmutableMode && this.dropPosition === 'middleSegment') {
7131
- var index = this.parent.treeColumnIndex + 1;
7273
+ var index = void 0;
7274
+ if (this.parent.allowRowDragAndDrop) {
7275
+ index = this.parent.treeColumnIndex + 1;
7276
+ }
7277
+ else if (this.parent[action] === 'indenting') {
7278
+ index = this.parent.treeColumnIndex;
7279
+ }
7132
7280
  var row = this.parent.getRows()[fromIndexes[0]];
7133
7281
  var dropData = args.data[0];
7134
7282
  var totalRecord = [];
@@ -7140,36 +7288,119 @@ var RowDD$1 = /** @__PURE__ @class */ (function () {
7140
7288
  var parentrow = this.parent.getRows()[toIndex];
7141
7289
  totalRecord.push(parentData);
7142
7290
  rows.push(parentrow);
7143
- for (var i = 0; i < totalRecord.length; i++) {
7144
- this.parent.renderModule.cellRender({
7145
- data: totalRecord[i], cell: rows[i].cells[index],
7146
- column: this.parent.grid.getColumns()[this.parent.treeColumnIndex],
7147
- requestType: 'rowDragAndDrop'
7148
- });
7149
- if (this.parent[action] === 'indenting' || this.parent[action] === 'outdenting') {
7150
- this.parent.renderModule.RowModifier({
7151
- data: totalRecord[i], row: rows[i]
7152
- });
7153
- }
7291
+ this.parent[updateRowAndCellElements](totalRecord, rows, index);
7292
+ }
7293
+ if (this.parent.enableImmutableMode && this.parent[action] === 'outdenting') {
7294
+ var index = void 0;
7295
+ if (this.parent.allowRowDragAndDrop) {
7296
+ index = this.parent.treeColumnIndex + 1;
7297
+ }
7298
+ else if (this.parent[action] === 'outdenting') {
7299
+ index = this.parent.treeColumnIndex;
7154
7300
  }
7301
+ var record = args.data[0];
7302
+ var row = this.parent.getRows()[fromIndexes[0]];
7303
+ var totalRecord = [];
7304
+ var rows = [];
7305
+ totalRecord.push(record);
7306
+ rows.push(row);
7307
+ this.parent[updateRowAndCellElements](totalRecord, rows, index);
7155
7308
  }
7156
7309
  }
7157
7310
  else {
7158
7311
  return;
7159
7312
  }
7160
7313
  };
7314
+ RowDD$$1.prototype.indentOutdentAction = function (record, request) {
7315
+ var tObj = this.parent;
7316
+ var action = 'action';
7317
+ var droppedIndex = 'dropIndex';
7318
+ var selectedItemIndex = -1;
7319
+ if (isNullOrUndefined(record) && this.parent.selectedRowIndex === -1) {
7320
+ return;
7321
+ }
7322
+ else {
7323
+ if (this.parent.enableVirtualization && this.parent.selectedRowIndex !== -1) {
7324
+ selectedItemIndex = this.parent.getSelectedRows()[0].rowIndex;
7325
+ }
7326
+ else if (this.parent.selectedRowIndex !== -1) {
7327
+ selectedItemIndex = this.parent.selectedRowIndex;
7328
+ }
7329
+ this.selectedItem = isNullOrUndefined(record) ?
7330
+ tObj.getCurrentViewRecords()[selectedItemIndex] : record;
7331
+ var primaryKeyField = this.parent.getPrimaryKeyFieldNames()[0];
7332
+ var rowIndex = this.parent.grid.getRowIndexByPrimaryKey(this.selectedItem[primaryKeyField]);
7333
+ this.selectedRow = this.parent[this.selectedRows] = selectedItemIndex !== -1 ?
7334
+ this.parent.getSelectedRows()[0]
7335
+ : this.parent.grid.getRowByIndex(rowIndex);
7336
+ this.selectedRecord = this.parent[this.selectedRecords] = selectedItemIndex !== -1 ?
7337
+ tObj.getCurrentViewRecords()[selectedItemIndex]
7338
+ : this.selectedItem;
7339
+ if (request === 'indent') {
7340
+ var record_1 = tObj.getCurrentViewRecords()[this.selectedRow.rowIndex - 1];
7341
+ var dropIndex = void 0;
7342
+ if (this.selectedRow.rowIndex === 0 || this.selectedRow.rowIndex === -1 ||
7343
+ tObj.getCurrentViewRecords()[this.selectedRow.rowIndex].level - record_1.level === 1) {
7344
+ return;
7345
+ }
7346
+ if (record_1.level > this.selectedRecord.level) {
7347
+ for (var i = 0; i < tObj.getCurrentViewRecords().length; i++) {
7348
+ if (tObj.getCurrentViewRecords()[i].taskData === record_1.parentItem.taskData) {
7349
+ dropIndex = i;
7350
+ }
7351
+ }
7352
+ }
7353
+ else {
7354
+ dropIndex = this.selectedRow.rowIndex - 1;
7355
+ }
7356
+ tObj[action] = 'indenting';
7357
+ tObj[droppedIndex] = dropIndex;
7358
+ this.eventTrigger('indenting', dropIndex);
7359
+ }
7360
+ else if (request === 'outdent') {
7361
+ if (this.selectedRow.rowIndex === -1 || this.selectedRow.rowIndex === 0 ||
7362
+ tObj.getCurrentViewRecords()[this.selectedRow.rowIndex].level === 0) {
7363
+ return;
7364
+ }
7365
+ var dropIndex = void 0;
7366
+ var parentItem = this.selectedRecord.parentItem;
7367
+ for (var i = 0; i < tObj.getCurrentViewRecords().length; i++) {
7368
+ if (tObj.getCurrentViewRecords()[i].taskData === parentItem.taskData) {
7369
+ dropIndex = i;
7370
+ }
7371
+ }
7372
+ tObj[action] = 'outdenting';
7373
+ tObj[droppedIndex] = dropIndex;
7374
+ this.eventTrigger('outdenting', dropIndex);
7375
+ }
7376
+ }
7377
+ };
7378
+ RowDD$$1.prototype.eventTrigger = function (action, dropIndex) {
7379
+ var _this = this;
7380
+ var actionArgs = {
7381
+ action: action,
7382
+ cancel: false,
7383
+ data: [this.parent[this.selectedRecords]],
7384
+ row: this.parent[this.selectedRows]
7385
+ };
7386
+ this.parent.trigger(actionBegin, actionArgs, function (actionArgs) {
7387
+ if (!actionArgs.cancel) {
7388
+ if (actionArgs.action === 'indenting') {
7389
+ _this.reorderRows([_this.selectedRow.rowIndex], dropIndex, 'child');
7390
+ }
7391
+ else if (actionArgs.action === 'outdenting') {
7392
+ _this.reorderRows([_this.selectedRow.rowIndex], dropIndex, 'below');
7393
+ }
7394
+ }
7395
+ });
7396
+ };
7161
7397
  RowDD$$1.prototype.orderToIndex = function (currentData) {
7162
- var _loop_1 = function (i) {
7398
+ for (var i = 0; i < currentData.length; i++) {
7163
7399
  currentData[i].index = i;
7164
7400
  if (!isNullOrUndefined(currentData[i].parentItem)) {
7165
- var updatedParent = currentData.filter(function (data) {
7166
- return data.uniqueID === currentData[i].parentUniqueID;
7167
- })[0];
7401
+ var updatedParent = getValue('uniqueIDCollection.' + currentData[i].parentUniqueID, this.parent);
7168
7402
  currentData[i].parentItem.index = updatedParent.index;
7169
7403
  }
7170
- };
7171
- for (var i = 0; i < currentData.length; i++) {
7172
- _loop_1(i);
7173
7404
  }
7174
7405
  return currentData;
7175
7406
  };
@@ -7228,7 +7459,8 @@ var RowDD$1 = /** @__PURE__ @class */ (function () {
7228
7459
  }
7229
7460
  }
7230
7461
  }
7231
- if (Object.prototype.hasOwnProperty.call(draggedRecord_1, tObj.parentIdMapping) && draggedRecord_1[tObj.parentIdMapping] != null
7462
+ if (Object.prototype.hasOwnProperty.call(draggedRecord_1, tObj.parentIdMapping)
7463
+ && draggedRecord_1[tObj.parentIdMapping] !== null
7232
7464
  && !this.isDraggedWithChild) {
7233
7465
  draggedRecord_1.taskData[tObj.parentIdMapping] = null;
7234
7466
  delete draggedRecord_1.parentItem;
@@ -7504,13 +7736,34 @@ var RowDD$1 = /** @__PURE__ @class */ (function () {
7504
7736
  spanContent.innerHTML = content;
7505
7737
  dragelem.querySelector('.e-rowcell').appendChild(ele);
7506
7738
  dragelem.querySelector('.e-rowcell').appendChild(spanContent);
7739
+ var dropItemSpan = document.querySelector('.e-dropitemscount');
7740
+ if (this.hasDropItem && dropItemSpan) {
7741
+ var dropItemLeft = parseInt(dropItemSpan.style.left, 10) + ele.offsetWidth + 16;
7742
+ var spanLeft = !this.parent.enableRtl ? dropItemLeft : 0;
7743
+ dropItemSpan.style.left = spanLeft + "px";
7744
+ this.hasDropItem = false;
7745
+ }
7507
7746
  }
7508
7747
  };
7509
7748
  RowDD$$1.prototype.removeErrorElem = function () {
7510
7749
  var errorelem = document.querySelector('.e-errorelem');
7750
+ var errorValue = document.querySelector('.errorValue');
7751
+ var dropItemSpan = document.querySelector('.e-dropitemscount');
7511
7752
  if (errorelem) {
7753
+ if (dropItemSpan) {
7754
+ var dropItemLeft = parseInt(dropItemSpan.style.left, 10) - errorelem.offsetWidth - 16;
7755
+ setStyleAttribute(errorValue, {
7756
+ paddingLeft: '0px'
7757
+ });
7758
+ if (!this.parent.enableRtl) {
7759
+ setStyleAttribute(dropItemSpan, {
7760
+ left: dropItemLeft + "px"
7761
+ });
7762
+ }
7763
+ }
7512
7764
  errorelem.remove();
7513
7765
  }
7766
+ this.hasDropItem = true;
7514
7767
  };
7515
7768
  RowDD$$1.prototype.topOrBottomBorder = function (target) {
7516
7769
  var rowElement = [];
@@ -7699,7 +7952,7 @@ var RowDD$1 = /** @__PURE__ @class */ (function () {
7699
7952
  indexes[i] = records[i].index;
7700
7953
  }
7701
7954
  var data = srcControl.dataSource;
7702
- if (this.parent.idMapping != null && (isNullOrUndefined(this.dropPosition) || this.dropPosition === 'bottomSegment' || this.dropPosition === 'Invalid') && !(data.length)) {
7955
+ if (this.parent.idMapping !== null && (isNullOrUndefined(this.dropPosition) || this.dropPosition === 'bottomSegment' || this.dropPosition === 'Invalid') && !(data.length)) {
7703
7956
  var actualData = [];
7704
7957
  for (var i = 0; i < records.length; i++) {
7705
7958
  if (records[i].hasChildRecords) {
@@ -7747,14 +8000,25 @@ var RowDD$1 = /** @__PURE__ @class */ (function () {
7747
8000
  RowDD$$1.prototype.getTargetIdx = function (targetRow) {
7748
8001
  return targetRow ? parseInt(targetRow.getAttribute('aria-rowindex'), 10) : 0;
7749
8002
  };
7750
- RowDD$$1.prototype.getParentData = function (record) {
8003
+ RowDD$$1.prototype.getParentData = function (record, data) {
7751
8004
  var parentItem = record.parentItem;
8005
+ var selectedItemIndex = -1;
8006
+ if (this.parent.enableVirtualization && this.parent.selectedRowIndex !== -1) {
8007
+ selectedItemIndex = this.parent.getSelectedRows()[0].rowIndex;
8008
+ }
8009
+ else if (this.parent.selectedRowIndex !== -1) {
8010
+ selectedItemIndex = this.parent.selectedRowIndex;
8011
+ }
7752
8012
  if (this.dropPosition === 'bottomSegment') {
7753
- var selectedRecord = this.parent.getSelectedRecords()[0];
8013
+ var primaryKeyField = this.parent.getPrimaryKeyFieldNames()[0];
8014
+ var rowIndex = selectedItemIndex === -1 ?
8015
+ (this.parent.grid.getRowIndexByPrimaryKey(data[0][primaryKeyField])) - 1
8016
+ : this.parent.getSelectedRowIndexes()[0] - 1;
8017
+ var selectedRecord = this.parent.getCurrentViewRecords()[rowIndex];
7754
8018
  this.droppedRecord = getParentData(this.parent, selectedRecord.parentItem.uniqueID);
7755
8019
  }
7756
8020
  if (this.dropPosition === 'middleSegment') {
7757
- var level = this.parent.getSelectedRecords()[0].level;
8021
+ var level = this.parent.getCurrentViewRecords()[selectedItemIndex].level;
7758
8022
  if (level === parentItem.level) {
7759
8023
  this.droppedRecord = getParentData(this.parent, parentItem.uniqueID);
7760
8024
  }
@@ -7769,9 +8033,12 @@ var RowDD$1 = /** @__PURE__ @class */ (function () {
7769
8033
  var draggedRecord_2;
7770
8034
  var droppedRecord = void 0;
7771
8035
  if (isNullOrUndefined(args.dropIndex)) {
7772
- var rowIndex = tObj.getSelectedRowIndexes()[0] - 1;
8036
+ var primaryKeyField = this.parent.getPrimaryKeyFieldNames()[0];
8037
+ var rowIndex = tObj.selectedRowIndex === -1 ?
8038
+ (this.parent.grid.getRowIndexByPrimaryKey(args.data[0][primaryKeyField])) - 1
8039
+ : tObj.getSelectedRowIndexes()[0] - 1;
7773
8040
  var record = tObj.getCurrentViewRecords()[rowIndex];
7774
- this.getParentData(record);
8041
+ this.getParentData(record, args.data);
7775
8042
  }
7776
8043
  else {
7777
8044
  args.dropIndex = args.dropIndex === args.fromIndex ? this.getTargetIdx(args.target.parentElement) : args.dropIndex;
@@ -7785,6 +8052,7 @@ var RowDD$1 = /** @__PURE__ @class */ (function () {
7785
8052
  else {
7786
8053
  dragRecords = args.data;
7787
8054
  }
8055
+ this.parent[this.modifiedRecords].push(args.data[0], droppedRecord);
7788
8056
  var count = 0;
7789
8057
  var multiplegrid = this.parent.rowDropSettings.targetID;
7790
8058
  this.isMultipleGrid = multiplegrid;
@@ -7798,7 +8066,7 @@ var RowDD$1 = /** @__PURE__ @class */ (function () {
7798
8066
  if (!isNullOrUndefined(this.parent.idMapping)) {
7799
8067
  dragRecords.reverse();
7800
8068
  }
7801
- var _loop_2 = function (i) {
8069
+ var _loop_1 = function (i) {
7802
8070
  draggedRecord_2 = dragRecords[i];
7803
8071
  this_1.draggedRecord = draggedRecord_2;
7804
8072
  if (this_1.dropPosition !== 'Invalid') {
@@ -7838,6 +8106,7 @@ var RowDD$1 = /** @__PURE__ @class */ (function () {
7838
8106
  }
7839
8107
  if (isNullOrUndefined(droppedRecord.parentItem)) {
7840
8108
  delete draggedRecord_2.parentItem;
8109
+ delete draggedRecord_2.parentUniqueID;
7841
8110
  draggedRecord_2.level = 0;
7842
8111
  if (this_1.parent.parentIdMapping) {
7843
8112
  draggedRecord_2[this_1.parent.parentIdMapping] = null;
@@ -7884,7 +8153,7 @@ var RowDD$1 = /** @__PURE__ @class */ (function () {
7884
8153
  };
7885
8154
  var this_1 = this;
7886
8155
  for (var i = 0; i < dragLength; i++) {
7887
- _loop_2(i);
8156
+ _loop_1(i);
7888
8157
  }
7889
8158
  }
7890
8159
  };
@@ -8052,7 +8321,7 @@ var RowDD$1 = /** @__PURE__ @class */ (function () {
8052
8321
  if (childRecords && childRecords.length > 0) {
8053
8322
  childIndex = childRecords.indexOf(deletedRow);
8054
8323
  flatParentData.childRecords.splice(childIndex, 1);
8055
- if (!this.parent.parentIdMapping) {
8324
+ if (!this.parent.parentIdMapping || tObj.enableImmutableMode) {
8056
8325
  editAction({ value: deletedRow, action: 'delete' }, this.parent, isSelfReference, deletedRow.index, deletedRow.index);
8057
8326
  }
8058
8327
  }
@@ -8106,6 +8375,19 @@ var RowDD$1 = /** @__PURE__ @class */ (function () {
8106
8375
  flatParentData.hasChildRecords = false;
8107
8376
  flatParentData.hasFilteredChildRecords = false;
8108
8377
  }
8378
+ if (this.parent[this.modifiedRecords].indexOf(flatParentData) === -1 && !isNullOrUndefined(flatParentData)) {
8379
+ this.parent[this.modifiedRecords].push(flatParentData);
8380
+ }
8381
+ if (!isNullOrUndefined(flatParentData)) {
8382
+ this.updateModifiedRecords(flatParentData);
8383
+ }
8384
+ }
8385
+ };
8386
+ RowDD$$1.prototype.updateModifiedRecords = function (record) {
8387
+ var parentData = getParentData(this.parent, record.parentUniqueID);
8388
+ if (!isNullOrUndefined(parentData)) {
8389
+ this.parent[this.modifiedRecords].push(parentData);
8390
+ this.updateModifiedRecords(parentData);
8109
8391
  }
8110
8392
  };
8111
8393
  RowDD$$1.prototype.removeChildItem = function (record) {
@@ -8510,6 +8792,9 @@ var Filter$1 = /** @__PURE__ @class */ (function () {
8510
8792
  }
8511
8793
  }
8512
8794
  else {
8795
+ if (parent['expanded'] === false && this.parent.getVisibleRecords().indexOf(record) === -1 && isNullOrUndefined(this.parent['dataResults']['action'])) {
8796
+ this.parent.expandRow(this.parent.getRows()[parent['index']], parent);
8797
+ }
8513
8798
  this.addParentRecord(parent);
8514
8799
  }
8515
8800
  }
@@ -9181,46 +9466,59 @@ var Toolbar$1 = /** @__PURE__ @class */ (function () {
9181
9466
  };
9182
9467
  Toolbar$$1.prototype.refreshToolbar = function (args) {
9183
9468
  var tObj = this.parent;
9184
- if (args.row.rowIndex === 0 || tObj.getSelectedRecords().length > 1) {
9185
- this.enableItems([tObj.element.id + '_gridcontrol_indent', tObj.element.id + '_gridcontrol_outdent'], false);
9186
- }
9187
- else if (args['name'] !== "rowDeselected") {
9188
- if (!isNullOrUndefined(tObj.getCurrentViewRecords()[args.row.rowIndex])) {
9189
- if (!isNullOrUndefined(tObj.getCurrentViewRecords()[args.row.rowIndex]) &&
9190
- (tObj.getCurrentViewRecords()[args.row.rowIndex].level >
9191
- tObj.getCurrentViewRecords()[args.row.rowIndex - 1].level)) {
9192
- this.enableItems([tObj.element.id + '_gridcontrol_indent'], false);
9193
- }
9194
- else {
9195
- this.enableItems([tObj.element.id + '_gridcontrol_indent'], true);
9196
- }
9197
- if (tObj.getCurrentViewRecords()[args.row.rowIndex].level ===
9198
- tObj.getCurrentViewRecords()[args.row.rowIndex - 1].level) {
9199
- this.enableItems([tObj.element.id + '_gridcontrol_indent'], true);
9469
+ var indentElement;
9470
+ var outdentElement;
9471
+ var indentID = tObj.element.id + '_gridcontrol_indent';
9472
+ var outdentID = tObj.element.id + '_gridcontrol_outdent';
9473
+ var toolbarElement = this.parent.grid.toolbarModule.getToolbar();
9474
+ var indentEle = toolbarElement.querySelector('#' + indentID);
9475
+ var outdentEle = toolbarElement.querySelector('#' + outdentID);
9476
+ var row = args.row;
9477
+ var selectedrow = tObj.getSelectedRows()[0];
9478
+ if (!isNullOrUndefined(row[0])) {
9479
+ row = row[0];
9480
+ }
9481
+ row = (!isNullOrUndefined(selectedrow) && selectedrow.rowIndex !== row.rowIndex) ? selectedrow : row;
9482
+ if (indentEle !== null && outdentEle !== null) {
9483
+ indentElement = toolbarElement.querySelector('#' + indentID).parentElement;
9484
+ outdentElement = toolbarElement.querySelector('#' + outdentID).parentElement;
9485
+ if (row.rowIndex === 0 || tObj.getSelectedRowIndexes().length > 1) {
9486
+ indentElement.classList.add('e-hidden');
9487
+ outdentElement.classList.add('e-hidden');
9488
+ }
9489
+ else if (args['name'] !== 'rowDeselected' || (!isNullOrUndefined(selectedrow) && tObj.grid.isCheckBoxSelection)) {
9490
+ var selectedItem = tObj.getCurrentViewRecords()[row.rowIndex];
9491
+ if (!isNullOrUndefined(selectedItem)) {
9492
+ if ((selectedItem.level > tObj.getCurrentViewRecords()[row.rowIndex - 1].level)) {
9493
+ indentElement.classList.add('e-hidden');
9494
+ }
9495
+ else {
9496
+ indentElement.classList.remove('e-hidden');
9497
+ }
9498
+ if (selectedItem.level === tObj.getCurrentViewRecords()[row.rowIndex - 1].level) {
9499
+ indentElement.classList.remove('e-hidden');
9500
+ }
9501
+ if (selectedItem.level === 0) {
9502
+ outdentElement.classList.add('e-hidden');
9503
+ }
9504
+ if (selectedItem.level !== 0) {
9505
+ outdentElement.classList.remove('e-hidden');
9506
+ }
9200
9507
  }
9201
- if (tObj.getCurrentViewRecords()[args.row.rowIndex].level === 0) {
9202
- this.enableItems([tObj.element.id + '_gridcontrol_outdent'], false);
9508
+ }
9509
+ if (args['name'] === 'rowDeselected' && isNullOrUndefined(selectedrow) && !tObj.grid.isCheckBoxSelection) {
9510
+ if (this.parent.toolbar['includes']('Indent')) {
9511
+ indentElement.classList.add('e-hidden');
9203
9512
  }
9204
- if (tObj.getCurrentViewRecords()[args.row.rowIndex].level !== 0) {
9205
- this.enableItems([tObj.element.id + '_gridcontrol_outdent'], true);
9513
+ if (this.parent.toolbar['includes']('Outdent')) {
9514
+ outdentElement.classList.add('e-hidden');
9206
9515
  }
9207
9516
  }
9208
9517
  }
9209
- if (args['name'] === "rowDeselected") {
9210
- if (this.parent.toolbar['includes']('Indent')) {
9211
- this.enableItems([tObj.element.id + '_gridcontrol_indent'], false);
9212
- }
9213
- if (this.parent.toolbar['includes']('Outdent')) {
9214
- this.enableItems([tObj.element.id + '_gridcontrol_outdent'], false);
9215
- }
9216
- }
9217
- if (args.row.rowIndex === 0 && !isNullOrUndefined(args.data.parentItem)) {
9218
- this.enableItems([tObj.element.id + '_gridcontrol_outdent'], true);
9219
- }
9220
9518
  };
9221
9519
  Toolbar$$1.prototype.toolbarClickHandler = function (args) {
9222
9520
  var tObj = this.parent;
9223
- var action = 'action';
9521
+ var indentOutdentAction = 'indentOutdentAction';
9224
9522
  if (this.parent.editSettings.mode === 'Cell' && this.parent.grid.editSettings.mode === 'Batch' &&
9225
9523
  args.item.id === this.parent.grid.element.id + '_update') {
9226
9524
  args.cancel = true;
@@ -9232,57 +9530,15 @@ var Toolbar$1 = /** @__PURE__ @class */ (function () {
9232
9530
  if (args.item.id === this.parent.grid.element.id + '_collapseall') {
9233
9531
  this.parent.collapseAll();
9234
9532
  }
9235
- if (args.item.id === tObj.grid.element.id + '_indent' && tObj.getSelectedRecords().length) {
9236
- var record = tObj.getCurrentViewRecords()[tObj.getSelectedRowIndexes()[0] - 1];
9237
- var dropIndex = void 0;
9238
- if (record.level > tObj.getSelectedRecords()[0].level) {
9239
- for (var i = 0; i < tObj.getCurrentViewRecords().length; i++) {
9240
- if (tObj.getCurrentViewRecords()[i].taskData === record.parentItem.taskData) {
9241
- dropIndex = i;
9242
- }
9243
- }
9244
- }
9245
- else {
9246
- dropIndex = tObj.getSelectedRowIndexes()[0] - 1;
9247
- }
9248
- this.parent[action] = 'indenting';
9249
- this.eventTrigger('indenting', dropIndex);
9533
+ if (args.item.id === tObj.grid.element.id + '_indent' && tObj.getSelectedRecords().length
9534
+ && !isNullOrUndefined(tObj.rowDragAndDropModule)) {
9535
+ this.parent.rowDragAndDropModule[indentOutdentAction](null, 'indent');
9250
9536
  }
9251
- if (args.item.id === tObj.grid.element.id + '_outdent' && tObj.getSelectedRecords().length) {
9252
- var dropIndex = void 0;
9253
- var parentItem = tObj.getSelectedRecords()[0].parentItem;
9254
- for (var i = 0; i < tObj.getCurrentViewRecords().length; i++) {
9255
- if (tObj.getCurrentViewRecords()[i].taskData === parentItem.taskData) {
9256
- dropIndex = i;
9257
- }
9258
- }
9259
- this.parent[action] = 'outdenting';
9260
- this.eventTrigger('outdenting', dropIndex);
9537
+ if (args.item.id === tObj.grid.element.id + '_outdent' && tObj.getSelectedRecords().length
9538
+ && !isNullOrUndefined(tObj.rowDragAndDropModule)) {
9539
+ this.parent.rowDragAndDropModule[indentOutdentAction](null, 'outdent');
9261
9540
  }
9262
9541
  };
9263
- Toolbar$$1.prototype.eventTrigger = function (action, dropIndex) {
9264
- var _this = this;
9265
- var selectedRecords = 'selectedRecords';
9266
- var selectedRows = 'selectedRows';
9267
- this.parent[selectedRows] = this.parent.getSelectedRows();
9268
- this.parent[selectedRecords] = this.parent.getSelectedRecords();
9269
- var actionArgs = {
9270
- requestType: action,
9271
- data: this.parent.getSelectedRecords(),
9272
- row: this.parent.getSelectedRows(),
9273
- cancel: false
9274
- };
9275
- this.parent.trigger(actionBegin, actionArgs, function (actionArgs) {
9276
- if (!actionArgs.cancel) {
9277
- if (actionArgs.requestType === 'indenting') {
9278
- _this.parent.reorderRows([_this.parent.getSelectedRowIndexes()[0]], dropIndex, 'child');
9279
- }
9280
- else if (actionArgs.requestType === 'outdenting') {
9281
- _this.parent.reorderRows([_this.parent.getSelectedRowIndexes()[0]], dropIndex, 'below');
9282
- }
9283
- }
9284
- });
9285
- };
9286
9542
  /**
9287
9543
  * Gets the toolbar of the TreeGrid.
9288
9544
  *
@@ -10020,9 +10276,17 @@ var BatchEdit = /** @__PURE__ @class */ (function () {
10020
10276
  this.parent.editModule[isTabLastRow] = false;
10021
10277
  return;
10022
10278
  }
10023
- this.selectedIndex = this.parent.grid.selectedRowIndex;
10024
- this.addRowIndex = this.parent.grid.selectedRowIndex > -1 ? this.parent.grid.selectedRowIndex : 0;
10025
- this.addRowRecord = this.parent.getSelectedRecords()[0];
10279
+ if (this.parent.editModule['isAddedRowByMethod'] && !isNullOrUndefined(this.parent.editModule['addRowIndex']) && this.parent.grid.selectedRowIndex === -1) {
10280
+ this.selectedIndex = this.parent.editModule['selectedIndex'];
10281
+ this.addRowIndex = this.parent.editModule['addRowIndex'];
10282
+ this.addRowRecord = this.parent.getCurrentViewRecords()[this.selectedIndex];
10283
+ }
10284
+ else {
10285
+ this.selectedIndex = this.parent.grid.selectedRowIndex;
10286
+ this.addRowIndex = this.parent.grid.selectedRowIndex > -1 ? this.parent.grid.selectedRowIndex : 0;
10287
+ this.parent.editModule['addRowIndex'] = this.parent.grid.selectedRowIndex > -1 ? this.parent.grid.selectedRowIndex : 0;
10288
+ this.addRowRecord = this.parent.getSelectedRecords()[0];
10289
+ }
10026
10290
  };
10027
10291
  BatchEdit.prototype.batchAdd = function (e) {
10028
10292
  if (this.parent.editSettings.newRowPosition !== 'Bottom') {
@@ -10034,6 +10298,9 @@ var BatchEdit = /** @__PURE__ @class */ (function () {
10034
10298
  this.batchRecords = extendArray(this.parent.grid.getCurrentViewRecords());
10035
10299
  this.currentViewRecords = extendArray(this.parent.grid.getCurrentViewRecords());
10036
10300
  }
10301
+ if (this.parent.editModule['isAddedRowByMethod'] && !isNullOrUndefined(this.parent.editModule['addRowIndex'])) {
10302
+ classList(this.parent.grid.getDataRows()[0], ['e-batchrow'], []);
10303
+ }
10037
10304
  if (this.parent.editSettings.newRowPosition !== 'Top') {
10038
10305
  var records = this.parent.grid.getCurrentViewRecords();
10039
10306
  if (this.parent.editSettings.mode === 'Batch' && (this.parent.getBatchChanges()[this.addedRecords].length > 1
@@ -10257,6 +10524,10 @@ var BatchEdit = /** @__PURE__ @class */ (function () {
10257
10524
  }
10258
10525
  if (this.parent.editSettings.newRowPosition !== 'Bottom' && !Object.hasOwnProperty.call(args, 'updatedRecords')) {
10259
10526
  data.splice(data.length - addRecords.length, addRecords.length);
10527
+ if (this.parent.editModule['isAddedRowByMethod'] && addRecords.length && !isNullOrUndefined(this.parent.editModule['addRowIndex'])) {
10528
+ var index_1 = parseInt(this.parent.getContentTable().getElementsByClassName('e-insertedrow')[0].getAttribute('aria-rowindex'), 10);
10529
+ data.splice(index_1, 0, addRecords[0]);
10530
+ }
10260
10531
  if (!this.parent.allowPaging && data.length !== currentViewRecords.length) {
10261
10532
  if (currentViewRecords.length > addRecords.length) {
10262
10533
  currentViewRecords.splice(currentViewRecords.length - addRecords.length, addRecords.length);
@@ -10308,7 +10579,8 @@ var BatchEdit = /** @__PURE__ @class */ (function () {
10308
10579
  }
10309
10580
  editAction({ value: addRecords[i], action: 'add' }, this.parent, this.isSelfReference, addRowIndex, selectedIndex, columnName, addRowRecord);
10310
10581
  selectedIndex = null;
10311
- if (this.parent.editSettings.newRowPosition === 'Child' && !isNullOrUndefined(addRecords[i][parentItem])) {
10582
+ if (this.parent.editSettings.newRowPosition === 'Child' && !isNullOrUndefined(addRecords[i][parentItem]) &&
10583
+ (isNullOrUndefined(this.parent.editModule['addRowIndex']) || this.isSelfReference)) {
10312
10584
  var indexValue = currentViewRecords.map(function (e) { return e[primarykey_1]; })
10313
10585
  .indexOf(addRecords[i][parentItem][primarykey_1]);
10314
10586
  var children = currentViewRecords[indexValue][childRecords];
@@ -11054,6 +11326,21 @@ var Edit$1 = /** @__PURE__ @class */ (function () {
11054
11326
  focussedElement.focus();
11055
11327
  }
11056
11328
  }
11329
+ if (this.parent.editSettings.mode === 'Batch' && !isNullOrUndefined(this.addRowIndex) && this.addRowIndex !== -1) {
11330
+ index = this.batchEditModule.getAddRowIndex();
11331
+ this.selectedIndex = this.batchEditModule.getSelectedIndex();
11332
+ if (this.parent.editModule['isAddedRowByMethod']) {
11333
+ var args = {
11334
+ action: 'add',
11335
+ data: this.parent.getBatchChanges()['addedRecords'][0],
11336
+ index: index,
11337
+ seletedRow: 0
11338
+ };
11339
+ this.parent.editModule.beginAddEdit(args);
11340
+ this.parent.editModule.batchEditModule['batchAddRowRecord'].push(this.parent.editModule.batchEditModule['addRowRecord']);
11341
+ this.parent.editModule.batchEditModule['batchAddedRecords'].push(args['data']);
11342
+ }
11343
+ }
11057
11344
  };
11058
11345
  // private beforeDataBound(args: BeforeDataBoundArgs): void {
11059
11346
  // if (this.parent.grid.isEdit && this.parent.dataSource instanceof DataManager &&
@@ -11198,7 +11485,7 @@ var Edit$1 = /** @__PURE__ @class */ (function () {
11198
11485
  var parentIdMapping = void 0;
11199
11486
  var isVirtualization = this.parent.enableVirtualization && this.addRowIndex > -1 && this.prevAriaRowIndex !== '-1';
11200
11487
  var rows = this.parent.getRows();
11201
- var firstAriaIndex = rows.length ? +rows[0].getAttribute('aria-rowindex') : 0;
11488
+ var firstAriaIndex = rows.length ? currentData.indexOf(currentData[0]) : 0;
11202
11489
  var lastAriaIndex = rows.length ? +rows[rows.length - 1].getAttribute('aria-rowindex') : 0;
11203
11490
  var withinRange = this.selectedIndex >= firstAriaIndex && this.selectedIndex <= lastAriaIndex;
11204
11491
  if (currentData.length) {
@@ -11649,7 +11936,7 @@ var VirtualTreeContentRenderer = /** @__PURE__ @class */ (function (_super) {
11649
11936
  getValue('virtualEle', this).setVirtualHeight(this.parent.getRowHeight() * e.count, '100%');
11650
11937
  }
11651
11938
  }
11652
- if ((!isNullOrUndefined(e.requestType) && e.requestType.toString() === 'collapseAll') || this.isDataSourceChanged) {
11939
+ if ((!isNullOrUndefined(e.requestType) && e.requestType.toString() === 'collapseAll') || (this.isDataSourceChanged && this.startIndex === -1)) {
11653
11940
  this.contents.scrollTop = 0;
11654
11941
  this.isDataSourceChanged = false;
11655
11942
  }
@@ -12193,7 +12480,7 @@ var VirtualScroll$1 = /** @__PURE__ @class */ (function () {
12193
12480
  }
12194
12481
  else {
12195
12482
  var requestType = pageingDetails.actionArgs.requestType;
12196
- if (requestType === 'filtering' || requestType === 'collapseAll' ||
12483
+ if (requestType === 'filtering' || requestType === 'collapseAll' || requestType === 'searching' ||
12197
12484
  (requestType === 'refresh' && this.parent.enableCollapseAll && endIndex > visualData.length)) {
12198
12485
  startIndex = 0;
12199
12486
  endIndex = this.parent.grid.pageSettings.pageSize - 1;