@syncfusion/ej2-treegrid 20.1.47 → 20.1.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/ej2-treegrid.umd.min.js +2 -2
  3. package/dist/ej2-treegrid.umd.min.js.map +1 -1
  4. package/dist/es6/ej2-treegrid.es2015.js +74 -39
  5. package/dist/es6/ej2-treegrid.es2015.js.map +1 -1
  6. package/dist/es6/ej2-treegrid.es5.js +77 -46
  7. package/dist/es6/ej2-treegrid.es5.js.map +1 -1
  8. package/dist/global/ej2-treegrid.min.js +2 -2
  9. package/dist/global/ej2-treegrid.min.js.map +1 -1
  10. package/dist/global/index.d.ts +1 -1
  11. package/package.json +7 -7
  12. package/src/treegrid/actions/batch-edit.js +21 -4
  13. package/src/treegrid/actions/edit.js +15 -0
  14. package/src/treegrid/actions/filter.js +3 -0
  15. package/src/treegrid/actions/rowdragdrop.js +4 -9
  16. package/src/treegrid/base/treegrid-model.d.ts +1 -1
  17. package/src/treegrid/base/treegrid.d.ts +1 -6
  18. package/src/treegrid/base/treegrid.js +34 -33
  19. package/styles/bootstrap-dark.css +0 -8
  20. package/styles/bootstrap.css +0 -8
  21. package/styles/bootstrap4.css +0 -8
  22. package/styles/bootstrap5-dark.css +0 -8
  23. package/styles/bootstrap5.css +0 -8
  24. package/styles/fabric-dark.css +0 -8
  25. package/styles/fabric.css +0 -8
  26. package/styles/fluent-dark.css +1 -5
  27. package/styles/fluent.css +1 -5
  28. package/styles/highcontrast-light.css +0 -8
  29. package/styles/highcontrast.css +0 -8
  30. package/styles/material-dark.css +0 -8
  31. package/styles/material.css +0 -8
  32. package/styles/tailwind-dark.css +0 -8
  33. package/styles/tailwind.css +0 -8
  34. package/styles/treegrid/_bootstrap-dark-definition.scss +0 -2
  35. package/styles/treegrid/_bootstrap-definition.scss +0 -2
  36. package/styles/treegrid/_bootstrap4-definition.scss +0 -2
  37. package/styles/treegrid/_bootstrap5-definition.scss +0 -2
  38. package/styles/treegrid/_fabric-dark-definition.scss +0 -2
  39. package/styles/treegrid/_fabric-definition.scss +0 -2
  40. package/styles/treegrid/_fluent-definition.scss +0 -1
  41. package/styles/treegrid/_highcontrast-definition.scss +0 -2
  42. package/styles/treegrid/_highcontrast-light-definition.scss +0 -2
  43. package/styles/treegrid/_layout.scss +4 -6
  44. package/styles/treegrid/_material-dark-definition.scss +0 -2
  45. package/styles/treegrid/_material-definition.scss +0 -2
  46. package/styles/treegrid/_tailwind-definition.scss +0 -2
  47. package/styles/treegrid/bootstrap-dark.css +0 -8
  48. package/styles/treegrid/bootstrap.css +0 -8
  49. package/styles/treegrid/bootstrap4.css +0 -8
  50. package/styles/treegrid/bootstrap5-dark.css +0 -8
  51. package/styles/treegrid/bootstrap5.css +0 -8
  52. package/styles/treegrid/fabric-dark.css +0 -8
  53. package/styles/treegrid/fabric.css +0 -8
  54. package/styles/treegrid/fluent-dark.css +1 -5
  55. package/styles/treegrid/fluent.css +1 -5
  56. package/styles/treegrid/highcontrast-light.css +0 -8
  57. package/styles/treegrid/highcontrast.css +0 -8
  58. package/styles/treegrid/material-dark.css +0 -8
  59. package/styles/treegrid/material.css +0 -8
  60. package/styles/treegrid/tailwind-dark.css +0 -8
  61. package/styles/treegrid/tailwind.css +0 -8
@@ -1,5 +1,5 @@
1
1
  import { Browser, ChildProperty, Collection, Complex, Component, Event, EventHandler, Internationalization, KeyboardEvents, L10n, NotifyPropertyChanges, Property, addClass, classList, closest, compile, createElement, debounce, extend, getEnumValue, getValue, isNullOrUndefined, merge, remove, removeClass, select, setStyleAttribute, setValue } from '@syncfusion/ej2-base';
2
- import { Aggregate, Cell, CellRenderer, CellType, Clipboard, ColumnChooser, ColumnMenu, CommandColumn, ContextMenu, DetailRow, Edit, ExcelExport, Filter, Freeze, Grid, InfiniteScroll, InterSectionObserver, Logger, Page, PdfExport, Print, RenderType, Reorder, Resize, RowDD, RowDropSettings, RowRenderer, Scroll, Sort, Toolbar, VirtualContentRenderer, VirtualHeaderRenderer, VirtualRowModelGenerator, VirtualScroll, appendChildren, calculateAggregate, detailLists, extend as extend$1, getActualProperties, getObject, getUid, iterateArrayOrObject, parentsUntil, resetRowIndex, templateCompiler } from '@syncfusion/ej2-grids';
2
+ import { Aggregate, Cell, CellType, Clipboard, ColumnChooser, ColumnMenu, CommandColumn, ContextMenu, DetailRow, Edit, ExcelExport, Filter, Freeze, Grid, InfiniteScroll, InterSectionObserver, Logger, Page, PdfExport, Print, RenderType, Reorder, Resize, RowDD, RowDropSettings, RowRenderer, Scroll, Sort, Toolbar, VirtualContentRenderer, VirtualHeaderRenderer, VirtualRowModelGenerator, VirtualScroll, appendChildren, calculateAggregate, detailLists, extend as extend$1, getActualProperties, getObject, getUid, iterateArrayOrObject, parentsUntil, resetRowIndex, templateCompiler } from '@syncfusion/ej2-grids';
3
3
  import { createCheckBox } from '@syncfusion/ej2-buttons';
4
4
  import { CacheAdaptor, DataManager, DataUtil, Deferred, JsonAdaptor, ODataAdaptor, Predicate, Query, RemoteSaveAdaptor, UrlAdaptor, WebApiAdaptor, WebMethodAdaptor } from '@syncfusion/ej2-data';
5
5
  import { createSpinner, hideSpinner, showSpinner } from '@syncfusion/ej2-popups';
@@ -2765,9 +2765,7 @@ class RowDD$1 {
2765
2765
  for (let i = 0; i < currentData.length; i++) {
2766
2766
  currentData[i].index = i;
2767
2767
  if (!isNullOrUndefined(currentData[i].parentItem)) {
2768
- const updatedParent = currentData.filter((data) => {
2769
- return data.uniqueID === currentData[i].parentUniqueID;
2770
- })[0];
2768
+ const updatedParent = getValue('uniqueIDCollection.' + currentData[i].parentUniqueID, this.parent);
2771
2769
  currentData[i].parentItem.index = updatedParent.index;
2772
2770
  }
2773
2771
  }
@@ -5996,10 +5994,13 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
5996
5994
  rowData.parentUniqueID = record.parentUniqueID;
5997
5995
  rowData.expanded = record.expanded;
5998
5996
  this.grid.setRowData(key, rowData);
5999
- const table = this.getContentTable();
6000
- const sHeight = table.scrollHeight;
6001
- const clientHeight = this.getContent().clientHeight;
6002
- this.lastRowBorder(this.getRows()[record.index], sHeight <= clientHeight);
5997
+ const visibleRecords = this.getVisibleRecords();
5998
+ if (visibleRecords.length > 0 && key === (visibleRecords[visibleRecords.length - 1])[primaryKey]) {
5999
+ const table = this.getContentTable();
6000
+ const sHeight = table.scrollHeight;
6001
+ const clientHeight = this.getContent().clientHeight;
6002
+ this.lastRowBorder(this.getRows()[currentRecords.indexOf(record)], sHeight <= clientHeight);
6003
+ }
6003
6004
  }
6004
6005
  /**
6005
6006
  * Navigates to the specified target page.
@@ -6208,31 +6209,6 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
6208
6209
  this[merge$$1] = undefined; // Workaround for blazor updateModel
6209
6210
  return this.columnModel;
6210
6211
  }
6211
- /**
6212
- * @param {string} columnUid - Defines column uid
6213
- * @returns {void}
6214
- * @hidden
6215
- */
6216
- refreshReactColumnTemplateByUid(columnUid) {
6217
- if (this.isReact) {
6218
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
6219
- this.clearTemplate(['columnTemplate'], undefined, () => {
6220
- const cells = 'cells';
6221
- const rowIdx = 'index';
6222
- const rowsObj = this.grid.getRowsObject();
6223
- const indent = this.grid.getIndentCount();
6224
- const cellIndex = this.grid.getNormalizedColumnIndex(columnUid);
6225
- for (let j = 0; j < rowsObj.length; j++) {
6226
- if (rowsObj[j].isDataRow && !isNullOrUndefined(rowsObj[j].index)) {
6227
- const cell = rowsObj[j][cells][cellIndex];
6228
- const cellRenderer = new CellRenderer(this.grid, this.grid.serviceLocator);
6229
- const td = this.getCellFromIndex(rowsObj[j].index, cellIndex - indent);
6230
- cellRenderer.refreshTD(td, cell, rowsObj[j].data, { index: rowsObj[j][rowIdx] });
6231
- }
6232
- }
6233
- });
6234
- }
6235
- }
6236
6212
  /**
6237
6213
  * Gets the content div of the TreeGrid.
6238
6214
  *
@@ -6377,8 +6353,14 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
6377
6353
  this.uniqueIDCollection = {};
6378
6354
  this.convertTreeData(this.dataSource);
6379
6355
  if (!isCountRequired(this)) {
6380
- this.grid.dataSource = !(this.dataSource instanceof DataManager) ? this.flatData :
6381
- new DataManager(this.dataSource.dataSource, this.dataSource.defaultQuery, this.dataSource.adaptor);
6356
+ if (!(this.dataSource instanceof DataManager)) {
6357
+ this.grid.dataSource = this.flatData;
6358
+ }
6359
+ else {
6360
+ this.grid.setProperties({
6361
+ dataSource: new DataManager(this.dataSource.dataSource, this.dataSource.defaultQuery, this.dataSource.adaptor)
6362
+ }, true);
6363
+ }
6382
6364
  }
6383
6365
  this.grid.refresh();
6384
6366
  }
@@ -6521,6 +6503,9 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
6521
6503
  if (!(isRemoteData(this) && !isOffline(this)) && (!isCountRequired(this) || !isNullOrUndefined(record[children]))) {
6522
6504
  const collapseArgs = { data: record, row: row };
6523
6505
  this.setHeightForFrozenContent();
6506
+ if (!isNullOrUndefined(this.expandStateMapping)) {
6507
+ this.updateExpandStateMapping(collapseArgs.data, true);
6508
+ }
6524
6509
  this.trigger(expanded, collapseArgs);
6525
6510
  }
6526
6511
  }
@@ -6582,6 +6567,9 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
6582
6567
  const collapseArgs = { data: record, row: row };
6583
6568
  if (!isRemoteData(this)) {
6584
6569
  this.setHeightForFrozenContent();
6570
+ if (!isNullOrUndefined(this.expandStateMapping)) {
6571
+ this.updateExpandStateMapping(collapseArgs.data, false);
6572
+ }
6585
6573
  this.trigger(collapsed, collapseArgs);
6586
6574
  if (this.enableInfiniteScrolling) {
6587
6575
  const scrollHeight = this.grid.getContent().firstElementChild.scrollHeight;
@@ -6594,6 +6582,19 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
6594
6582
  }
6595
6583
  });
6596
6584
  }
6585
+ updateExpandStateMapping(record, state) {
6586
+ const totalRecords = record;
6587
+ if (totalRecords.length) {
6588
+ for (let i = 0; i < totalRecords.length; i++) {
6589
+ totalRecords[i][this.expandStateMapping] = state;
6590
+ editAction({ value: totalRecords[i], action: 'edit' }, this, this.isSelfReference, totalRecords[i].index, this.grid.selectedRowIndex, this.expandStateMapping);
6591
+ }
6592
+ }
6593
+ else {
6594
+ record[this.expandStateMapping] = state;
6595
+ editAction({ value: record, action: 'edit' }, this, this.isSelfReference, record.index, this.grid.selectedRowIndex, this.expandStateMapping);
6596
+ }
6597
+ }
6597
6598
  /**
6598
6599
  * Expands the records at specific hierarchical level
6599
6600
  *
@@ -8247,6 +8248,9 @@ class Filter$1 {
8247
8248
  }
8248
8249
  }
8249
8250
  else {
8251
+ if (parent['expanded'] === false && this.parent.getVisibleRecords().indexOf(record) === -1 && isNullOrUndefined(this.parent['dataResults']['action'])) {
8252
+ this.parent.expandRow(this.parent.getRows()[parent['index']], parent);
8253
+ }
8250
8254
  this.addParentRecord(parent);
8251
8255
  }
8252
8256
  }
@@ -9735,9 +9739,17 @@ class BatchEdit {
9735
9739
  this.parent.editModule[isTabLastRow] = false;
9736
9740
  return;
9737
9741
  }
9738
- this.selectedIndex = this.parent.grid.selectedRowIndex;
9739
- this.addRowIndex = this.parent.grid.selectedRowIndex > -1 ? this.parent.grid.selectedRowIndex : 0;
9740
- this.addRowRecord = this.parent.getSelectedRecords()[0];
9742
+ if (this.parent.editModule['isAddedRowByMethod'] && !isNullOrUndefined(this.parent.editModule['addRowIndex']) && this.parent.grid.selectedRowIndex === -1) {
9743
+ this.selectedIndex = this.parent.editModule['selectedIndex'];
9744
+ this.addRowIndex = this.parent.editModule['addRowIndex'];
9745
+ this.addRowRecord = this.parent.getCurrentViewRecords()[this.selectedIndex];
9746
+ }
9747
+ else {
9748
+ this.selectedIndex = this.parent.grid.selectedRowIndex;
9749
+ this.addRowIndex = this.parent.grid.selectedRowIndex > -1 ? this.parent.grid.selectedRowIndex : 0;
9750
+ this.parent.editModule['addRowIndex'] = this.parent.grid.selectedRowIndex > -1 ? this.parent.grid.selectedRowIndex : 0;
9751
+ this.addRowRecord = this.parent.getSelectedRecords()[0];
9752
+ }
9741
9753
  }
9742
9754
  batchAdd(e) {
9743
9755
  if (this.parent.editSettings.newRowPosition !== 'Bottom') {
@@ -9749,6 +9761,9 @@ class BatchEdit {
9749
9761
  this.batchRecords = extendArray(this.parent.grid.getCurrentViewRecords());
9750
9762
  this.currentViewRecords = extendArray(this.parent.grid.getCurrentViewRecords());
9751
9763
  }
9764
+ if (this.parent.editModule['isAddedRowByMethod'] && !isNullOrUndefined(this.parent.editModule['addRowIndex'])) {
9765
+ classList(this.parent.grid.getDataRows()[0], ['e-batchrow'], []);
9766
+ }
9752
9767
  if (this.parent.editSettings.newRowPosition !== 'Top') {
9753
9768
  let records = this.parent.grid.getCurrentViewRecords();
9754
9769
  if (this.parent.editSettings.mode === 'Batch' && (this.parent.getBatchChanges()[this.addedRecords].length > 1
@@ -9972,6 +9987,10 @@ class BatchEdit {
9972
9987
  }
9973
9988
  if (this.parent.editSettings.newRowPosition !== 'Bottom' && !Object.hasOwnProperty.call(args, 'updatedRecords')) {
9974
9989
  data.splice(data.length - addRecords.length, addRecords.length);
9990
+ if (this.parent.editModule['isAddedRowByMethod'] && addRecords.length && !isNullOrUndefined(this.parent.editModule['addRowIndex'])) {
9991
+ const index = parseInt(this.parent.getContentTable().getElementsByClassName('e-insertedrow')[0].ariaRowIndex);
9992
+ data.splice(index, 0, addRecords[0]);
9993
+ }
9975
9994
  if (!this.parent.allowPaging && data.length !== currentViewRecords.length) {
9976
9995
  if (currentViewRecords.length > addRecords.length) {
9977
9996
  currentViewRecords.splice(currentViewRecords.length - addRecords.length, addRecords.length);
@@ -10023,7 +10042,8 @@ class BatchEdit {
10023
10042
  }
10024
10043
  editAction({ value: addRecords[i], action: 'add' }, this.parent, this.isSelfReference, addRowIndex, selectedIndex, columnName, addRowRecord);
10025
10044
  selectedIndex = null;
10026
- if (this.parent.editSettings.newRowPosition === 'Child' && !isNullOrUndefined(addRecords[i][parentItem])) {
10045
+ if (this.parent.editSettings.newRowPosition === 'Child' && !isNullOrUndefined(addRecords[i][parentItem]) &&
10046
+ (isNullOrUndefined(this.parent.editModule['addRowIndex']) || this.isSelfReference)) {
10027
10047
  const indexValue = currentViewRecords.map((e) => { return e[primarykey]; })
10028
10048
  .indexOf(addRecords[i][parentItem][primarykey]);
10029
10049
  const children = currentViewRecords[indexValue][childRecords];
@@ -10765,6 +10785,21 @@ class Edit$1 {
10765
10785
  focussedElement.focus();
10766
10786
  }
10767
10787
  }
10788
+ if (this.parent.editSettings.mode === 'Batch' && !isNullOrUndefined(this.addRowIndex) && this.addRowIndex !== -1) {
10789
+ index = this.batchEditModule.getAddRowIndex();
10790
+ this.selectedIndex = this.batchEditModule.getSelectedIndex();
10791
+ if (this.parent.editModule['isAddedRowByMethod']) {
10792
+ const args = {
10793
+ action: "add",
10794
+ data: this.parent.getBatchChanges()['addedRecords'][0],
10795
+ index: index,
10796
+ seletedRow: 0
10797
+ };
10798
+ this.parent.editModule.beginAddEdit(args);
10799
+ this.parent.editModule.batchEditModule['batchAddRowRecord'].push(this.parent.editModule.batchEditModule['addRowRecord']);
10800
+ this.parent.editModule.batchEditModule['batchAddedRecords'].push(args['data']);
10801
+ }
10802
+ }
10768
10803
  }
10769
10804
  // private beforeDataBound(args: BeforeDataBoundArgs): void {
10770
10805
  // if (this.parent.grid.isEdit && this.parent.dataSource instanceof DataManager &&