angular-slickgrid 4.2.2 → 4.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.
@@ -178,6 +178,9 @@ class ContainerService {
178
178
  }
179
179
  return null;
180
180
  }
181
+ dispose() {
182
+ this.dependencies = [];
183
+ }
181
184
  registerInstance(key, instance) {
182
185
  const dependency = this.dependencies.some(dep => dep.key === key);
183
186
  if (!dependency) {
@@ -930,6 +933,7 @@ class AngularSlickgridComponent {
930
933
  this.gridService = externalServices?.gridService ?? new GridService(this.gridStateService, this.filterService, this._eventPubSubService, this.paginationService, this.sharedService, this.sortService, this.treeDataService);
931
934
  this.groupingService = externalServices?.groupingAndColspanService ?? new GroupingAndColspanService(this.extensionUtility, this._eventPubSubService);
932
935
  this.serviceList = [
936
+ this.containerService,
933
937
  this.extensionService,
934
938
  this.filterService,
935
939
  this.gridEventService,
@@ -1129,6 +1133,7 @@ class AngularSlickgridComponent {
1129
1133
  this.datasetHierarchical = undefined;
1130
1134
  this._columnDefinitions = [];
1131
1135
  this._angularGridInstances = undefined;
1136
+ this.slickGrid = undefined;
1132
1137
  }
1133
1138
  emptyGridContainerElm() {
1134
1139
  const gridContainerId = this.gridOptions?.gridContainerId ?? 'grid1';
@@ -1238,8 +1243,7 @@ class AngularSlickgridComponent {
1238
1243
  this.dataView.endUpdate();
1239
1244
  // if you don't want the items that are not visible (due to being filtered out or being on a different page)
1240
1245
  // to stay selected, pass 'false' to the second arg
1241
- const selectionModel = this.slickGrid?.getSelectionModel();
1242
- if (selectionModel && this.gridOptions && this.gridOptions.dataView && this.gridOptions.dataView.hasOwnProperty('syncGridSelection')) {
1246
+ if (this.slickGrid?.getSelectionModel() && this.gridOptions && this.gridOptions.dataView && this.gridOptions.dataView.hasOwnProperty('syncGridSelection')) {
1243
1247
  // if we are using a Backend Service, we will do an extra flag check, the reason is because it might have some unintended behaviors
1244
1248
  // with the BackendServiceApi because technically the data in the page changes the DataView on every page change.
1245
1249
  let preservedRowSelectionWithBackend = false;
@@ -1526,27 +1530,26 @@ class AngularSlickgridComponent {
1526
1530
  // When data changes in the DataView, we need to refresh the metrics and/or display a warning if the dataset is empty
1527
1531
  this._eventHandler.subscribe(dataView.onRowCountChanged, () => {
1528
1532
  grid.invalidate();
1529
- this.handleOnItemCountChanged(this.dataView.getFilteredItemCount() || 0, dataView.getItemCount());
1533
+ this.handleOnItemCountChanged(dataView.getFilteredItemCount() || 0, dataView.getItemCount() || 0);
1530
1534
  });
1531
1535
  this._eventHandler.subscribe(dataView.onSetItemsCalled, (_e, args) => {
1532
- grid.invalidate();
1533
- this.handleOnItemCountChanged(this.dataView.getFilteredItemCount(), args.itemCount);
1536
+ this.handleOnItemCountChanged(dataView.getFilteredItemCount() || 0, args.itemCount);
1534
1537
  // when user has resize by content enabled, we'll force a full width calculation since we change our entire dataset
1535
1538
  if (args.itemCount > 0 && (this.gridOptions.autosizeColumnsByCellContentOnFirstLoad || this.gridOptions.enableAutoResizeColumnsByCellContent)) {
1536
1539
  this.resizerService.resizeColumnsByCellContent(!this.gridOptions?.resizeByContentOnlyOnFirstLoad);
1537
1540
  }
1538
1541
  });
1539
- this._eventHandler.subscribe(dataView.onRowsChanged, (_e, args) => {
1540
- // filtering data with local dataset will not always show correctly unless we call this updateRow/render
1541
- // also don't use "invalidateRows" since it destroys the entire row and as bad user experience when updating a row
1542
- // see commit: https://github.com/ghiscoding/aurelia-slickgrid/commit/8c503a4d45fba11cbd8d8cc467fae8d177cc4f60
1543
- if (gridOptions?.enableFiltering && !gridOptions.enableRowDetailView) {
1542
+ if (gridOptions?.enableFiltering && !gridOptions.enableRowDetailView) {
1543
+ this._eventHandler.subscribe(dataView.onRowsChanged, (_e, args) => {
1544
+ // filtering data with local dataset will not always show correctly unless we call this updateRow/render
1545
+ // also don't use "invalidateRows" since it destroys the entire row and as bad user experience when updating a row
1546
+ // see commit: https://github.com/ghiscoding/aurelia-slickgrid/commit/8c503a4d45fba11cbd8d8cc467fae8d177cc4f60
1544
1547
  if (args?.rows && Array.isArray(args.rows)) {
1545
1548
  args.rows.forEach((row) => grid.updateRow(row));
1546
1549
  grid.render();
1547
1550
  }
1548
- }
1549
- });
1551
+ });
1552
+ }
1550
1553
  }
1551
1554
  }
1552
1555
  // did the user add a colspan callback? If so, hook it into the DataView getItemMetadata
@@ -1765,9 +1768,8 @@ class AngularSlickgridComponent {
1765
1768
  loadRowSelectionPresetWhenExists() {
1766
1769
  // if user entered some Row Selections "presets"
1767
1770
  const presets = this.gridOptions?.presets;
1768
- const selectionModel = this.slickGrid?.getSelectionModel();
1769
1771
  const enableRowSelection = this.gridOptions && (this.gridOptions.enableCheckboxSelector || this.gridOptions.enableRowSelection);
1770
- if (enableRowSelection && selectionModel && presets && presets.rowSelection && (Array.isArray(presets.rowSelection.gridRowIndexes) || Array.isArray(presets.rowSelection.dataContextIds))) {
1772
+ if (enableRowSelection && this.slickGrid?.getSelectionModel() && presets?.rowSelection && (Array.isArray(presets.rowSelection.gridRowIndexes) || Array.isArray(presets.rowSelection.dataContextIds))) {
1771
1773
  let dataContextIds = presets.rowSelection.dataContextIds;
1772
1774
  let gridRowIndexes = presets.rowSelection.gridRowIndexes;
1773
1775
  // maps the IDs to the Grid Rows and vice versa, the "dataContextIds" has precedence over the other
@@ -1859,7 +1861,7 @@ class AngularSlickgridComponent {
1859
1861
  // register all services by executing their init method and providing them with the Grid object
1860
1862
  if (Array.isArray(this._registeredResources)) {
1861
1863
  for (const resource of this._registeredResources) {
1862
- if (typeof resource.init === 'function') {
1864
+ if (this.slickGrid && typeof resource.init === 'function') {
1863
1865
  resource.init(this.slickGrid, this.containerService);
1864
1866
  }
1865
1867
  }