@syncfusion/ej2-treegrid 20.1.48 → 20.1.55

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 (58) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/ej2-treegrid.umd.min.js +2 -2
  3. package/dist/ej2-treegrid.umd.min.js.map +1 -1
  4. package/dist/es6/ej2-treegrid.es2015.js +3731 -3537
  5. package/dist/es6/ej2-treegrid.es2015.js.map +1 -1
  6. package/dist/es6/ej2-treegrid.es5.js +5209 -5014
  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 +1 -1
  13. package/src/treegrid/actions/crud-actions.js +6 -1
  14. package/src/treegrid/actions/edit.js +2 -2
  15. package/src/treegrid/actions/rowdragdrop.d.ts +13 -0
  16. package/src/treegrid/actions/rowdragdrop.js +127 -7
  17. package/src/treegrid/actions/selection.js +4 -2
  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.d.ts +21 -0
  22. package/src/treegrid/base/treegrid.js +67 -16
  23. package/src/treegrid/models/column.d.ts +9 -0
  24. package/src/treegrid/models/column.js +19 -0
  25. package/src/treegrid/models/rowdrop-settings.d.ts +9 -1
  26. package/src/treegrid/renderer/render.d.ts +6 -0
  27. package/src/treegrid/renderer/render.js +27 -1
  28. package/src/treegrid/renderer/virtual-tree-content-render.js +1 -1
  29. package/styles/bootstrap-dark.css +12 -95
  30. package/styles/bootstrap.css +12 -95
  31. package/styles/bootstrap4.css +12 -94
  32. package/styles/bootstrap5-dark.css +12 -94
  33. package/styles/bootstrap5.css +12 -94
  34. package/styles/fabric-dark.css +12 -93
  35. package/styles/fabric.css +12 -93
  36. package/styles/fluent-dark.css +13 -96
  37. package/styles/fluent.css +13 -96
  38. package/styles/highcontrast-light.css +10 -104
  39. package/styles/highcontrast.css +10 -104
  40. package/styles/material-dark.css +8 -84
  41. package/styles/material.css +8 -85
  42. package/styles/tailwind-dark.css +8 -82
  43. package/styles/tailwind.css +8 -82
  44. package/styles/treegrid/bootstrap-dark.css +12 -95
  45. package/styles/treegrid/bootstrap.css +12 -95
  46. package/styles/treegrid/bootstrap4.css +12 -94
  47. package/styles/treegrid/bootstrap5-dark.css +12 -94
  48. package/styles/treegrid/bootstrap5.css +12 -94
  49. package/styles/treegrid/fabric-dark.css +12 -93
  50. package/styles/treegrid/fabric.css +12 -93
  51. package/styles/treegrid/fluent-dark.css +13 -96
  52. package/styles/treegrid/fluent.css +13 -96
  53. package/styles/treegrid/highcontrast-light.css +10 -104
  54. package/styles/treegrid/highcontrast.css +10 -104
  55. package/styles/treegrid/material-dark.css +8 -84
  56. package/styles/treegrid/material.css +8 -85
  57. package/styles/treegrid/tailwind-dark.css +8 -82
  58. package/styles/treegrid/tailwind.css +8 -82
@@ -38,7 +38,6 @@ import { isRemoteData, isOffline, extendArray, isCountRequired, findChildrenReco
38
38
  import { Grid, Logger } from '@syncfusion/ej2-grids';
39
39
  import { Render } from '../renderer/render';
40
40
  import { DataManipulation } from './data';
41
- import { RowDD } from '../actions/rowdragdrop';
42
41
  import { iterateArrayOrObject } from '@syncfusion/ej2-grids';
43
42
  import { ToolbarItem, ContextMenuItems } from '../enum';
44
43
  import { PageSettings } from '../models/page-settings';
@@ -68,6 +67,9 @@ var TreeGrid = /** @class */ (function (_super) {
68
67
  _this.changedRecords = 'changedRecords';
69
68
  _this.deletedRecords = 'deletedRecords';
70
69
  _this.addedRecords = 'addedRecords';
70
+ _this.indentOutdentAction = 'indentOutdentAction';
71
+ _this.modifiedRecords = [];
72
+ _this.stackedHeader = false;
71
73
  _this.objectEqualityChecker = function (old, current) {
72
74
  if (old) {
73
75
  var keys = Object.keys(old);
@@ -476,14 +478,14 @@ var TreeGrid = /** @class */ (function (_super) {
476
478
  return modules;
477
479
  };
478
480
  TreeGrid.prototype.extendRequiredModules = function (modules) {
479
- if (this.allowRowDragAndDrop) {
480
- modules.push({
481
- member: 'rowDragAndDrop',
482
- args: [this]
483
- });
484
- }
485
- if (!isNullOrUndefined(this.toolbar) && (this.toolbar['includes']('Indent') || this.toolbar['includes']('Outdent'))) {
486
- TreeGrid_1.Inject(RowDD);
481
+ var IsRowDDInjected = this.injectedModules.filter(function (e) {
482
+ return e.name === 'RowDD';
483
+ });
484
+ if (this.allowRowDragAndDrop || IsRowDDInjected.length) {
485
+ if ((!isNullOrUndefined(this.toolbar) && (this.toolbar['includes']('Indent') ||
486
+ this.toolbar['includes']('Outdent')))) {
487
+ this.isIndentEnabled = true;
488
+ }
487
489
  modules.push({
488
490
  member: 'rowDragAndDrop',
489
491
  args: [this]
@@ -612,6 +614,9 @@ var TreeGrid = /** @class */ (function (_super) {
612
614
  var root = 'root';
613
615
  this.grid[root] = this[root] ? this[root] : this;
614
616
  this.grid.appendTo(gridContainer);
617
+ if (this.isIndentEnabled) {
618
+ this.refreshToolbarItems();
619
+ }
615
620
  this.wireEvents();
616
621
  this.renderComplete();
617
622
  var destroyTemplate = 'destroyTemplate';
@@ -625,6 +630,15 @@ var TreeGrid = /** @class */ (function (_super) {
625
630
  }
626
631
  };
627
632
  };
633
+ TreeGrid.prototype.refreshToolbarItems = function () {
634
+ var toolbarElement = this.toolbarModule.getToolbar();
635
+ var indentID = this.element.id + '_gridcontrol_indent';
636
+ var outdentID = this.element.id + '_gridcontrol_outdent';
637
+ var indentElement = toolbarElement.querySelector('#' + indentID).parentElement;
638
+ var outdentElement = toolbarElement.querySelector('#' + outdentID).parentElement;
639
+ indentElement.classList.add('e-hidden');
640
+ outdentElement.classList.add('e-hidden');
641
+ };
628
642
  TreeGrid.prototype.afterGridRender = function () {
629
643
  if (!isNullOrUndefined(this.grid.clipboardModule)) {
630
644
  this.grid.clipboardModule.destroy();
@@ -1104,14 +1118,24 @@ var TreeGrid = /** @class */ (function (_super) {
1104
1118
  }
1105
1119
  if (_this.action === 'indenting' || _this.action === 'outdenting') {
1106
1120
  _this.action = _this.action === 'indenting' ? 'indented' : 'outdented';
1121
+ var selectedItem_1 = [_this.selectedRecords];
1107
1122
  var actionArgs = {
1123
+ data: selectedItem_1,
1124
+ dropIndex: _this.dropIndex,
1125
+ dropPosition: _this.dropPosition,
1126
+ modifiedRecords: _this.modifiedRecords,
1108
1127
  requestType: _this.action,
1109
- data: _this.selectedRecords,
1110
1128
  row: _this.selectedRows
1111
1129
  };
1112
1130
  _this.trigger(events.actionComplete, actionArgs);
1131
+ var currentPageItem = _this.getCurrentViewRecords().filter(function (e) {
1132
+ return e.uniqueID === selectedItem_1[0].uniqueID;
1133
+ });
1134
+ if (!currentPageItem.length) {
1135
+ _this.refreshToolbarItems();
1136
+ }
1113
1137
  _this.action = '';
1114
- _this.selectedRecords = _this.selectedRows = [];
1138
+ _this.selectedRecords = _this.selectedRows = _this.modifiedRecords = [];
1115
1139
  }
1116
1140
  else {
1117
1141
  _this.trigger(events.actionComplete, args);
@@ -1315,7 +1339,7 @@ var TreeGrid = /** @class */ (function (_super) {
1315
1339
  case ToolbarItem.RowIndent:
1316
1340
  tooltipText = this.l10n.getConstant('RowIndent');
1317
1341
  items.push({
1318
- text: tooltipText, tooltipText: tooltipText, disabled: true,
1342
+ text: tooltipText, tooltipText: tooltipText,
1319
1343
  prefixIcon: 'e-indent', id: this.element.id + '_gridcontrol_indent'
1320
1344
  });
1321
1345
  break;
@@ -1323,7 +1347,7 @@ var TreeGrid = /** @class */ (function (_super) {
1323
1347
  case ToolbarItem.RowOutdent:
1324
1348
  tooltipText = this.l10n.getConstant('RowOutdent');
1325
1349
  items.push({
1326
- text: tooltipText, tooltipText: tooltipText, disabled: true,
1350
+ text: tooltipText, tooltipText: tooltipText,
1327
1351
  prefixIcon: 'e-outdent', id: this.element.id + '_gridcontrol_outdent'
1328
1352
  });
1329
1353
  break;
@@ -2004,6 +2028,10 @@ var TreeGrid = /** @class */ (function (_super) {
2004
2028
  */
2005
2029
  TreeGrid.prototype.getColumnByUid = function (uid) {
2006
2030
  var Columns = this.initialRender ? this.grid.columns : this.columns;
2031
+ var columnModel = 'columnModel';
2032
+ if (this.grid.columns.length !== this.columnModel.length) {
2033
+ Columns = this.grid[columnModel];
2034
+ }
2007
2035
  return iterateArrayOrObject(Columns, function (item) {
2008
2036
  if (item.uid === uid) {
2009
2037
  return item;
@@ -2131,7 +2159,6 @@ var TreeGrid = /** @class */ (function (_super) {
2131
2159
  temp = this.columnModel[this.treeColumnIndex].template;
2132
2160
  field = this.columnModel[this.treeColumnIndex].field;
2133
2161
  }
2134
- var stackedHeader = false;
2135
2162
  var gridColumn;
2136
2163
  if (!this.enableColumnVirtualization || (this.enableColumnVirtualization && this.columnModel.length === gridColumns.length)) {
2137
2164
  this.columnModel = [];
@@ -2150,9 +2177,9 @@ var TreeGrid = /** @class */ (function (_super) {
2150
2177
  var merge = 'deepMerge';
2151
2178
  this[merge] = ['columns']; // Workaround for blazor updateModel
2152
2179
  if (this.grid.columns.length !== this.columnModel.length) {
2153
- stackedHeader = true;
2180
+ this.stackedHeader = true;
2154
2181
  }
2155
- if (!stackedHeader) {
2182
+ if (!this.stackedHeader) {
2156
2183
  this.setProperties({ columns: this.columnModel }, true);
2157
2184
  }
2158
2185
  this[merge] = undefined; // Workaround for blazor updateModel
@@ -3463,6 +3490,30 @@ var TreeGrid = /** @class */ (function (_super) {
3463
3490
  TreeGrid.prototype.reorderRows = function (fromIndexes, toIndex, position) {
3464
3491
  this.rowDragAndDropModule.reorderRows(fromIndexes, toIndex, position);
3465
3492
  };
3493
+ /**
3494
+ * Indents the record to one level of hierarchy. Moves the selected row as the last child of its previous row.
3495
+ *
3496
+ * @param {Object} record – specifies the record to do indented
3497
+ * @returns {void}
3498
+ */
3499
+ TreeGrid.prototype.indent = function (record) {
3500
+ if (!isNullOrUndefined(this.rowDragAndDropModule)) {
3501
+ record = record;
3502
+ this.rowDragAndDropModule[this.indentOutdentAction](record, 'indent');
3503
+ }
3504
+ };
3505
+ /**
3506
+ * Outdent the record to one level of hierarchy. Moves the selected row as sibling to its parent row.
3507
+ *
3508
+ * @param {Object} record – specifies the record to do outdented
3509
+ * @returns {void}
3510
+ */
3511
+ TreeGrid.prototype.outdent = function (record) {
3512
+ if (!isNullOrUndefined(this.rowDragAndDropModule)) {
3513
+ record = record;
3514
+ this.rowDragAndDropModule[this.indentOutdentAction](record, 'outdent');
3515
+ }
3516
+ };
3466
3517
  var TreeGrid_1;
3467
3518
  __decorate([
3468
3519
  Property(0)
@@ -326,7 +326,16 @@ export declare class Column {
326
326
  * @default null
327
327
  */
328
328
  freeze: freezeDirection;
329
+ private parent;
329
330
  constructor(options: ColumnModel);
331
+ /**
332
+ * Update the State changes reflected for TreeGrid columndirective in react platform.
333
+ *
334
+ * @param {Column} column - specifies the column
335
+ * @returns {void}
336
+ * @hidden
337
+ */
338
+ private setProperties;
330
339
  }
331
340
  /**
332
341
  * Interface for a TreeGrid class Column
@@ -71,6 +71,25 @@ var Column = /** @class */ (function () {
71
71
  this.filter = {};
72
72
  merge(this, options);
73
73
  }
74
+ /**
75
+ * Update the State changes reflected for TreeGrid columndirective in react platform.
76
+ *
77
+ * @param {Column} column - specifies the column
78
+ * @returns {void}
79
+ * @hidden
80
+ */
81
+ Column.prototype.setProperties = function (column) {
82
+ //Angular two way binding
83
+ var keys = Object.keys(column);
84
+ for (var i = 0; i < keys.length; i++) {
85
+ this[keys[i]] = column[keys[i]];
86
+ //Refresh the react columnTemplates on state change
87
+ if (this.parent && this.parent['isReact'] && keys[i] === 'template') {
88
+ var refreshReactColumnTemplateByUid = 'refreshReactColumnTemplateByUid';
89
+ this.parent.clipboardModule['treeGridParent'].renderModule[refreshReactColumnTemplateByUid](this.uid);
90
+ }
91
+ }
92
+ };
74
93
  return Column;
75
94
  }());
76
95
  export { Column };
@@ -13,7 +13,15 @@ export declare class RowDropSettings extends ChildProperty<RowDropSettings> {
13
13
  }
14
14
  export interface TreeActionEventArgs {
15
15
  requestType?: string;
16
- data?: ITreeData[];
16
+ data?: ITreeData | ITreeData[];
17
17
  row?: Object[];
18
18
  cancel?: boolean;
19
+ /** Defines the corresponding action */
20
+ action?: string;
21
+ /** Defines the target element from index. */
22
+ dropIndex?: number;
23
+ /** Defines drop position of the dragged record */
24
+ dropPosition?: string;
25
+ /** Defines the modified records. */
26
+ modifiedRecords?: ITreeData[];
19
27
  }
@@ -29,6 +29,12 @@ export declare class Render {
29
29
  */
30
30
  cellRender(args: QueryCellInfoEventArgs): void;
31
31
  private updateTreeCell;
32
+ /**
33
+ * @param {string} columnUid - Defines column uid
34
+ * @returns {void}
35
+ * @hidden
36
+ */
37
+ private refreshReactColumnTemplateByUid;
32
38
  private columnTemplateResult;
33
39
  private reactTemplateRender;
34
40
  destroy(): void;
@@ -1,5 +1,5 @@
1
1
  import { getObject, appendChildren } from '@syncfusion/ej2-grids';
2
- import { templateCompiler, extend } from '@syncfusion/ej2-grids';
2
+ import { templateCompiler, extend, CellRenderer } from '@syncfusion/ej2-grids';
3
3
  import { addClass, createElement, isNullOrUndefined, getValue } from '@syncfusion/ej2-base';
4
4
  import * as events from '../base/constant';
5
5
  import { isRemoteData, isOffline, getExpandStatus, isFilterChildHierarchy } from '../utils';
@@ -275,6 +275,32 @@ var Render = /** @class */ (function () {
275
275
  args.cell.innerHTML = '';
276
276
  }
277
277
  };
278
+ /**
279
+ * @param {string} columnUid - Defines column uid
280
+ * @returns {void}
281
+ * @hidden
282
+ */
283
+ Render.prototype.refreshReactColumnTemplateByUid = function (columnUid) {
284
+ var _this = this;
285
+ if (this.parent.isReact) {
286
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
287
+ this.parent.clearTemplate(['columnTemplate'], undefined, function () {
288
+ var cells = 'cells';
289
+ var rowIdx = 'index';
290
+ var rowsObj = _this.parent.grid.getRowsObject();
291
+ var indent = _this.parent.grid.getIndentCount();
292
+ var cellIndex = _this.parent.grid.getNormalizedColumnIndex(columnUid);
293
+ for (var j = 0; j < rowsObj.length; j++) {
294
+ if (rowsObj[j].isDataRow && !isNullOrUndefined(rowsObj[j].index)) {
295
+ var cell = rowsObj[j][cells][cellIndex];
296
+ var cellRenderer = new CellRenderer(_this.parent.grid, _this.parent.grid.serviceLocator);
297
+ var td = _this.parent.getCellFromIndex(rowsObj[j].index, cellIndex - indent);
298
+ cellRenderer.refreshTD(td, cell, rowsObj[j].data, { index: rowsObj[j][rowIdx] });
299
+ }
300
+ }
301
+ });
302
+ }
303
+ };
278
304
  Render.prototype.columnTemplateResult = function (args) {
279
305
  this.templateResult = args.template;
280
306
  };
@@ -126,7 +126,7 @@ var VirtualTreeContentRenderer = /** @class */ (function (_super) {
126
126
  getValue('virtualEle', this).setVirtualHeight(this.parent.getRowHeight() * e.count, '100%');
127
127
  }
128
128
  }
129
- if ((!isNullOrUndefined(e.requestType) && e.requestType.toString() === 'collapseAll') || this.isDataSourceChanged) {
129
+ if ((!isNullOrUndefined(e.requestType) && e.requestType.toString() === 'collapseAll') || (this.isDataSourceChanged && this.startIndex === -1)) {
130
130
  this.contents.scrollTop = 0;
131
131
  this.isDataSourceChanged = false;
132
132
  }