@syncfusion/ej2-treegrid 32.1.25 → 32.2.3

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) &&
@@ -16164,6 +16176,10 @@ class InfiniteScroll {
16164
16176
  this.parent.grid.on('infinite-edit-handler', this.infiniteEditHandler, this);
16165
16177
  this.parent.grid.on('infinite-crud-cancel', this.createRows, this);
16166
16178
  this.parent.grid.on('content-ready', this.contentready, this);
16179
+ this.parent.on(collapseActionComplete, this.collapseActionComplete, this);
16180
+ this.parent.grid.on('data-ready', this.onDataReady, this);
16181
+ this.dataBoundFunction = this.dataBound.bind(this);
16182
+ this.parent.addEventListener(dataBound, this.dataBoundFunction);
16167
16183
  }
16168
16184
  /**
16169
16185
  * @hidden
@@ -16179,6 +16195,53 @@ class InfiniteScroll {
16179
16195
  this.parent.off(pagingActions, this.infinitePageAction);
16180
16196
  this.parent.grid.off('infinite-crud-cancel', this.createRows);
16181
16197
  this.parent.grid.off('content-ready', this.contentready);
16198
+ this.parent.off(collapseActionComplete, this.collapseActionComplete);
16199
+ this.parent.grid.off('data-ready', this.onDataReady);
16200
+ this.parent.removeEventListener(dataBound, this.dataBoundFunction);
16201
+ }
16202
+ dataBound() {
16203
+ if (this.treeAction === 'collapse') {
16204
+ this.treeAction = 'refresh';
16205
+ this.makeCollapseRequest();
16206
+ }
16207
+ else if (this.treeAction === 'refresh') {
16208
+ this.treeAction = null;
16209
+ }
16210
+ }
16211
+ onDataReady(e) {
16212
+ if (!isNullOrUndefined(e.count) && e.requestType !== 'infiniteScroll') {
16213
+ this.maxPage = Math.ceil(e.count / this.parent.pageSettings.pageSize);
16214
+ }
16215
+ }
16216
+ collapseActionComplete(args) {
16217
+ if (!this.parent.infiniteScrollSettings.enableCache && args.isCollapse) {
16218
+ const contentBounds = this.parent.getContent().firstElementChild.getBoundingClientRect();
16219
+ const tableBounds = this.parent.grid.contentModule.getTable().getBoundingClientRect();
16220
+ if (Math.round(tableBounds.bottom - this.parent.grid.getRowHeight()) <= Math.round(contentBounds.bottom)) {
16221
+ this.treeAction = 'collapse';
16222
+ this.collapsedData = args.data;
16223
+ this.makeCollapseRequest(args);
16224
+ }
16225
+ }
16226
+ }
16227
+ makeCollapseRequest(args) {
16228
+ const rows = this.parent.getRows();
16229
+ const index = getRowIndexFromElement(rows[rows.length - 1]);
16230
+ const previousPage = this.parent.grid.pageSettings.currentPage;
16231
+ const nextPage = Math.ceil(index / this.parent.grid.pageSettings.pageSize) + 1;
16232
+ if ((previousPage >= this.maxPage) || (nextPage > this.maxPage)) {
16233
+ return;
16234
+ }
16235
+ this.parent.grid.pageSettings.currentPage = nextPage;
16236
+ this.parent['isInfiniteCollapse'] = true;
16237
+ const scrollArg = {
16238
+ requestType: 'infiniteScroll',
16239
+ currentPage: this.parent.grid.pageSettings.currentPage,
16240
+ prevPage: previousPage,
16241
+ startIndex: index + 1,
16242
+ direction: 'down'
16243
+ };
16244
+ this.parent.grid.notify('model-changed', scrollArg);
16182
16245
  }
16183
16246
  /**
16184
16247
  * Handles the Expand Collapse action for Remote data with infinite scrolling.
@@ -16269,7 +16332,12 @@ class InfiniteScroll {
16269
16332
  if (!isCache && actionArgs.requestType === 'delete') {
16270
16333
  const skip = lastIndex - actionArgs.data.length + 1;
16271
16334
  const take = actionArgs.data.length;
16272
- query = query.skip(skip).take(take);
16335
+ if (skip < 0) {
16336
+ query = query.take(take);
16337
+ }
16338
+ else {
16339
+ query = query.skip(skip).take(take);
16340
+ }
16273
16341
  }
16274
16342
  else if (isCache && actionArgs.requestType === 'delete' ||
16275
16343
  (actionArgs.requestType === 'save' && actionArgs.action === 'add')) {
@@ -16277,13 +16345,36 @@ class InfiniteScroll {
16277
16345
  query = query.take(this.parent.infiniteScrollSettings.initialBlocks * this.parent.pageSettings.pageSize);
16278
16346
  }
16279
16347
  else {
16280
- query = query.page(current, size);
16348
+ if (this.treeAction !== 'collapse' && this.treeAction !== 'refresh') {
16349
+ query = query.page(current, size);
16350
+ }
16281
16351
  }
16282
16352
  }
16283
16353
  else {
16284
16354
  query = query.page(current, size);
16285
16355
  }
16286
16356
  dm.dataSource.json = visualData;
16357
+ if (this.treeAction === 'collapse') {
16358
+ const rows = this.parent.getRows();
16359
+ const skip = getRowIndexFromElement(rows[rows.length - 1]) + 1;
16360
+ query = query.skip(skip);
16361
+ const renderedChildDataCount = this.parent.grid.getRowsObject().filter((record) => {
16362
+ return record.data.parentUniqueID === this.collapsedData.uniqueID;
16363
+ }).length;
16364
+ const remainingChildDataCount = this.collapsedData.childRecords.length - renderedChildDataCount;
16365
+ if (remainingChildDataCount > 0) {
16366
+ query = query.take(Math.max(remainingChildDataCount, 0));
16367
+ }
16368
+ else {
16369
+ query = query.take(this.parent.pageSettings.pageSize);
16370
+ }
16371
+ }
16372
+ else if (this.treeAction === 'refresh') {
16373
+ const rows = this.parent.getRows();
16374
+ const skip = getRowIndexFromElement(rows[rows.length - 1]) + 1;
16375
+ query = query.skip(skip);
16376
+ query = query.take(this.parent.infiniteScrollSettings.initialBlocks * this.parent.pageSettings.pageSize);
16377
+ }
16287
16378
  if (!isCache && !isNullOrUndefined(actionArgs) && actionArgs.requestType === 'save' && actionArgs.action === 'add') {
16288
16379
  pageingDetails.result = [actionArgs.data];
16289
16380
  }
@@ -16430,5 +16521,5 @@ class InfiniteScroll {
16430
16521
  }
16431
16522
  }
16432
16523
 
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 };
16524
+ 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
16525
  //# sourceMappingURL=ej2-treegrid.es2015.js.map