angular-slickgrid 5.2.2 → 5.4.0

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.
@@ -7,10 +7,10 @@ import { TranslateModule } from '@ngx-translate/core';
7
7
  import { SlickRowDetailView as SlickRowDetailView$1 } from '@slickgrid-universal/row-detail-view-plugin';
8
8
  import { Observable } from 'rxjs';
9
9
  import * as DOMPurify from 'dompurify';
10
- import 'slickgrid/dist/slick.core.min';
11
- import 'slickgrid/dist/slick.interactions.min';
12
- import 'slickgrid/dist/slick.grid.min';
13
- import 'slickgrid/dist/slick.dataview.min';
10
+ import 'slickgrid/slick.core';
11
+ import 'slickgrid/slick.interactions';
12
+ import 'slickgrid/slick.grid';
13
+ import 'slickgrid/slick.dataview';
14
14
  import { EventPubSubService } from '@slickgrid-universal/event-pub-sub';
15
15
  import { SlickEmptyWarningComponent } from '@slickgrid-universal/empty-warning-component';
16
16
  import { SlickFooterComponent } from '@slickgrid-universal/custom-footer-component';
@@ -137,13 +137,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
137
137
  */
138
138
  function unsubscribeAllObservables(subscriptions) {
139
139
  if (Array.isArray(subscriptions)) {
140
- subscriptions.forEach((subscription) => {
141
- if (subscription && subscription.unsubscribe) {
140
+ let subscription = subscriptions.pop();
141
+ while (subscription) {
142
+ if (typeof subscription.unsubscribe === 'function') {
142
143
  subscription.unsubscribe();
143
144
  }
144
- });
145
- subscriptions = [];
145
+ subscription = subscriptions.pop();
146
+ }
146
147
  }
148
+ // TODO: deprecated, remove the return type in next major version
147
149
  return subscriptions;
148
150
  }
149
151
 
@@ -510,7 +512,11 @@ const GlobalGridOptions = {
510
512
  }
511
513
  },
512
514
  dataView: {
513
- syncGridSelection: true,
515
+ // when enabled, this will preserve the row selection even after filtering/sorting/grouping
516
+ syncGridSelection: {
517
+ preserveHidden: false,
518
+ preserveHiddenOnSelectionChange: true
519
+ },
514
520
  syncGridSelectionWithBackendService: false, // but disable it when using backend services
515
521
  },
516
522
  datasetIdPropertyName: 'id',
@@ -1232,11 +1238,11 @@ class AngularSlickgridComponent {
1232
1238
  }
1233
1239
  /**
1234
1240
  * On a Pagination changed, we will trigger a Grid State changed with the new pagination info
1235
- * Also if we use Row Selection or the Checkbox Selector, we need to reset any selection
1241
+ * Also if we use Row Selection or the Checkbox Selector with a Backend Service (Odata, GraphQL), we need to reset any selection
1236
1242
  */
1237
1243
  paginationChanged(pagination) {
1238
1244
  const isSyncGridSelectionEnabled = this.gridStateService?.needToPreserveRowSelection() ?? false;
1239
- if (!isSyncGridSelectionEnabled && (this.gridOptions.enableRowSelection || this.gridOptions.enableCheckboxSelector)) {
1245
+ if (this.slickGrid && !isSyncGridSelectionEnabled && this.gridOptions?.backendServiceApi && (this.gridOptions.enableRowSelection || this.gridOptions.enableCheckboxSelector)) {
1240
1246
  this.slickGrid.setSelectedRows([]);
1241
1247
  }
1242
1248
  const { pageNumber, pageSize } = pagination;
@@ -1693,15 +1699,13 @@ class AngularSlickgridComponent {
1693
1699
  else if (Array.isArray(gridRowIndexes) && gridRowIndexes.length > 0) {
1694
1700
  dataContextIds = this.dataView.mapRowsToIds(gridRowIndexes) || [];
1695
1701
  }
1696
- this.gridStateService.selectedRowDataContextIds = dataContextIds;
1697
- // change the selected rows except UNLESS it's a Local Grid with Pagination
1698
- // local Pagination uses the DataView and that also trigger a change/refresh
1699
- // and we don't want to trigger 2 Grid State changes just 1
1700
- if ((this._isLocalGrid && !this.gridOptions.enablePagination) || !this._isLocalGrid) {
1701
- setTimeout(() => {
1702
- if (this.slickGrid && Array.isArray(gridRowIndexes)) {
1703
- this.slickGrid.setSelectedRows(gridRowIndexes);
1704
- }
1702
+ // apply row selection when defined as grid presets
1703
+ if (this.slickGrid && Array.isArray(gridRowIndexes)) {
1704
+ this.slickGrid.setSelectedRows(gridRowIndexes);
1705
+ this.dataView.setSelectedIds(dataContextIds || [], {
1706
+ isRowBeingAdded: true,
1707
+ shouldTriggerEvent: false,
1708
+ applyRowSelectionToGrid: true
1705
1709
  });
1706
1710
  }
1707
1711
  }