@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 @@ class Column {
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
  setProperties(column) {
87
87
  //Angular two way binding
88
88
  const keys = Object.keys(column);
@@ -91,7 +91,7 @@ class Column {
91
91
  //Refresh the react columnTemplates on state change
92
92
  if (this.parent && this.parent['isReact'] && keys[i] === 'template') {
93
93
  const 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
  }
@@ -1658,6 +1658,31 @@ class Render {
1658
1658
  args.cell.innerHTML = '';
1659
1659
  }
1660
1660
  }
1661
+ /**
1662
+ * @param {string} columnUid - Defines column uid
1663
+ * @returns {void}
1664
+ * @hidden
1665
+ */
1666
+ refreshReactColumnTemplateByUid(columnUid) {
1667
+ if (this.parent.isReact) {
1668
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1669
+ this.parent.clearTemplate(['columnTemplate'], undefined, () => {
1670
+ const cells = 'cells';
1671
+ const rowIdx = 'index';
1672
+ const rowsObj = this.parent.grid.getRowsObject();
1673
+ const indent = this.parent.grid.getIndentCount();
1674
+ const cellIndex = this.parent.grid.getNormalizedColumnIndex(columnUid);
1675
+ for (let j = 0; j < rowsObj.length; j++) {
1676
+ if (rowsObj[j].isDataRow && !isNullOrUndefined(rowsObj[j].index)) {
1677
+ const cell = rowsObj[j][cells][cellIndex];
1678
+ const cellRenderer = new CellRenderer(this.parent.grid, this.parent.grid.serviceLocator);
1679
+ const td = this.parent.getCellFromIndex(rowsObj[j].index, cellIndex - indent);
1680
+ cellRenderer.refreshTD(td, cell, rowsObj[j].data, { index: rowsObj[j][rowIdx] });
1681
+ }
1682
+ }
1683
+ });
1684
+ }
1685
+ }
1661
1686
  columnTemplateResult(args) {
1662
1687
  this.templateResult = args.template;
1663
1688
  }
@@ -2586,7 +2611,9 @@ function editAction(details, control, isSelfReference, addRowIndex, selectedInde
2586
2611
  const childRecords = parentData ? parentData[control.childMapping] : [];
2587
2612
  for (let p = childRecords.length - 1; p >= 0; p--) {
2588
2613
  if (childRecords[p][control.idMapping] === currentData[control.idMapping]) {
2589
- parentData['childRecords'].splice(p, 1);
2614
+ if (!control.enableImmutableMode) {
2615
+ parentData['childRecords'].splice(p, 1);
2616
+ }
2590
2617
  childRecords.splice(p, 1);
2591
2618
  if (!childRecords.length) {
2592
2619
  parentData.hasChildRecords = false;
@@ -2879,7 +2906,12 @@ function updateParentRow(key, record, action, control, isSelfReference, child) {
2879
2906
  control.grid.setRowData(key, record);
2880
2907
  let row = control.getRowByIndex(index);
2881
2908
  if (control.editSettings.mode === 'Batch') {
2882
- row = control.getRows()[control.grid.getRowIndexByPrimaryKey(record[key])];
2909
+ if (action === 'add') {
2910
+ row = control.getRows()[control.grid.getCurrentViewRecords().indexOf(record)];
2911
+ }
2912
+ else {
2913
+ row = control.getRows()[control.grid.getRowIndexByPrimaryKey(record[key])];
2914
+ }
2883
2915
  }
2884
2916
  let movableRow;
2885
2917
  if (control.frozenRows || control.getFrozenColumns()) {
@@ -2952,6 +2984,8 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
2952
2984
  this.changedRecords = 'changedRecords';
2953
2985
  this.deletedRecords = 'deletedRecords';
2954
2986
  this.addedRecords = 'addedRecords';
2987
+ this.indentOutdentAction = 'indentOutdentAction';
2988
+ this.modifiedRecords = [];
2955
2989
  this.objectEqualityChecker = (old, current) => {
2956
2990
  if (old) {
2957
2991
  const keys = Object.keys(old);
@@ -3358,7 +3392,14 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
3358
3392
  return modules;
3359
3393
  }
3360
3394
  extendRequiredModules(modules) {
3361
- if (this.allowRowDragAndDrop) {
3395
+ const IsRowDDInjected = this.injectedModules.filter((e) => {
3396
+ return e.name === 'RowDD';
3397
+ });
3398
+ if (this.allowRowDragAndDrop || IsRowDDInjected.length) {
3399
+ if ((!isNullOrUndefined(this.toolbar) && (this.toolbar['includes']('Indent') ||
3400
+ this.toolbar['includes']('Outdent')))) {
3401
+ this.isIndentEnabled = true;
3402
+ }
3362
3403
  modules.push({
3363
3404
  member: 'rowDragAndDrop',
3364
3405
  args: [this]
@@ -3482,7 +3523,12 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
3482
3523
  }
3483
3524
  return modules;
3484
3525
  };
3526
+ const root = 'root';
3527
+ this.grid[root] = this[root] ? this[root] : this;
3485
3528
  this.grid.appendTo(gridContainer);
3529
+ if (this.isIndentEnabled) {
3530
+ this.refreshToolbarItems();
3531
+ }
3486
3532
  this.wireEvents();
3487
3533
  this.renderComplete();
3488
3534
  const destroyTemplate = 'destroyTemplate';
@@ -3496,6 +3542,15 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
3496
3542
  }
3497
3543
  };
3498
3544
  }
3545
+ refreshToolbarItems() {
3546
+ const toolbarElement = this.toolbarModule.getToolbar();
3547
+ const indentID = this.element.id + '_gridcontrol_indent';
3548
+ const outdentID = this.element.id + '_gridcontrol_outdent';
3549
+ const indentElement = toolbarElement.querySelector('#' + indentID).parentElement;
3550
+ const outdentElement = toolbarElement.querySelector('#' + outdentID).parentElement;
3551
+ indentElement.classList.add('e-hidden');
3552
+ outdentElement.classList.add('e-hidden');
3553
+ }
3499
3554
  afterGridRender() {
3500
3555
  if (!isNullOrUndefined(this.grid.clipboardModule)) {
3501
3556
  this.grid.clipboardModule.destroy();
@@ -3969,14 +4024,24 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
3969
4024
  }
3970
4025
  if (this.action === 'indenting' || this.action === 'outdenting') {
3971
4026
  this.action = this.action === 'indenting' ? 'indented' : 'outdented';
4027
+ const selectedItem = [this.selectedRecords];
3972
4028
  const actionArgs = {
4029
+ data: selectedItem,
4030
+ dropIndex: this.dropIndex,
4031
+ dropPosition: this.dropPosition,
4032
+ modifiedRecords: this.modifiedRecords,
3973
4033
  requestType: this.action,
3974
- data: this.selectedRecords,
3975
4034
  row: this.selectedRows
3976
4035
  };
3977
4036
  this.trigger(actionComplete, actionArgs);
4037
+ const currentPageItem = this.getCurrentViewRecords().filter((e) => {
4038
+ return e.uniqueID === selectedItem[0].uniqueID;
4039
+ });
4040
+ if (!currentPageItem.length) {
4041
+ this.refreshToolbarItems();
4042
+ }
3978
4043
  this.action = '';
3979
- this.selectedRecords = this.selectedRows = [];
4044
+ this.selectedRecords = this.selectedRows = this.modifiedRecords = [];
3980
4045
  }
3981
4046
  else {
3982
4047
  this.trigger(actionComplete, args);
@@ -4178,7 +4243,7 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
4178
4243
  case ToolbarItem.RowIndent:
4179
4244
  tooltipText = this.l10n.getConstant('RowIndent');
4180
4245
  items.push({
4181
- text: tooltipText, tooltipText: tooltipText, disabled: true,
4246
+ text: tooltipText, tooltipText: tooltipText,
4182
4247
  prefixIcon: 'e-indent', id: this.element.id + '_gridcontrol_indent'
4183
4248
  });
4184
4249
  break;
@@ -4186,7 +4251,7 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
4186
4251
  case ToolbarItem.RowOutdent:
4187
4252
  tooltipText = this.l10n.getConstant('RowOutdent');
4188
4253
  items.push({
4189
- text: tooltipText, tooltipText: tooltipText, disabled: true,
4254
+ text: tooltipText, tooltipText: tooltipText,
4190
4255
  prefixIcon: 'e-outdent', id: this.element.id + '_gridcontrol_outdent'
4191
4256
  });
4192
4257
  break;
@@ -4236,6 +4301,15 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
4236
4301
  this.columnModel.push(new Column(treeGridColumn));
4237
4302
  }
4238
4303
  gridColumnCollection.push(gridColumn);
4304
+ if (!isNullOrUndefined(this.columnModel[this.treeColumnIndex]) && this.enableRtl) {
4305
+ if (gridColumn.field === this.columnModel[this.treeColumnIndex].field) {
4306
+ if (isNullOrUndefined(this.treeColumnTextAlign)) {
4307
+ this.treeColumnTextAlign = this.columnModel[this.treeColumnIndex].textAlign;
4308
+ this.treeColumnField = this.columnModel[this.treeColumnIndex].field;
4309
+ }
4310
+ gridColumn.textAlign = 'Right';
4311
+ }
4312
+ }
4239
4313
  }
4240
4314
  return gridColumnCollection;
4241
4315
  }
@@ -4407,6 +4481,9 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
4407
4481
  this.grid.allowPdfExport = this.allowPdfExport;
4408
4482
  break;
4409
4483
  case 'enableRtl':
4484
+ if (!isNullOrUndefined(this.treeColumnField)) {
4485
+ this.updateTreeColumnTextAlign();
4486
+ }
4410
4487
  this.grid.enableRtl = this.enableRtl;
4411
4488
  break;
4412
4489
  case 'allowReordering':
@@ -4447,6 +4524,11 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
4447
4524
  }
4448
4525
  }
4449
4526
  }
4527
+ updateTreeColumnTextAlign() {
4528
+ const gridColumn = this.grid.getColumnByField(this.treeColumnField);
4529
+ gridColumn.textAlign = this.enableRtl ? 'Right' : this.treeColumnTextAlign;
4530
+ this.grid.refreshColumns();
4531
+ }
4450
4532
  /**
4451
4533
  * Destroys the component (detaches/removes all event handlers, attributes, classes, and empties the component element).
4452
4534
  *
@@ -4784,10 +4866,13 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
4784
4866
  rowData.parentUniqueID = record.parentUniqueID;
4785
4867
  rowData.expanded = record.expanded;
4786
4868
  this.grid.setRowData(key, rowData);
4787
- const table = this.getContentTable();
4788
- const sHeight = table.scrollHeight;
4789
- const clientHeight = this.getContent().clientHeight;
4790
- this.lastRowBorder(this.getRows()[record.index], sHeight <= clientHeight);
4869
+ const visibleRecords = this.getVisibleRecords();
4870
+ if (visibleRecords.length > 0 && key === (visibleRecords[visibleRecords.length - 1])[primaryKey]) {
4871
+ const table = this.getContentTable();
4872
+ const sHeight = table.scrollHeight;
4873
+ const clientHeight = this.getContent().clientHeight;
4874
+ this.lastRowBorder(this.getRows()[currentRecords.indexOf(record)], sHeight <= clientHeight);
4875
+ }
4791
4876
  }
4792
4877
  /**
4793
4878
  * Navigates to the specified target page.
@@ -4996,31 +5081,6 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
4996
5081
  this[merge$$1] = undefined; // Workaround for blazor updateModel
4997
5082
  return this.columnModel;
4998
5083
  }
4999
- /**
5000
- * @param {string} columnUid - Defines column uid
5001
- * @returns {void}
5002
- * @hidden
5003
- */
5004
- refreshReactColumnTemplateByUid(columnUid) {
5005
- if (this.isReact) {
5006
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
5007
- this.clearTemplate(['columnTemplate'], undefined, () => {
5008
- const cells = 'cells';
5009
- const rowIdx = 'index';
5010
- const rowsObj = this.grid.getRowsObject();
5011
- const indent = this.grid.getIndentCount();
5012
- const cellIndex = this.grid.getNormalizedColumnIndex(columnUid);
5013
- for (let j = 0; j < rowsObj.length; j++) {
5014
- if (rowsObj[j].isDataRow && !isNullOrUndefined(rowsObj[j].index)) {
5015
- const cell = rowsObj[j][cells][cellIndex];
5016
- const cellRenderer = new CellRenderer(this.grid, this.grid.serviceLocator);
5017
- const td = this.getCellFromIndex(rowsObj[j].index, cellIndex - indent);
5018
- cellRenderer.refreshTD(td, cell, rowsObj[j].data, { index: rowsObj[j][rowIdx] });
5019
- }
5020
- }
5021
- });
5022
- }
5023
- }
5024
5084
  /**
5025
5085
  * Gets the content div of the TreeGrid.
5026
5086
  *
@@ -5165,8 +5225,14 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
5165
5225
  this.uniqueIDCollection = {};
5166
5226
  this.convertTreeData(this.dataSource);
5167
5227
  if (!isCountRequired(this)) {
5168
- this.grid.dataSource = !(this.dataSource instanceof DataManager) ? this.flatData :
5169
- new DataManager(this.dataSource.dataSource, this.dataSource.defaultQuery, this.dataSource.adaptor);
5228
+ if (!(this.dataSource instanceof DataManager)) {
5229
+ this.grid.dataSource = this.flatData;
5230
+ }
5231
+ else {
5232
+ this.grid.setProperties({
5233
+ dataSource: new DataManager(this.dataSource.dataSource, this.dataSource.defaultQuery, this.dataSource.adaptor)
5234
+ }, true);
5235
+ }
5170
5236
  }
5171
5237
  this.grid.refresh();
5172
5238
  }
@@ -5309,6 +5375,9 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
5309
5375
  if (!(isRemoteData(this) && !isOffline(this)) && (!isCountRequired(this) || !isNullOrUndefined(record[children]))) {
5310
5376
  const collapseArgs = { data: record, row: row };
5311
5377
  this.setHeightForFrozenContent();
5378
+ if (!isNullOrUndefined(this.expandStateMapping)) {
5379
+ this.updateExpandStateMapping(collapseArgs.data, true);
5380
+ }
5312
5381
  this.trigger(expanded, collapseArgs);
5313
5382
  }
5314
5383
  }
@@ -5370,6 +5439,9 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
5370
5439
  const collapseArgs = { data: record, row: row };
5371
5440
  if (!isRemoteData(this)) {
5372
5441
  this.setHeightForFrozenContent();
5442
+ if (!isNullOrUndefined(this.expandStateMapping)) {
5443
+ this.updateExpandStateMapping(collapseArgs.data, false);
5444
+ }
5373
5445
  this.trigger(collapsed, collapseArgs);
5374
5446
  if (this.enableInfiniteScrolling) {
5375
5447
  const scrollHeight = this.grid.getContent().firstElementChild.scrollHeight;
@@ -5382,6 +5454,19 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
5382
5454
  }
5383
5455
  });
5384
5456
  }
5457
+ updateExpandStateMapping(record, state) {
5458
+ const totalRecords = record;
5459
+ if (totalRecords.length) {
5460
+ for (let i = 0; i < totalRecords.length; i++) {
5461
+ totalRecords[i][this.expandStateMapping] = state;
5462
+ editAction({ value: totalRecords[i], action: 'edit' }, this, this.isSelfReference, totalRecords[i].index, this.grid.selectedRowIndex, this.expandStateMapping);
5463
+ }
5464
+ }
5465
+ else {
5466
+ record[this.expandStateMapping] = state;
5467
+ editAction({ value: record, action: 'edit' }, this, this.isSelfReference, record.index, this.grid.selectedRowIndex, this.expandStateMapping);
5468
+ }
5469
+ }
5385
5470
  /**
5386
5471
  * Expands the records at specific hierarchical level
5387
5472
  *
@@ -5807,7 +5892,7 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
5807
5892
  freezeRightRows[i].style.display = displayAction;
5808
5893
  }
5809
5894
  this.notify('childRowExpand', { row: rows[i] });
5810
- if (!isNullOrUndefined(childRecords[i].childRecords) && (action !== 'expand' ||
5895
+ if ((!isNullOrUndefined(childRecords[i].childRecords) && childRecords[i].childRecords.length > 0) && (action !== 'expand' ||
5811
5896
  isNullOrUndefined(childRecords[i].expanded) || childRecords[i].expanded)) {
5812
5897
  this.expandCollapse(action, rows[i], childRecords[i], true);
5813
5898
  if (this.frozenColumns <= this.treeColumnIndex && !isNullOrUndefined(movableRows)) {
@@ -5902,6 +5987,28 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
5902
5987
  }
5903
5988
  }
5904
5989
  }
5990
+ /**
5991
+ * Updates the rows and cells
5992
+ *
5993
+ * @param {Object[]} records - Updates the given records
5994
+ * @param {HTMLTableRowElement[]} rows - Updates the given rows
5995
+ * @param {number} index - Updates the given cell index
5996
+ * @returns {void}
5997
+ */
5998
+ updateRowAndCellElements(records, rows, index) {
5999
+ for (let i = 0; i < records.length; i++) {
6000
+ this.renderModule.cellRender({
6001
+ data: records[i], cell: rows[i].cells[index],
6002
+ column: this.grid.getColumns()[this.treeColumnIndex],
6003
+ requestType: 'rowDragAndDrop'
6004
+ });
6005
+ if (this['action'] === 'indenting' || this['action'] === 'outdenting') {
6006
+ this.renderModule.RowModifier({
6007
+ data: records[i], row: rows[i]
6008
+ });
6009
+ }
6010
+ }
6011
+ }
5905
6012
  /**
5906
6013
  * @hidden
5907
6014
  * @returns {void}
@@ -6255,6 +6362,30 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
6255
6362
  reorderRows(fromIndexes, toIndex, position) {
6256
6363
  this.rowDragAndDropModule.reorderRows(fromIndexes, toIndex, position);
6257
6364
  }
6365
+ /**
6366
+ * Indents the record to one level of hierarchy. Moves the selected row as the last child of its previous row.
6367
+ *
6368
+ * @param {Object} record – specifies the record to do indented
6369
+ * @returns {void}
6370
+ */
6371
+ indent(record) {
6372
+ if (!isNullOrUndefined(this.rowDragAndDropModule)) {
6373
+ record = record;
6374
+ this.rowDragAndDropModule[this.indentOutdentAction](record, 'indent');
6375
+ }
6376
+ }
6377
+ /**
6378
+ * Outdent the record to one level of hierarchy. Moves the selected row as sibling to its parent row.
6379
+ *
6380
+ * @param {Object} record – specifies the record to do outdented
6381
+ * @returns {void}
6382
+ */
6383
+ outdent(record) {
6384
+ if (!isNullOrUndefined(this.rowDragAndDropModule)) {
6385
+ record = record;
6386
+ this.rowDragAndDropModule[this.indentOutdentAction](record, 'outdent');
6387
+ }
6388
+ }
6258
6389
  };
6259
6390
  __decorate([
6260
6391
  Property(0)
@@ -6769,6 +6900,14 @@ class RowDD$1 {
6769
6900
  /** @hidden */
6770
6901
  this.isDraggedWithChild = false;
6771
6902
  /** @hidden */
6903
+ this.modifiedRecords = 'modifiedRecords';
6904
+ /** @hidden */
6905
+ this.selectedRecords = 'selectedRecords';
6906
+ /** @hidden */
6907
+ this.selectedRows = 'selectedRows';
6908
+ /** @hidden */
6909
+ this.hasDropItem = true;
6910
+ /** @hidden */
6772
6911
  this.isaddtoBottom = false;
6773
6912
  Grid.Inject(RowDD);
6774
6913
  this.parent = parent;
@@ -6808,6 +6947,8 @@ class RowDD$1 {
6808
6947
  reorderRows(fromIndexes, toIndex, position) {
6809
6948
  const tObj = this.parent;
6810
6949
  const action = 'action';
6950
+ const dropPosition = 'dropPosition';
6951
+ const updateRowAndCellElements = 'updateRowAndCellElements';
6811
6952
  if (fromIndexes[0] !== toIndex && ['above', 'below', 'child'].indexOf(position) !== -1) {
6812
6953
  if (position === 'above') {
6813
6954
  this.dropPosition = 'topSegment';
@@ -6818,6 +6959,7 @@ class RowDD$1 {
6818
6959
  if (position === 'child') {
6819
6960
  this.dropPosition = 'middleSegment';
6820
6961
  }
6962
+ this.parent[dropPosition] = this.dropPosition;
6821
6963
  const data = [];
6822
6964
  for (let i = 0; i < fromIndexes.length; i++) {
6823
6965
  data[i] = this.parent.getCurrentViewRecords()[fromIndexes[i]];
@@ -6841,7 +6983,13 @@ class RowDD$1 {
6841
6983
  }
6842
6984
  this.parent.grid.refresh();
6843
6985
  if (this.parent.enableImmutableMode && this.dropPosition === 'middleSegment') {
6844
- const index = this.parent.treeColumnIndex + 1;
6986
+ let index;
6987
+ if (this.parent.allowRowDragAndDrop) {
6988
+ index = this.parent.treeColumnIndex + 1;
6989
+ }
6990
+ else if (this.parent[action] === 'indenting') {
6991
+ index = this.parent.treeColumnIndex;
6992
+ }
6845
6993
  const row = this.parent.getRows()[fromIndexes[0]];
6846
6994
  const dropData = args.data[0];
6847
6995
  const totalRecord = [];
@@ -6853,31 +7001,116 @@ class RowDD$1 {
6853
7001
  const parentrow = this.parent.getRows()[toIndex];
6854
7002
  totalRecord.push(parentData);
6855
7003
  rows.push(parentrow);
6856
- for (let i = 0; i < totalRecord.length; i++) {
6857
- this.parent.renderModule.cellRender({
6858
- data: totalRecord[i], cell: rows[i].cells[index],
6859
- column: this.parent.grid.getColumns()[this.parent.treeColumnIndex],
6860
- requestType: 'rowDragAndDrop'
6861
- });
6862
- if (this.parent[action] === 'indenting' || this.parent[action] === 'outdenting') {
6863
- this.parent.renderModule.RowModifier({
6864
- data: totalRecord[i], row: rows[i]
6865
- });
6866
- }
7004
+ this.parent[updateRowAndCellElements](totalRecord, rows, index);
7005
+ }
7006
+ if (this.parent.enableImmutableMode && this.parent[action] === 'outdenting') {
7007
+ let index;
7008
+ if (this.parent.allowRowDragAndDrop) {
7009
+ index = this.parent.treeColumnIndex + 1;
7010
+ }
7011
+ else if (this.parent[action] === 'outdenting') {
7012
+ index = this.parent.treeColumnIndex;
6867
7013
  }
7014
+ const record = args.data[0];
7015
+ const row = this.parent.getRows()[fromIndexes[0]];
7016
+ const totalRecord = [];
7017
+ const rows = [];
7018
+ totalRecord.push(record);
7019
+ rows.push(row);
7020
+ this.parent[updateRowAndCellElements](totalRecord, rows, index);
6868
7021
  }
6869
7022
  }
6870
7023
  else {
6871
7024
  return;
6872
7025
  }
6873
7026
  }
7027
+ indentOutdentAction(record, request) {
7028
+ const tObj = this.parent;
7029
+ const action = 'action';
7030
+ const droppedIndex = 'dropIndex';
7031
+ let selectedItemIndex = -1;
7032
+ if (isNullOrUndefined(record) && this.parent.selectedRowIndex === -1) {
7033
+ return;
7034
+ }
7035
+ else {
7036
+ if (this.parent.enableVirtualization && this.parent.selectedRowIndex !== -1) {
7037
+ selectedItemIndex = this.parent.getSelectedRows()[0].rowIndex;
7038
+ }
7039
+ else if (this.parent.selectedRowIndex !== -1) {
7040
+ selectedItemIndex = this.parent.selectedRowIndex;
7041
+ }
7042
+ this.selectedItem = isNullOrUndefined(record) ?
7043
+ tObj.getCurrentViewRecords()[selectedItemIndex] : record;
7044
+ const primaryKeyField = this.parent.getPrimaryKeyFieldNames()[0];
7045
+ const rowIndex = this.parent.grid.getRowIndexByPrimaryKey(this.selectedItem[primaryKeyField]);
7046
+ this.selectedRow = this.parent[this.selectedRows] = selectedItemIndex !== -1 ?
7047
+ this.parent.getSelectedRows()[0]
7048
+ : this.parent.grid.getRowByIndex(rowIndex);
7049
+ this.selectedRecord = this.parent[this.selectedRecords] = selectedItemIndex !== -1 ?
7050
+ tObj.getCurrentViewRecords()[selectedItemIndex]
7051
+ : this.selectedItem;
7052
+ if (request === 'indent') {
7053
+ const record = tObj.getCurrentViewRecords()[this.selectedRow.rowIndex - 1];
7054
+ let dropIndex;
7055
+ if (this.selectedRow.rowIndex === 0 || this.selectedRow.rowIndex === -1 ||
7056
+ tObj.getCurrentViewRecords()[this.selectedRow.rowIndex].level - record.level === 1) {
7057
+ return;
7058
+ }
7059
+ if (record.level > this.selectedRecord.level) {
7060
+ for (let i = 0; i < tObj.getCurrentViewRecords().length; i++) {
7061
+ if (tObj.getCurrentViewRecords()[i].taskData === record.parentItem.taskData) {
7062
+ dropIndex = i;
7063
+ }
7064
+ }
7065
+ }
7066
+ else {
7067
+ dropIndex = this.selectedRow.rowIndex - 1;
7068
+ }
7069
+ tObj[action] = 'indenting';
7070
+ tObj[droppedIndex] = dropIndex;
7071
+ this.eventTrigger('indenting', dropIndex);
7072
+ }
7073
+ else if (request === 'outdent') {
7074
+ if (this.selectedRow.rowIndex === -1 || this.selectedRow.rowIndex === 0 ||
7075
+ tObj.getCurrentViewRecords()[this.selectedRow.rowIndex].level === 0) {
7076
+ return;
7077
+ }
7078
+ let dropIndex;
7079
+ const parentItem = this.selectedRecord.parentItem;
7080
+ for (let i = 0; i < tObj.getCurrentViewRecords().length; i++) {
7081
+ if (tObj.getCurrentViewRecords()[i].taskData === parentItem.taskData) {
7082
+ dropIndex = i;
7083
+ }
7084
+ }
7085
+ tObj[action] = 'outdenting';
7086
+ tObj[droppedIndex] = dropIndex;
7087
+ this.eventTrigger('outdenting', dropIndex);
7088
+ }
7089
+ }
7090
+ }
7091
+ eventTrigger(action, dropIndex) {
7092
+ const actionArgs = {
7093
+ action: action,
7094
+ cancel: false,
7095
+ data: [this.parent[this.selectedRecords]],
7096
+ row: this.parent[this.selectedRows]
7097
+ };
7098
+ this.parent.trigger(actionBegin, actionArgs, (actionArgs) => {
7099
+ if (!actionArgs.cancel) {
7100
+ if (actionArgs.action === 'indenting') {
7101
+ this.reorderRows([this.selectedRow.rowIndex], dropIndex, 'child');
7102
+ }
7103
+ else if (actionArgs.action === 'outdenting') {
7104
+ this.reorderRows([this.selectedRow.rowIndex], dropIndex, 'below');
7105
+ }
7106
+ }
7107
+ });
7108
+ }
6874
7109
  orderToIndex(currentData) {
6875
7110
  for (let i = 0; i < currentData.length; i++) {
6876
7111
  currentData[i].index = i;
6877
7112
  if (!isNullOrUndefined(currentData[i].parentItem)) {
6878
- const updatedParent = currentData.filter((data) => {
6879
- return data.uniqueID === currentData[i].parentUniqueID;
6880
- })[0];
7113
+ const updatedParent = getValue('uniqueIDCollection.' + currentData[i].parentUniqueID, this.parent);
6881
7114
  currentData[i].parentItem.index = updatedParent.index;
6882
7115
  }
6883
7116
  }
@@ -6938,7 +7171,8 @@ class RowDD$1 {
6938
7171
  }
6939
7172
  }
6940
7173
  }
6941
- if (Object.prototype.hasOwnProperty.call(draggedRecord, tObj.parentIdMapping) && draggedRecord[tObj.parentIdMapping] != null
7174
+ if (Object.prototype.hasOwnProperty.call(draggedRecord, tObj.parentIdMapping)
7175
+ && draggedRecord[tObj.parentIdMapping] !== null
6942
7176
  && !this.isDraggedWithChild) {
6943
7177
  draggedRecord.taskData[tObj.parentIdMapping] = null;
6944
7178
  delete draggedRecord.parentItem;
@@ -7214,13 +7448,34 @@ class RowDD$1 {
7214
7448
  spanContent.innerHTML = content;
7215
7449
  dragelem.querySelector('.e-rowcell').appendChild(ele);
7216
7450
  dragelem.querySelector('.e-rowcell').appendChild(spanContent);
7451
+ const dropItemSpan = document.querySelector('.e-dropitemscount');
7452
+ if (this.hasDropItem && dropItemSpan) {
7453
+ const dropItemLeft = parseInt(dropItemSpan.style.left, 10) + ele.offsetWidth + 16;
7454
+ const spanLeft = !this.parent.enableRtl ? dropItemLeft : 0;
7455
+ dropItemSpan.style.left = `${spanLeft}px`;
7456
+ this.hasDropItem = false;
7457
+ }
7217
7458
  }
7218
7459
  }
7219
7460
  removeErrorElem() {
7220
7461
  const errorelem = document.querySelector('.e-errorelem');
7462
+ const errorValue = document.querySelector('.errorValue');
7463
+ const dropItemSpan = document.querySelector('.e-dropitemscount');
7221
7464
  if (errorelem) {
7465
+ if (dropItemSpan) {
7466
+ const dropItemLeft = parseInt(dropItemSpan.style.left, 10) - errorelem.offsetWidth - 16;
7467
+ setStyleAttribute(errorValue, {
7468
+ paddingLeft: '0px'
7469
+ });
7470
+ if (!this.parent.enableRtl) {
7471
+ setStyleAttribute(dropItemSpan, {
7472
+ left: `${dropItemLeft}px`
7473
+ });
7474
+ }
7475
+ }
7222
7476
  errorelem.remove();
7223
7477
  }
7478
+ this.hasDropItem = true;
7224
7479
  }
7225
7480
  topOrBottomBorder(target) {
7226
7481
  let rowElement = [];
@@ -7409,7 +7664,7 @@ class RowDD$1 {
7409
7664
  indexes[i] = records[i].index;
7410
7665
  }
7411
7666
  const data = srcControl.dataSource;
7412
- if (this.parent.idMapping != null && (isNullOrUndefined(this.dropPosition) || this.dropPosition === 'bottomSegment' || this.dropPosition === 'Invalid') && !(data.length)) {
7667
+ if (this.parent.idMapping !== null && (isNullOrUndefined(this.dropPosition) || this.dropPosition === 'bottomSegment' || this.dropPosition === 'Invalid') && !(data.length)) {
7413
7668
  const actualData = [];
7414
7669
  for (let i = 0; i < records.length; i++) {
7415
7670
  if (records[i].hasChildRecords) {
@@ -7457,14 +7712,25 @@ class RowDD$1 {
7457
7712
  getTargetIdx(targetRow) {
7458
7713
  return targetRow ? parseInt(targetRow.getAttribute('aria-rowindex'), 10) : 0;
7459
7714
  }
7460
- getParentData(record) {
7715
+ getParentData(record, data) {
7461
7716
  const parentItem = record.parentItem;
7717
+ let selectedItemIndex = -1;
7718
+ if (this.parent.enableVirtualization && this.parent.selectedRowIndex !== -1) {
7719
+ selectedItemIndex = this.parent.getSelectedRows()[0].rowIndex;
7720
+ }
7721
+ else if (this.parent.selectedRowIndex !== -1) {
7722
+ selectedItemIndex = this.parent.selectedRowIndex;
7723
+ }
7462
7724
  if (this.dropPosition === 'bottomSegment') {
7463
- const selectedRecord = this.parent.getSelectedRecords()[0];
7725
+ const primaryKeyField = this.parent.getPrimaryKeyFieldNames()[0];
7726
+ const rowIndex = selectedItemIndex === -1 ?
7727
+ (this.parent.grid.getRowIndexByPrimaryKey(data[0][primaryKeyField])) - 1
7728
+ : this.parent.getSelectedRowIndexes()[0] - 1;
7729
+ const selectedRecord = this.parent.getCurrentViewRecords()[rowIndex];
7464
7730
  this.droppedRecord = getParentData(this.parent, selectedRecord.parentItem.uniqueID);
7465
7731
  }
7466
7732
  if (this.dropPosition === 'middleSegment') {
7467
- const level = this.parent.getSelectedRecords()[0].level;
7733
+ const level = this.parent.getCurrentViewRecords()[selectedItemIndex].level;
7468
7734
  if (level === parentItem.level) {
7469
7735
  this.droppedRecord = getParentData(this.parent, parentItem.uniqueID);
7470
7736
  }
@@ -7479,9 +7745,12 @@ class RowDD$1 {
7479
7745
  let draggedRecord;
7480
7746
  let droppedRecord;
7481
7747
  if (isNullOrUndefined(args.dropIndex)) {
7482
- const rowIndex = tObj.getSelectedRowIndexes()[0] - 1;
7748
+ const primaryKeyField = this.parent.getPrimaryKeyFieldNames()[0];
7749
+ const rowIndex = tObj.selectedRowIndex === -1 ?
7750
+ (this.parent.grid.getRowIndexByPrimaryKey(args.data[0][primaryKeyField])) - 1
7751
+ : tObj.getSelectedRowIndexes()[0] - 1;
7483
7752
  const record = tObj.getCurrentViewRecords()[rowIndex];
7484
- this.getParentData(record);
7753
+ this.getParentData(record, args.data);
7485
7754
  }
7486
7755
  else {
7487
7756
  args.dropIndex = args.dropIndex === args.fromIndex ? this.getTargetIdx(args.target.parentElement) : args.dropIndex;
@@ -7495,6 +7764,7 @@ class RowDD$1 {
7495
7764
  else {
7496
7765
  dragRecords = args.data;
7497
7766
  }
7767
+ this.parent[this.modifiedRecords].push(args.data[0], droppedRecord);
7498
7768
  let count = 0;
7499
7769
  const multiplegrid = this.parent.rowDropSettings.targetID;
7500
7770
  this.isMultipleGrid = multiplegrid;
@@ -7548,6 +7818,7 @@ class RowDD$1 {
7548
7818
  }
7549
7819
  if (isNullOrUndefined(droppedRecord.parentItem)) {
7550
7820
  delete draggedRecord.parentItem;
7821
+ delete draggedRecord.parentUniqueID;
7551
7822
  draggedRecord.level = 0;
7552
7823
  if (this.parent.parentIdMapping) {
7553
7824
  draggedRecord[this.parent.parentIdMapping] = null;
@@ -7758,7 +8029,7 @@ class RowDD$1 {
7758
8029
  if (childRecords && childRecords.length > 0) {
7759
8030
  childIndex = childRecords.indexOf(deletedRow);
7760
8031
  flatParentData.childRecords.splice(childIndex, 1);
7761
- if (!this.parent.parentIdMapping) {
8032
+ if (!this.parent.parentIdMapping || tObj.enableImmutableMode) {
7762
8033
  editAction({ value: deletedRow, action: 'delete' }, this.parent, isSelfReference, deletedRow.index, deletedRow.index);
7763
8034
  }
7764
8035
  }
@@ -7812,6 +8083,19 @@ class RowDD$1 {
7812
8083
  flatParentData.hasChildRecords = false;
7813
8084
  flatParentData.hasFilteredChildRecords = false;
7814
8085
  }
8086
+ if (this.parent[this.modifiedRecords].indexOf(flatParentData) === -1 && !isNullOrUndefined(flatParentData)) {
8087
+ this.parent[this.modifiedRecords].push(flatParentData);
8088
+ }
8089
+ if (!isNullOrUndefined(flatParentData)) {
8090
+ this.updateModifiedRecords(flatParentData);
8091
+ }
8092
+ }
8093
+ }
8094
+ updateModifiedRecords(record) {
8095
+ const parentData = getParentData(this.parent, record.parentUniqueID);
8096
+ if (!isNullOrUndefined(parentData)) {
8097
+ this.parent[this.modifiedRecords].push(parentData);
8098
+ this.updateModifiedRecords(parentData);
7815
8099
  }
7816
8100
  }
7817
8101
  removeChildItem(record) {
@@ -8180,6 +8464,9 @@ class Filter$1 {
8180
8464
  }
8181
8465
  }
8182
8466
  else {
8467
+ if (parent['expanded'] === false && this.parent.getVisibleRecords().indexOf(record) === -1 && isNullOrUndefined(this.parent['dataResults']['action'])) {
8468
+ this.parent.expandRow(this.parent.getRows()[parent['index']], parent);
8469
+ }
8183
8470
  this.addParentRecord(parent);
8184
8471
  }
8185
8472
  }
@@ -8840,46 +9127,59 @@ class Toolbar$1 {
8840
9127
  }
8841
9128
  refreshToolbar(args) {
8842
9129
  const tObj = this.parent;
8843
- if (args.row.rowIndex === 0 || tObj.getSelectedRecords().length > 1) {
8844
- this.enableItems([tObj.element.id + '_gridcontrol_indent', tObj.element.id + '_gridcontrol_outdent'], false);
8845
- }
8846
- else if (args['name'] !== "rowDeselected") {
8847
- if (!isNullOrUndefined(tObj.getCurrentViewRecords()[args.row.rowIndex])) {
8848
- if (!isNullOrUndefined(tObj.getCurrentViewRecords()[args.row.rowIndex]) &&
8849
- (tObj.getCurrentViewRecords()[args.row.rowIndex].level >
8850
- tObj.getCurrentViewRecords()[args.row.rowIndex - 1].level)) {
8851
- this.enableItems([tObj.element.id + '_gridcontrol_indent'], false);
8852
- }
8853
- else {
8854
- this.enableItems([tObj.element.id + '_gridcontrol_indent'], true);
8855
- }
8856
- if (tObj.getCurrentViewRecords()[args.row.rowIndex].level ===
8857
- tObj.getCurrentViewRecords()[args.row.rowIndex - 1].level) {
8858
- this.enableItems([tObj.element.id + '_gridcontrol_indent'], true);
9130
+ let indentElement;
9131
+ let outdentElement;
9132
+ const indentID = tObj.element.id + '_gridcontrol_indent';
9133
+ const outdentID = tObj.element.id + '_gridcontrol_outdent';
9134
+ const toolbarElement = this.parent.grid.toolbarModule.getToolbar();
9135
+ const indentEle = toolbarElement.querySelector('#' + indentID);
9136
+ const outdentEle = toolbarElement.querySelector('#' + outdentID);
9137
+ let row = args.row;
9138
+ const selectedrow = tObj.getSelectedRows()[0];
9139
+ if (!isNullOrUndefined(row[0])) {
9140
+ row = row[0];
9141
+ }
9142
+ row = (!isNullOrUndefined(selectedrow) && selectedrow.rowIndex !== row.rowIndex) ? selectedrow : row;
9143
+ if (indentEle !== null && outdentEle !== null) {
9144
+ indentElement = toolbarElement.querySelector('#' + indentID).parentElement;
9145
+ outdentElement = toolbarElement.querySelector('#' + outdentID).parentElement;
9146
+ if (row.rowIndex === 0 || tObj.getSelectedRowIndexes().length > 1) {
9147
+ indentElement.classList.add('e-hidden');
9148
+ outdentElement.classList.add('e-hidden');
9149
+ }
9150
+ else if (args['name'] !== 'rowDeselected' || (!isNullOrUndefined(selectedrow) && tObj.grid.isCheckBoxSelection)) {
9151
+ const selectedItem = tObj.getCurrentViewRecords()[row.rowIndex];
9152
+ if (!isNullOrUndefined(selectedItem)) {
9153
+ if ((selectedItem.level > tObj.getCurrentViewRecords()[row.rowIndex - 1].level)) {
9154
+ indentElement.classList.add('e-hidden');
9155
+ }
9156
+ else {
9157
+ indentElement.classList.remove('e-hidden');
9158
+ }
9159
+ if (selectedItem.level === tObj.getCurrentViewRecords()[row.rowIndex - 1].level) {
9160
+ indentElement.classList.remove('e-hidden');
9161
+ }
9162
+ if (selectedItem.level === 0) {
9163
+ outdentElement.classList.add('e-hidden');
9164
+ }
9165
+ if (selectedItem.level !== 0) {
9166
+ outdentElement.classList.remove('e-hidden');
9167
+ }
8859
9168
  }
8860
- if (tObj.getCurrentViewRecords()[args.row.rowIndex].level === 0) {
8861
- this.enableItems([tObj.element.id + '_gridcontrol_outdent'], false);
9169
+ }
9170
+ if (args['name'] === 'rowDeselected' && isNullOrUndefined(selectedrow) && !tObj.grid.isCheckBoxSelection) {
9171
+ if (this.parent.toolbar['includes']('Indent')) {
9172
+ indentElement.classList.add('e-hidden');
8862
9173
  }
8863
- if (tObj.getCurrentViewRecords()[args.row.rowIndex].level !== 0) {
8864
- this.enableItems([tObj.element.id + '_gridcontrol_outdent'], true);
9174
+ if (this.parent.toolbar['includes']('Outdent')) {
9175
+ outdentElement.classList.add('e-hidden');
8865
9176
  }
8866
9177
  }
8867
9178
  }
8868
- if (args['name'] === "rowDeselected") {
8869
- if (this.parent.toolbar['includes']('Indent')) {
8870
- this.enableItems([tObj.element.id + '_gridcontrol_indent'], false);
8871
- }
8872
- if (this.parent.toolbar['includes']('Outdent')) {
8873
- this.enableItems([tObj.element.id + '_gridcontrol_outdent'], false);
8874
- }
8875
- }
8876
- if (args.row.rowIndex === 0 && !isNullOrUndefined(args.data.parentItem)) {
8877
- this.enableItems([tObj.element.id + '_gridcontrol_outdent'], true);
8878
- }
8879
9179
  }
8880
9180
  toolbarClickHandler(args) {
8881
9181
  const tObj = this.parent;
8882
- const action = 'action';
9182
+ const indentOutdentAction = 'indentOutdentAction';
8883
9183
  if (this.parent.editSettings.mode === 'Cell' && this.parent.grid.editSettings.mode === 'Batch' &&
8884
9184
  args.item.id === this.parent.grid.element.id + '_update') {
8885
9185
  args.cancel = true;
@@ -8891,56 +9191,15 @@ class Toolbar$1 {
8891
9191
  if (args.item.id === this.parent.grid.element.id + '_collapseall') {
8892
9192
  this.parent.collapseAll();
8893
9193
  }
8894
- if (args.item.id === tObj.grid.element.id + '_indent' && tObj.getSelectedRecords().length) {
8895
- const record = tObj.getCurrentViewRecords()[tObj.getSelectedRowIndexes()[0] - 1];
8896
- let dropIndex;
8897
- if (record.level > tObj.getSelectedRecords()[0].level) {
8898
- for (let i = 0; i < tObj.getCurrentViewRecords().length; i++) {
8899
- if (tObj.getCurrentViewRecords()[i].taskData === record.parentItem.taskData) {
8900
- dropIndex = i;
8901
- }
8902
- }
8903
- }
8904
- else {
8905
- dropIndex = tObj.getSelectedRowIndexes()[0] - 1;
8906
- }
8907
- this.parent[action] = 'indenting';
8908
- this.eventTrigger('indenting', dropIndex);
9194
+ if (args.item.id === tObj.grid.element.id + '_indent' && tObj.getSelectedRecords().length
9195
+ && !isNullOrUndefined(tObj.rowDragAndDropModule)) {
9196
+ this.parent.rowDragAndDropModule[indentOutdentAction](null, 'indent');
8909
9197
  }
8910
- if (args.item.id === tObj.grid.element.id + '_outdent' && tObj.getSelectedRecords().length) {
8911
- let dropIndex;
8912
- const parentItem = tObj.getSelectedRecords()[0].parentItem;
8913
- for (let i = 0; i < tObj.getCurrentViewRecords().length; i++) {
8914
- if (tObj.getCurrentViewRecords()[i].taskData === parentItem.taskData) {
8915
- dropIndex = i;
8916
- }
8917
- }
8918
- this.parent[action] = 'outdenting';
8919
- this.eventTrigger('outdenting', dropIndex);
9198
+ if (args.item.id === tObj.grid.element.id + '_outdent' && tObj.getSelectedRecords().length
9199
+ && !isNullOrUndefined(tObj.rowDragAndDropModule)) {
9200
+ this.parent.rowDragAndDropModule[indentOutdentAction](null, 'outdent');
8920
9201
  }
8921
9202
  }
8922
- eventTrigger(action, dropIndex) {
8923
- const selectedRecords = 'selectedRecords';
8924
- const selectedRows = 'selectedRows';
8925
- this.parent[selectedRows] = this.parent.getSelectedRows();
8926
- this.parent[selectedRecords] = this.parent.getSelectedRecords();
8927
- const actionArgs = {
8928
- requestType: action,
8929
- data: this.parent.getSelectedRecords(),
8930
- row: this.parent.getSelectedRows(),
8931
- cancel: false
8932
- };
8933
- this.parent.trigger(actionBegin, actionArgs, (actionArgs) => {
8934
- if (!actionArgs.cancel) {
8935
- if (actionArgs.requestType === 'indenting') {
8936
- this.parent.reorderRows([this.parent.getSelectedRowIndexes()[0]], dropIndex, 'child');
8937
- }
8938
- else if (actionArgs.requestType === 'outdenting') {
8939
- this.parent.reorderRows([this.parent.getSelectedRowIndexes()[0]], dropIndex, 'below');
8940
- }
8941
- }
8942
- });
8943
- }
8944
9203
  /**
8945
9204
  * Gets the toolbar of the TreeGrid.
8946
9205
  *
@@ -9668,9 +9927,17 @@ class BatchEdit {
9668
9927
  this.parent.editModule[isTabLastRow] = false;
9669
9928
  return;
9670
9929
  }
9671
- this.selectedIndex = this.parent.grid.selectedRowIndex;
9672
- this.addRowIndex = this.parent.grid.selectedRowIndex > -1 ? this.parent.grid.selectedRowIndex : 0;
9673
- this.addRowRecord = this.parent.getSelectedRecords()[0];
9930
+ if (this.parent.editModule['isAddedRowByMethod'] && !isNullOrUndefined(this.parent.editModule['addRowIndex']) && this.parent.grid.selectedRowIndex === -1) {
9931
+ this.selectedIndex = this.parent.editModule['selectedIndex'];
9932
+ this.addRowIndex = this.parent.editModule['addRowIndex'];
9933
+ this.addRowRecord = this.parent.getCurrentViewRecords()[this.selectedIndex];
9934
+ }
9935
+ else {
9936
+ this.selectedIndex = this.parent.grid.selectedRowIndex;
9937
+ this.addRowIndex = this.parent.grid.selectedRowIndex > -1 ? this.parent.grid.selectedRowIndex : 0;
9938
+ this.parent.editModule['addRowIndex'] = this.parent.grid.selectedRowIndex > -1 ? this.parent.grid.selectedRowIndex : 0;
9939
+ this.addRowRecord = this.parent.getSelectedRecords()[0];
9940
+ }
9674
9941
  }
9675
9942
  batchAdd(e) {
9676
9943
  if (this.parent.editSettings.newRowPosition !== 'Bottom') {
@@ -9682,6 +9949,9 @@ class BatchEdit {
9682
9949
  this.batchRecords = extendArray(this.parent.grid.getCurrentViewRecords());
9683
9950
  this.currentViewRecords = extendArray(this.parent.grid.getCurrentViewRecords());
9684
9951
  }
9952
+ if (this.parent.editModule['isAddedRowByMethod'] && !isNullOrUndefined(this.parent.editModule['addRowIndex'])) {
9953
+ classList(this.parent.grid.getDataRows()[0], ['e-batchrow'], []);
9954
+ }
9685
9955
  if (this.parent.editSettings.newRowPosition !== 'Top') {
9686
9956
  let records = this.parent.grid.getCurrentViewRecords();
9687
9957
  if (this.parent.editSettings.mode === 'Batch' && (this.parent.getBatchChanges()[this.addedRecords].length > 1
@@ -9905,6 +10175,10 @@ class BatchEdit {
9905
10175
  }
9906
10176
  if (this.parent.editSettings.newRowPosition !== 'Bottom' && !Object.hasOwnProperty.call(args, 'updatedRecords')) {
9907
10177
  data.splice(data.length - addRecords.length, addRecords.length);
10178
+ if (this.parent.editModule['isAddedRowByMethod'] && addRecords.length && !isNullOrUndefined(this.parent.editModule['addRowIndex'])) {
10179
+ const index = parseInt(this.parent.getContentTable().getElementsByClassName('e-insertedrow')[0].getAttribute('aria-rowindex'), 10);
10180
+ data.splice(index, 0, addRecords[0]);
10181
+ }
9908
10182
  if (!this.parent.allowPaging && data.length !== currentViewRecords.length) {
9909
10183
  if (currentViewRecords.length > addRecords.length) {
9910
10184
  currentViewRecords.splice(currentViewRecords.length - addRecords.length, addRecords.length);
@@ -9956,7 +10230,8 @@ class BatchEdit {
9956
10230
  }
9957
10231
  editAction({ value: addRecords[i], action: 'add' }, this.parent, this.isSelfReference, addRowIndex, selectedIndex, columnName, addRowRecord);
9958
10232
  selectedIndex = null;
9959
- if (this.parent.editSettings.newRowPosition === 'Child' && !isNullOrUndefined(addRecords[i][parentItem])) {
10233
+ if (this.parent.editSettings.newRowPosition === 'Child' && !isNullOrUndefined(addRecords[i][parentItem]) &&
10234
+ (isNullOrUndefined(this.parent.editModule['addRowIndex']) || this.isSelfReference)) {
9960
10235
  const indexValue = currentViewRecords.map((e) => { return e[primarykey]; })
9961
10236
  .indexOf(addRecords[i][parentItem][primarykey]);
9962
10237
  const children = currentViewRecords[indexValue][childRecords];
@@ -10698,6 +10973,21 @@ class Edit$1 {
10698
10973
  focussedElement.focus();
10699
10974
  }
10700
10975
  }
10976
+ if (this.parent.editSettings.mode === 'Batch' && !isNullOrUndefined(this.addRowIndex) && this.addRowIndex !== -1) {
10977
+ index = this.batchEditModule.getAddRowIndex();
10978
+ this.selectedIndex = this.batchEditModule.getSelectedIndex();
10979
+ if (this.parent.editModule['isAddedRowByMethod']) {
10980
+ const args = {
10981
+ action: 'add',
10982
+ data: this.parent.getBatchChanges()['addedRecords'][0],
10983
+ index: index,
10984
+ seletedRow: 0
10985
+ };
10986
+ this.parent.editModule.beginAddEdit(args);
10987
+ this.parent.editModule.batchEditModule['batchAddRowRecord'].push(this.parent.editModule.batchEditModule['addRowRecord']);
10988
+ this.parent.editModule.batchEditModule['batchAddedRecords'].push(args['data']);
10989
+ }
10990
+ }
10701
10991
  }
10702
10992
  // private beforeDataBound(args: BeforeDataBoundArgs): void {
10703
10993
  // if (this.parent.grid.isEdit && this.parent.dataSource instanceof DataManager &&
@@ -10838,7 +11128,7 @@ class Edit$1 {
10838
11128
  let parentIdMapping;
10839
11129
  const isVirtualization = this.parent.enableVirtualization && this.addRowIndex > -1 && this.prevAriaRowIndex !== '-1';
10840
11130
  const rows = this.parent.getRows();
10841
- const firstAriaIndex = rows.length ? +rows[0].getAttribute('aria-rowindex') : 0;
11131
+ const firstAriaIndex = rows.length ? currentData.indexOf(currentData[0]) : 0;
10842
11132
  const lastAriaIndex = rows.length ? +rows[rows.length - 1].getAttribute('aria-rowindex') : 0;
10843
11133
  const withinRange = this.selectedIndex >= firstAriaIndex && this.selectedIndex <= lastAriaIndex;
10844
11134
  if (currentData.length) {
@@ -11270,7 +11560,7 @@ class VirtualTreeContentRenderer extends VirtualContentRenderer {
11270
11560
  getValue('virtualEle', this).setVirtualHeight(this.parent.getRowHeight() * e.count, '100%');
11271
11561
  }
11272
11562
  }
11273
- if ((!isNullOrUndefined(e.requestType) && e.requestType.toString() === 'collapseAll') || this.isDataSourceChanged) {
11563
+ if ((!isNullOrUndefined(e.requestType) && e.requestType.toString() === 'collapseAll') || (this.isDataSourceChanged && this.startIndex === -1)) {
11274
11564
  this.contents.scrollTop = 0;
11275
11565
  this.isDataSourceChanged = false;
11276
11566
  }
@@ -11794,7 +12084,7 @@ class VirtualScroll$1 {
11794
12084
  }
11795
12085
  else {
11796
12086
  const requestType = pageingDetails.actionArgs.requestType;
11797
- if (requestType === 'filtering' || requestType === 'collapseAll' ||
12087
+ if (requestType === 'filtering' || requestType === 'collapseAll' || requestType === 'searching' ||
11798
12088
  (requestType === 'refresh' && this.parent.enableCollapseAll && endIndex > visualData.length)) {
11799
12089
  startIndex = 0;
11800
12090
  endIndex = this.parent.grid.pageSettings.pageSize - 1;