@syncfusion/ej2-treegrid 32.1.25 → 32.2.4

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.
@@ -1,5 +1,5 @@
1
1
  import { merge, Property, ChildProperty, Collection, isNullOrUndefined, Browser, removeClass, addClass, getValue, createElement, setValue, extend as extend$1, Internationalization, getEnumValue, compile, Component, L10n, EventHandler, KeyboardEvents, SanitizeHtmlHelper, Complex, Event, NotifyPropertyChanges, closest, setStyleAttribute, select, classList, debounce, remove } from '@syncfusion/ej2-base';
2
- import { Logger as Logger$1, Grid, detailLists, Clipboard, getObject, parentsUntil, Print as Print$1, templateCompiler, appendChildren, extend, CellRenderer, getUid, CellType, Freeze as Freeze$1, getNumberFormat, getActualProperties, iterateArrayOrObject, RowDropSettings as RowDropSettings$1, Reorder as Reorder$1, Resize as Resize$1, RowDD as RowDD$1, Scroll, VirtualRowModelGenerator, Filter as Filter$1, ExcelExport as ExcelExport$1, Data, ExportHelper, PdfExport as PdfExport$1, Page as Page$1, Toolbar as Toolbar$1, Aggregate as Aggregate$1, calculateAggregate, Sort as Sort$1, ColumnMenu as ColumnMenu$1, ContextMenu as ContextMenu$1, Edit as Edit$1, resetRowIndex, CommandColumn as CommandColumn$1, DetailRow as DetailRow$1, VirtualContentRenderer, Cell, getVisiblePage, InterSectionObserver, getTransformValues, VirtualScroll as VirtualScroll$1, RenderType, VirtualHeaderRenderer, ColumnChooser as ColumnChooser$1, InfiniteScroll as InfiniteScroll$1, RowRenderer } from '@syncfusion/ej2-grids';
2
+ import { Logger as Logger$1, Grid, detailLists, Clipboard, getObject, parentsUntil, Print as Print$1, templateCompiler, appendChildren, extend, CellRenderer, getUid, CellType, Freeze as Freeze$1, getNumberFormat, getActualProperties, iterateArrayOrObject, RowDropSettings as RowDropSettings$1, Reorder as Reorder$1, Resize as Resize$1, RowDD as RowDD$1, Scroll, VirtualRowModelGenerator, Filter as Filter$1, ExcelExport as ExcelExport$1, Data, ExportHelper, PdfExport as PdfExport$1, Page as Page$1, Toolbar as Toolbar$1, Aggregate as Aggregate$1, calculateAggregate, Sort as Sort$1, ColumnMenu as ColumnMenu$1, ContextMenu as ContextMenu$1, Edit as Edit$1, resetRowIndex, CommandColumn as CommandColumn$1, DetailRow as DetailRow$1, VirtualContentRenderer, Cell, getVisiblePage, InterSectionObserver, getTransformValues, VirtualScroll as VirtualScroll$1, RenderType, VirtualHeaderRenderer, ColumnChooser as ColumnChooser$1, InfiniteScroll as InfiniteScroll$1, getRowIndexFromElement, RowRenderer } from '@syncfusion/ej2-grids';
3
3
  import { createCheckBox } from '@syncfusion/ej2-buttons';
4
4
  import { DataManager, ODataAdaptor, WebApiAdaptor, WebMethodAdaptor, CacheAdaptor, UrlAdaptor, Query, DataUtil, RemoteSaveAdaptor, Deferred, JsonAdaptor, Predicate as Predicate$1 } from '@syncfusion/ej2-data';
5
5
  import { showSpinner, hideSpinner, createSpinner } from '@syncfusion/ej2-popups';
@@ -500,6 +500,8 @@ const ariaColIndex = 'aria-colindex';
500
500
  const ariaRowIndex = 'aria-rowindex';
501
501
  /** @hidden */
502
502
  const actionFailure = 'actionFailure';
503
+ /** @hidden */
504
+ const collapseActionComplete = 'collapseActionComplete';
503
505
 
504
506
  /**
505
507
  * The `Clipboard` module is used to handle clipboard copy action.
@@ -4035,6 +4037,7 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
4035
4037
  this.componentRefresh = Component.prototype.refresh;
4036
4038
  this.isComponentRefresh = false;
4037
4039
  this.isVirtualExpandCollapse = false;
4040
+ this.isInfiniteCollapse = false;
4038
4041
  this.objectEqualityChecker = (old, current) => {
4039
4042
  if (old) {
4040
4043
  const keys = Object.keys(old);
@@ -4906,12 +4909,12 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
4906
4909
  const checkboxColumn = this.columnModel.filter((col) => col.showCheckbox);
4907
4910
  const treeColumn = this.columns[this.treeColumnIndex];
4908
4911
  if (checkboxColumn.length !== 0) {
4909
- if (checkboxColumn !== treeColumn) {
4910
- failureCases.push('ShowCheckbox column should not be defined other than the tree column.');
4911
- }
4912
4912
  if (checkboxColumn.length > 1) {
4913
4913
  failureCases.push('Only one column can have the ShowCheckbox option enabled.');
4914
4914
  }
4915
+ else if (checkboxColumn[0].field !== treeColumn.field) {
4916
+ failureCases.push('ShowCheckbox column should not be defined other than the tree column.');
4917
+ }
4915
4918
  }
4916
4919
  let alignColumn;
4917
4920
  if (this.treeColumnIndex !== null && this.treeColumnIndex !== -1 && this.treeColumnIndex < this.columns.length) {
@@ -5531,6 +5534,12 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
5531
5534
  if (args.action === 'clearFilter' && this.enableCollapseAll) {
5532
5535
  this.collapseAll();
5533
5536
  }
5537
+ if (args.action === 'clearFilter' && this.enableInfiniteScrolling) {
5538
+ this.expandAll();
5539
+ }
5540
+ if (args.requestType === 'sorting' && this.enableInfiniteScrolling) {
5541
+ this.expandAll();
5542
+ }
5534
5543
  if (this.action === 'indenting' || this.action === 'outdenting') {
5535
5544
  this.action = this.action === 'indenting' ? 'indented' : 'outdented';
5536
5545
  const selectedItem = [this.selectedRecords];
@@ -7373,13 +7382,6 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
7373
7382
  else if (!this.isCollapseAll) {
7374
7383
  this.trigger(collapsed, collapseArgs);
7375
7384
  }
7376
- if (this.enableInfiniteScrolling) {
7377
- const scrollHeight = this.grid.getContent().firstElementChild.scrollHeight;
7378
- const scrollTop = this.grid.getContent().firstElementChild.scrollTop;
7379
- if ((scrollHeight - scrollTop) < this.grid.getRowHeight() + +this.height) {
7380
- this.grid.getContent().firstElementChild.scrollBy(0, this.grid.getRowHeight());
7381
- }
7382
- }
7383
7385
  }
7384
7386
  }
7385
7387
  updateExpandStateMapping(record, state) {
@@ -7754,10 +7756,13 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
7754
7756
  if ((!isCountRequired(this) || childRecords.length) || action === 'collapse') {
7755
7757
  this.localExpand(action, row, record);
7756
7758
  }
7759
+ if (this.enableInfiniteScrolling && action === 'collapse' && !this.isCollapseAll) {
7760
+ this.notify(collapseActionComplete, { isCollapse: true, data: record, row: row });
7761
+ }
7757
7762
  const lastrowIdx = this.getVisibleRecords()[this.getVisibleRecords().length - 1]['index'];
7758
7763
  const lastRow = this.getRowByIndex(lastrowIdx);
7759
7764
  const borderElement = lastRow ? lastRow.nextElementSibling ? lastRow.nextElementSibling.classList.contains('e-detailrow') ? lastRow.nextElementSibling : lastRow : lastRow : null;
7760
- if (this.grid.getContentTable().clientHeight <= this.grid.getContent().clientHeight && !isNullOrUndefined(borderElement) && !borderElement.cells[0].classList.contains('e-lastrowcell')) {
7765
+ if (!this.isInfiniteCollapse && this.grid.getContentTable().clientHeight <= this.grid.getContent().clientHeight && !isNullOrUndefined(borderElement) && !borderElement.cells[0].classList.contains('e-lastrowcell')) {
7761
7766
  this.lastRowBorder(borderElement, true);
7762
7767
  }
7763
7768
  }
@@ -7772,7 +7777,7 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
7772
7777
  targetEle.closest('.e-treerowcell').classList.remove('e-cellselectionbackground');
7773
7778
  targetEle.closest('.e-treerowcell').removeAttribute('aria-selected');
7774
7779
  }
7775
- if (this.isPixelHeight() && !row.cells[0].classList.contains('e-lastrowcell')) {
7780
+ if (this.isPixelHeight() && !row.cells[0].classList.contains('e-lastrowcell') && !this.isInfiniteCollapse) {
7776
7781
  let totalRows = this.getRows();
7777
7782
  const rows = this.getContentTable().rows;
7778
7783
  totalRows = [].slice.call(rows);
@@ -7789,6 +7794,7 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
7789
7794
  this.notify('rowExpandCollapse', { detailrows: detailrows, action: displayAction, record: record, row: row });
7790
7795
  this.updateAltRow(gridRows);
7791
7796
  }
7797
+ this.isInfiniteCollapse = false;
7792
7798
  }
7793
7799
  updateChildOnDemand(expandingArgs) {
7794
7800
  if (expandingArgs.requestType === 'collapse' && isCountRequired(this)) {
@@ -7920,9 +7926,15 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
7920
7926
  localExpand(action, row, record) {
7921
7927
  let rows;
7922
7928
  const detailRow = row.nextElementSibling ? row.nextElementSibling.classList.contains('e-detailrow') ? row.nextElementSibling : null : null;
7923
- const childRecords = this.grid.currentViewData.filter((e) => {
7924
- return e.parentUniqueID === record.uniqueID;
7925
- });
7929
+ let childRecords;
7930
+ if (this.enableInfiniteScrolling) {
7931
+ childRecords = this.grid.getRowsObject().filter((e) => { return e.data.parentUniqueID === record.uniqueID; });
7932
+ }
7933
+ else {
7934
+ childRecords = this.grid.currentViewData.filter((e) => {
7935
+ return e.parentUniqueID === record.uniqueID;
7936
+ });
7937
+ }
7926
7938
  if (this.isPixelHeight() && row.cells[0].classList.contains('e-lastrowcell')) {
7927
7939
  this.lastRowBorder(row, false);
7928
7940
  }
@@ -7956,9 +7968,9 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
7956
7968
  freezeRightRows = this.getRows().filter((r) => r.querySelector('.e-gridrowindex' + record.index + 'level' + (record.level + 1)));
7957
7969
  }
7958
7970
  const gridRowsObject = this.grid.getRowsObject();
7959
- const currentViewData = this.grid.currentViewData;
7971
+ const currentViewData = this.enableInfiniteScrolling ? this.grid.getRowsObject() : this.grid.currentViewData;
7960
7972
  const currentRecord = currentViewData.filter((e) => {
7961
- return e.uniqueID === record.uniqueID;
7973
+ return this.enableInfiniteScrolling ? e.data.uniqueID === record.uniqueID : e.uniqueID === record.uniqueID;
7962
7974
  });
7963
7975
  const currentIndex = currentViewData.indexOf(currentRecord[0]);
7964
7976
  if (!isNullOrUndefined(gridRowsObject[parseInt(currentIndex.toString(), 10)].visible) &&
@@ -12877,7 +12889,7 @@ class BatchEdit {
12877
12889
  return;
12878
12890
  }
12879
12891
  if (this.parent.editModule['isAddedRowByMethod'] && !isNullOrUndefined(this.parent.editModule['addRowIndex']) &&
12880
- !this.parent.editModule['isAddedRowByContextMenu'] && (this.parent.grid.selectedRowIndex === -1 || this.parent.editModule['batchEditModule'].isAdd)) {
12892
+ !this.parent.editModule['isAddedRowByContextMenu'] && (this.parent.editModule['selectedIndex'] >= 0 || this.parent.editModule['batchEditModule'].isAdd)) {
12881
12893
  this.selectedIndex = this.parent.editModule['selectedIndex'];
12882
12894
  this.addRowIndex = this.parent.editModule['addRowIndex'];
12883
12895
  this.addRowRecord = this.batchRecords.length ? this.batchRecords[this.selectedIndex]
@@ -13241,6 +13253,9 @@ class BatchEdit {
13241
13253
  if (this.parent.editModule['isAddedRowByContextMenu']) {
13242
13254
  this.parent.editModule['isAddedRowByContextMenu'] = false;
13243
13255
  }
13256
+ if (this.parent.editModule['isAddedRowByMethod']) {
13257
+ this.parent.editModule['isAddedRowByMethod'] = false;
13258
+ }
13244
13259
  }
13245
13260
  getActualRowObjectIndex(index) {
13246
13261
  const rows = this.parent.grid.getDataRows();
@@ -16164,6 +16179,10 @@ class InfiniteScroll {
16164
16179
  this.parent.grid.on('infinite-edit-handler', this.infiniteEditHandler, this);
16165
16180
  this.parent.grid.on('infinite-crud-cancel', this.createRows, this);
16166
16181
  this.parent.grid.on('content-ready', this.contentready, this);
16182
+ this.parent.on(collapseActionComplete, this.collapseActionComplete, this);
16183
+ this.parent.grid.on('data-ready', this.onDataReady, this);
16184
+ this.dataBoundFunction = this.dataBound.bind(this);
16185
+ this.parent.addEventListener(dataBound, this.dataBoundFunction);
16167
16186
  }
16168
16187
  /**
16169
16188
  * @hidden
@@ -16179,6 +16198,53 @@ class InfiniteScroll {
16179
16198
  this.parent.off(pagingActions, this.infinitePageAction);
16180
16199
  this.parent.grid.off('infinite-crud-cancel', this.createRows);
16181
16200
  this.parent.grid.off('content-ready', this.contentready);
16201
+ this.parent.off(collapseActionComplete, this.collapseActionComplete);
16202
+ this.parent.grid.off('data-ready', this.onDataReady);
16203
+ this.parent.removeEventListener(dataBound, this.dataBoundFunction);
16204
+ }
16205
+ dataBound() {
16206
+ if (this.treeAction === 'collapse') {
16207
+ this.treeAction = 'refresh';
16208
+ this.makeCollapseRequest();
16209
+ }
16210
+ else if (this.treeAction === 'refresh') {
16211
+ this.treeAction = null;
16212
+ }
16213
+ }
16214
+ onDataReady(e) {
16215
+ if (!isNullOrUndefined(e.count) && e.requestType !== 'infiniteScroll') {
16216
+ this.maxPage = Math.ceil(e.count / this.parent.pageSettings.pageSize);
16217
+ }
16218
+ }
16219
+ collapseActionComplete(args) {
16220
+ if (!this.parent.infiniteScrollSettings.enableCache && args.isCollapse) {
16221
+ const contentBounds = this.parent.getContent().firstElementChild.getBoundingClientRect();
16222
+ const tableBounds = this.parent.grid.contentModule.getTable().getBoundingClientRect();
16223
+ if (Math.round(tableBounds.bottom - this.parent.grid.getRowHeight()) <= Math.round(contentBounds.bottom)) {
16224
+ this.treeAction = 'collapse';
16225
+ this.collapsedData = args.data;
16226
+ this.makeCollapseRequest(args);
16227
+ }
16228
+ }
16229
+ }
16230
+ makeCollapseRequest(args) {
16231
+ const rows = this.parent.getRows();
16232
+ const index = getRowIndexFromElement(rows[rows.length - 1]);
16233
+ const previousPage = this.parent.grid.pageSettings.currentPage;
16234
+ const nextPage = Math.ceil(index / this.parent.grid.pageSettings.pageSize) + 1;
16235
+ if ((previousPage >= this.maxPage) || (nextPage > this.maxPage)) {
16236
+ return;
16237
+ }
16238
+ this.parent.grid.pageSettings.currentPage = nextPage;
16239
+ this.parent['isInfiniteCollapse'] = true;
16240
+ const scrollArg = {
16241
+ requestType: 'infiniteScroll',
16242
+ currentPage: this.parent.grid.pageSettings.currentPage,
16243
+ prevPage: previousPage,
16244
+ startIndex: index + 1,
16245
+ direction: 'down'
16246
+ };
16247
+ this.parent.grid.notify('model-changed', scrollArg);
16182
16248
  }
16183
16249
  /**
16184
16250
  * Handles the Expand Collapse action for Remote data with infinite scrolling.
@@ -16269,7 +16335,12 @@ class InfiniteScroll {
16269
16335
  if (!isCache && actionArgs.requestType === 'delete') {
16270
16336
  const skip = lastIndex - actionArgs.data.length + 1;
16271
16337
  const take = actionArgs.data.length;
16272
- query = query.skip(skip).take(take);
16338
+ if (skip < 0) {
16339
+ query = query.take(take);
16340
+ }
16341
+ else {
16342
+ query = query.skip(skip).take(take);
16343
+ }
16273
16344
  }
16274
16345
  else if (isCache && actionArgs.requestType === 'delete' ||
16275
16346
  (actionArgs.requestType === 'save' && actionArgs.action === 'add')) {
@@ -16277,13 +16348,36 @@ class InfiniteScroll {
16277
16348
  query = query.take(this.parent.infiniteScrollSettings.initialBlocks * this.parent.pageSettings.pageSize);
16278
16349
  }
16279
16350
  else {
16280
- query = query.page(current, size);
16351
+ if (this.treeAction !== 'collapse' && this.treeAction !== 'refresh') {
16352
+ query = query.page(current, size);
16353
+ }
16281
16354
  }
16282
16355
  }
16283
16356
  else {
16284
16357
  query = query.page(current, size);
16285
16358
  }
16286
16359
  dm.dataSource.json = visualData;
16360
+ if (this.treeAction === 'collapse') {
16361
+ const rows = this.parent.getRows();
16362
+ const skip = getRowIndexFromElement(rows[rows.length - 1]) + 1;
16363
+ query = query.skip(skip);
16364
+ const renderedChildDataCount = this.parent.grid.getRowsObject().filter((record) => {
16365
+ return record.data.parentUniqueID === this.collapsedData.uniqueID;
16366
+ }).length;
16367
+ const remainingChildDataCount = this.collapsedData.childRecords.length - renderedChildDataCount;
16368
+ if (remainingChildDataCount > 0) {
16369
+ query = query.take(Math.max(remainingChildDataCount, 0));
16370
+ }
16371
+ else {
16372
+ query = query.take(this.parent.pageSettings.pageSize);
16373
+ }
16374
+ }
16375
+ else if (this.treeAction === 'refresh') {
16376
+ const rows = this.parent.getRows();
16377
+ const skip = getRowIndexFromElement(rows[rows.length - 1]) + 1;
16378
+ query = query.skip(skip);
16379
+ query = query.take(this.parent.infiniteScrollSettings.initialBlocks * this.parent.pageSettings.pageSize);
16380
+ }
16287
16381
  if (!isCache && !isNullOrUndefined(actionArgs) && actionArgs.requestType === 'save' && actionArgs.action === 'add') {
16288
16382
  pageingDetails.result = [actionArgs.data];
16289
16383
  }
@@ -16430,5 +16524,5 @@ class InfiniteScroll {
16430
16524
  }
16431
16525
  }
16432
16526
 
16433
- export { Aggregate, AggregateColumn, AggregateRow, Column, ColumnChooser, ColumnMenu, CommandColumn, ContextMenu, ContextMenuItems, DataManipulation, DetailRow, Edit, EditSettings, ExcelExport, Filter, FilterSettings, Freeze, InfiniteScroll, InfiniteScrollSettings, LoadingIndicator, Logger, Page, PageSettings, PdfExport, Predicate, Render, Reorder, Resize, RowDD, RowDropSettings, SearchSettings, Selection, SelectionSettings, Sort, SortDescriptor, SortSettings, StackedColumn, Toolbar, ToolbarItem, TreeClipboard, TreeGrid, TreeGridColumn, TreeVirtual, TreeVirtualRowModelGenerator, VirtualScroll, actionBegin, actionComplete, actionFailure, ariaColIndex, ariaRowIndex, autoCol, batchAdd, batchCancel, batchDelete, batchEditFormRendered, batchSave, beforeBatchAdd, beforeBatchCancel, beforeBatchDelete, beforeBatchSave, beforeCopy, beforeDataBound, beforeExcelExport, beforePaste, beforePdfExport, beforeStartEdit, beginAdd, beginEdit, cellEdit, cellSave, cellSaved, checkboxChange, collapsed, collapsing, content, contextMenuClick, contextMenuOpen, crudAction, dataBound, dataListener, dataStateChange, destroy, detailDataBound, doubleTap, expanded, expanding, extendArray, findChildrenRecords, findParentRecords, frozenContent, frozenHeader, frozenLeft, frozenRight, getExpandStatus, getParentData, getPlainData, headerContent, indexModifier, isCheckboxcolumn, isCountRequired, isFilterChildHierarchy, isHidden, isOffline, isRemoteData, keyPressed, leftRight, load, localPagedExpandCollapse, movableContent, movableHeader, pagingActions, printGridInit, queryCellInfo, recordDoubleClick, remoteExpand, resizeStop, rowDataBound, rowDeselected, rowDeselecting, rowDrag, rowDragStart, rowDragStartHelper, rowDrop, rowDropped, rowSelected, rowSelecting, rowdraging, rowsAdd, rowsRemove, savePreviousRowPosition, table, toolbarClick, treeGridDetails, updateData, virtualActionArgs, virtualColumnIndex };
16527
+ export { Aggregate, AggregateColumn, AggregateRow, Column, ColumnChooser, ColumnMenu, CommandColumn, ContextMenu, ContextMenuItems, DataManipulation, DetailRow, Edit, EditSettings, ExcelExport, Filter, FilterSettings, Freeze, InfiniteScroll, InfiniteScrollSettings, LoadingIndicator, Logger, Page, PageSettings, PdfExport, Predicate, Render, Reorder, Resize, RowDD, RowDropSettings, SearchSettings, Selection, SelectionSettings, Sort, SortDescriptor, SortSettings, StackedColumn, Toolbar, ToolbarItem, TreeClipboard, TreeGrid, TreeGridColumn, TreeVirtual, TreeVirtualRowModelGenerator, VirtualScroll, actionBegin, actionComplete, actionFailure, ariaColIndex, ariaRowIndex, autoCol, batchAdd, batchCancel, batchDelete, batchEditFormRendered, batchSave, beforeBatchAdd, beforeBatchCancel, beforeBatchDelete, beforeBatchSave, beforeCopy, beforeDataBound, beforeExcelExport, beforePaste, beforePdfExport, beforeStartEdit, beginAdd, beginEdit, cellEdit, cellSave, cellSaved, checkboxChange, collapseActionComplete, collapsed, collapsing, content, contextMenuClick, contextMenuOpen, crudAction, dataBound, dataListener, dataStateChange, destroy, detailDataBound, doubleTap, expanded, expanding, extendArray, findChildrenRecords, findParentRecords, frozenContent, frozenHeader, frozenLeft, frozenRight, getExpandStatus, getParentData, getPlainData, headerContent, indexModifier, isCheckboxcolumn, isCountRequired, isFilterChildHierarchy, isHidden, isOffline, isRemoteData, keyPressed, leftRight, load, localPagedExpandCollapse, movableContent, movableHeader, pagingActions, printGridInit, queryCellInfo, recordDoubleClick, remoteExpand, resizeStop, rowDataBound, rowDeselected, rowDeselecting, rowDrag, rowDragStart, rowDragStartHelper, rowDrop, rowDropped, rowSelected, rowSelecting, rowdraging, rowsAdd, rowsRemove, savePreviousRowPosition, table, toolbarClick, treeGridDetails, updateData, virtualActionArgs, virtualColumnIndex };
16434
16528
  //# sourceMappingURL=ej2-treegrid.es2015.js.map