@slickgrid-universal/vanilla-bundle 5.11.0 → 5.12.1

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.
@@ -68,7 +68,7 @@ export class SlickVanillaGridBundle<TData = any> {
68
68
  protected _currentDatasetLength = 0;
69
69
  protected _eventPubSubService!: EventPubSubService;
70
70
  protected _darkMode = false;
71
- protected _collectionObservers: Array<null | ({ disconnect: () => void; })> = [];
71
+ protected _collectionObservers: Array<null | { disconnect: () => void }> = [];
72
72
  protected _columnDefinitions?: Column<TData>[];
73
73
  protected _gridOptions: GridOption = {};
74
74
  protected _gridContainerElm!: HTMLElement;
@@ -151,11 +151,16 @@ export class SlickVanillaGridBundle<TData = any> {
151
151
  set dataset(newDataset: TData[]) {
152
152
  const prevDatasetLn = this._currentDatasetLength;
153
153
  const isDatasetEqual = dequal(newDataset, this.dataset || []);
154
- const isDeepCopyDataOnPageLoadEnabled = !!(this._gridOptions?.enableDeepCopyDatasetOnPageLoad);
154
+ const isDeepCopyDataOnPageLoadEnabled = !!this._gridOptions?.enableDeepCopyDatasetOnPageLoad;
155
155
  let data = isDeepCopyDataOnPageLoadEnabled ? extend(true, [], newDataset) : newDataset;
156
156
 
157
157
  // when Tree Data is enabled and we don't yet have the hierarchical dataset filled, we can force a convert+sort of the array
158
- if (this.slickGrid && this.gridOptions?.enableTreeData && Array.isArray(newDataset) && (newDataset.length > 0 || newDataset.length !== prevDatasetLn || !isDatasetEqual)) {
158
+ if (
159
+ this.slickGrid &&
160
+ this.gridOptions?.enableTreeData &&
161
+ Array.isArray(newDataset) &&
162
+ (newDataset.length > 0 || newDataset.length !== prevDatasetLn || !isDatasetEqual)
163
+ ) {
159
164
  this._isDatasetHierarchicalInitialized = false;
160
165
  data = this.sortTreeDataset(newDataset, !isDatasetEqual); // if dataset changed, then force a refresh anyway
161
166
  }
@@ -212,7 +217,7 @@ export class SlickVanillaGridBundle<TData = any> {
212
217
  }
213
218
 
214
219
  get gridOptions(): GridOption {
215
- return this._gridOptions || {} as GridOption;
220
+ return this._gridOptions || ({} as GridOption);
216
221
  }
217
222
 
218
223
  set gridOptions(options: GridOption) {
@@ -222,7 +227,7 @@ export class SlickVanillaGridBundle<TData = any> {
222
227
  // if we already have grid options, when grid was already initialized, we'll merge with those options
223
228
  // else we'll merge with global grid options
224
229
  if (this.slickGrid?.getOptions) {
225
- mergedOptions = (extend<GridOption>(true, {} as GridOption, this.slickGrid.getOptions() as GridOption, options)) as GridOption;
230
+ mergedOptions = extend<GridOption>(true, {} as GridOption, this.slickGrid.getOptions() as GridOption, options) as GridOption;
226
231
  } else {
227
232
  mergedOptions = this.mergeGridOptions(options);
228
233
  }
@@ -289,26 +294,28 @@ export class SlickVanillaGridBundle<TData = any> {
289
294
  options?: Partial<GridOption> | undefined,
290
295
  dataset?: TData[] | undefined,
291
296
  hierarchicalDataset?: any[] | undefined,
292
- services?: {
293
- backendUtilityService?: BackendUtilityService,
294
- collectionService?: CollectionService,
295
- eventPubSubService?: EventPubSubService,
296
- extensionService?: ExtensionService,
297
- extensionUtility?: ExtensionUtility,
298
- filterService?: FilterService,
299
- gridEventService?: GridEventService,
300
- gridService?: GridService,
301
- gridStateService?: GridStateService,
302
- headerGroupingService?: HeaderGroupingService,
303
- paginationService?: PaginationService,
304
- resizerService?: ResizerService,
305
- rxjs?: RxJsFacade,
306
- sharedService?: SharedService,
307
- sortService?: SortService,
308
- treeDataService?: TreeDataService,
309
- translaterService?: TranslaterService,
310
- universalContainerService?: UniversalContainerService,
311
- } | undefined
297
+ services?:
298
+ | {
299
+ backendUtilityService?: BackendUtilityService;
300
+ collectionService?: CollectionService;
301
+ eventPubSubService?: EventPubSubService;
302
+ extensionService?: ExtensionService;
303
+ extensionUtility?: ExtensionUtility;
304
+ filterService?: FilterService;
305
+ gridEventService?: GridEventService;
306
+ gridService?: GridService;
307
+ gridStateService?: GridStateService;
308
+ headerGroupingService?: HeaderGroupingService;
309
+ paginationService?: PaginationService;
310
+ resizerService?: ResizerService;
311
+ rxjs?: RxJsFacade;
312
+ sharedService?: SharedService;
313
+ sortService?: SortService;
314
+ treeDataService?: TreeDataService;
315
+ translaterService?: TranslaterService;
316
+ universalContainerService?: UniversalContainerService;
317
+ }
318
+ | undefined
312
319
  ) {
313
320
  // make sure that the grid container doesn't already have the "slickgrid-container" css class
314
321
  // if it does then we won't create yet another grid, just stop there
@@ -324,7 +331,7 @@ export class SlickVanillaGridBundle<TData = any> {
324
331
 
325
332
  // check if the user wants to hide the header row from the start
326
333
  // we only want to do this check once in the constructor
327
- this._hideHeaderRowAfterPageLoad = (options?.showHeaderRow === false);
334
+ this._hideHeaderRowAfterPageLoad = options?.showHeaderRow === false;
328
335
 
329
336
  this._columnDefinitions = columnDefs || [];
330
337
  if (this._columnDefinitions.length > 0) {
@@ -336,7 +343,7 @@ export class SlickVanillaGridBundle<TData = any> {
336
343
  this._registeredResources = options?.externalResources || [];
337
344
 
338
345
  this._gridOptions = this.mergeGridOptions(options || {});
339
- const isDeepCopyDataOnPageLoadEnabled = !!(this._gridOptions?.enableDeepCopyDatasetOnPageLoad);
346
+ const isDeepCopyDataOnPageLoadEnabled = !!this._gridOptions?.enableDeepCopyDatasetOnPageLoad;
340
347
 
341
348
  // add dark mode CSS class when enabled
342
349
  if (this._gridOptions.darkMode) {
@@ -357,31 +364,41 @@ export class SlickVanillaGridBundle<TData = any> {
357
364
  this.gridEventService = services?.gridEventService ?? new GridEventService();
358
365
  this.sharedService = services?.sharedService ?? new SharedService();
359
366
  this.collectionService = services?.collectionService ?? new CollectionService(this.translaterService);
360
- this.extensionUtility = services?.extensionUtility ?? new ExtensionUtility(this.sharedService, this.backendUtilityService, this.translaterService);
367
+ this.extensionUtility =
368
+ services?.extensionUtility ?? new ExtensionUtility(this.sharedService, this.backendUtilityService, this.translaterService);
361
369
  this.filterFactory = new FilterFactory(slickgridConfig, this.translaterService, this.collectionService);
370
+ // prettier-ignore
362
371
  this.filterService = services?.filterService ?? new FilterService(this.filterFactory, this._eventPubSubService, this.sharedService, this.backendUtilityService);
363
372
  this.resizerService = services?.resizerService ?? new ResizerService(this._eventPubSubService);
373
+ // prettier-ignore
364
374
  this.sortService = services?.sortService ?? new SortService(this.collectionService, this.sharedService, this._eventPubSubService, this.backendUtilityService);
365
375
  this.treeDataService = services?.treeDataService ?? new TreeDataService(this._eventPubSubService, this.sharedService, this.sortService);
376
+
377
+ // prettier-ignore
366
378
  this.paginationService = services?.paginationService ?? new PaginationService(this._eventPubSubService, this.sharedService, this.backendUtilityService);
367
379
 
368
- this.extensionService = services?.extensionService ?? new ExtensionService(
369
- this.extensionUtility,
370
- this.filterService,
371
- this._eventPubSubService,
372
- this.sharedService,
373
- this.sortService,
374
- this.treeDataService,
375
- this.translaterService,
376
- () => this.gridService
377
- );
380
+ this.extensionService =
381
+ services?.extensionService ??
382
+ new ExtensionService(
383
+ this.extensionUtility,
384
+ this.filterService,
385
+ this._eventPubSubService,
386
+ this.sharedService,
387
+ this.sortService,
388
+ this.treeDataService,
389
+ this.translaterService,
390
+ () => this.gridService
391
+ );
378
392
 
393
+ // prettier-ignore
379
394
  this.gridStateService = services?.gridStateService ?? new GridStateService(this.extensionService, this.filterService, this._eventPubSubService, this.sharedService, this.sortService, this.treeDataService);
395
+ // prettier-ignore
380
396
  this.gridService = services?.gridService ?? new GridService(this.gridStateService, this.filterService, this._eventPubSubService, this.paginationService, this.sharedService, this.sortService, this.treeDataService);
381
397
  this.headerGroupingService = services?.headerGroupingService ?? new HeaderGroupingService(this.extensionUtility);
382
398
 
383
399
  if (hierarchicalDataset) {
384
- this.sharedService.hierarchicalDataset = (isDeepCopyDataOnPageLoadEnabled ? extend(true, [], hierarchicalDataset) : hierarchicalDataset) || [];
400
+ this.sharedService.hierarchicalDataset =
401
+ (isDeepCopyDataOnPageLoadEnabled ? extend(true, [], hierarchicalDataset) : hierarchicalDataset) || [];
385
402
  }
386
403
  const eventHandler = new SlickEventHandler();
387
404
 
@@ -475,7 +492,7 @@ export class SlickVanillaGridBundle<TData = any> {
475
492
  if (shouldEmptyDomElementContainer) {
476
493
  this.emptyGridContainerElm();
477
494
  }
478
- this._collectionObservers.forEach(obs => obs?.disconnect());
495
+ this._collectionObservers.forEach((obs) => obs?.disconnect());
479
496
  this._eventPubSubService?.dispose();
480
497
  this._slickerGridInstances = null as any;
481
498
  }
@@ -494,7 +511,12 @@ export class SlickVanillaGridBundle<TData = any> {
494
511
 
495
512
  initialization(gridContainerElm: HTMLElement, eventHandler: SlickEventHandler, inputDataset?: TData[]): void {
496
513
  // when detecting a frozen grid, we'll automatically enable the mousewheel scroll handler so that we can scroll from both left/right frozen containers
497
- if (this.gridOptions && ((this.gridOptions.frozenRow !== undefined && this.gridOptions.frozenRow >= 0) || this.gridOptions.frozenColumn !== undefined && this.gridOptions.frozenColumn >= 0) && this.gridOptions.enableMouseWheelScrollHandler === undefined) {
514
+ if (
515
+ this.gridOptions &&
516
+ ((this.gridOptions.frozenRow !== undefined && this.gridOptions.frozenRow >= 0) ||
517
+ (this.gridOptions.frozenColumn !== undefined && this.gridOptions.frozenColumn >= 0)) &&
518
+ this.gridOptions.enableMouseWheelScrollHandler === undefined
519
+ ) {
498
520
  this.gridOptions.enableMouseWheelScrollHandler = true;
499
521
  }
500
522
 
@@ -504,7 +526,7 @@ export class SlickVanillaGridBundle<TData = any> {
504
526
 
505
527
  this._isAutosizeColsCalled = false;
506
528
  this._eventHandler = eventHandler;
507
- this._gridOptions = this.mergeGridOptions(this._gridOptions || {} as GridOption);
529
+ this._gridOptions = this.mergeGridOptions(this._gridOptions || ({} as GridOption));
508
530
  this.backendServiceApi = this._gridOptions?.backendServiceApi;
509
531
  this._isLocalGrid = !this.backendServiceApi; // considered a local grid if it doesn't have a backend service set
510
532
  this._eventPubSubService.eventNamingStyle = this._gridOptions?.eventNamingStyle ?? EventNamingStyle.camelCase;
@@ -562,7 +584,13 @@ export class SlickVanillaGridBundle<TData = any> {
562
584
  this.gridOptions = { ...this.gridOptions, ...this.gridOptions.presets.pinning };
563
585
  }
564
586
 
565
- this.slickGrid = new SlickGrid<TData, Column<TData>, GridOption<Column<TData>>>(gridContainerElm, this.dataView as SlickDataView<TData>, this._columnDefinitions, this._gridOptions, this._eventPubSubService);
587
+ this.slickGrid = new SlickGrid<TData, Column<TData>, GridOption<Column<TData>>>(
588
+ gridContainerElm,
589
+ this.dataView as SlickDataView<TData>,
590
+ this._columnDefinitions,
591
+ this._gridOptions,
592
+ this._eventPubSubService
593
+ );
566
594
  this.sharedService.dataView = this.dataView as SlickDataView;
567
595
  this.sharedService.slickGrid = this.slickGrid as SlickGrid;
568
596
  this.sharedService.gridContainerElement = this._gridContainerElm;
@@ -592,7 +620,12 @@ export class SlickVanillaGridBundle<TData = any> {
592
620
 
593
621
  // user could show a custom footer with the data metrics (dataset length and last updated timestamp)
594
622
  if (!this.gridOptions.enablePagination && this.gridOptions.showCustomFooter && this.gridOptions.customFooterOptions) {
595
- this.slickFooter = new SlickFooterComponent(this.slickGrid, this.gridOptions.customFooterOptions, this._eventPubSubService, this.translaterService);
623
+ this.slickFooter = new SlickFooterComponent(
624
+ this.slickGrid,
625
+ this.gridOptions.customFooterOptions,
626
+ this._eventPubSubService,
627
+ this.translaterService
628
+ );
596
629
  this.slickFooter.renderFooter(this._gridParentContainerElm);
597
630
  }
598
631
 
@@ -626,7 +659,11 @@ export class SlickVanillaGridBundle<TData = any> {
626
659
  }
627
660
  this.dataView?.syncGridSelection(this.slickGrid, preservedRowSelection);
628
661
  } else if (typeof syncGridSelection === 'object') {
629
- this.dataView?.syncGridSelection(this.slickGrid, syncGridSelection.preserveHidden, syncGridSelection.preserveHiddenOnSelectionChange);
662
+ this.dataView?.syncGridSelection(
663
+ this.slickGrid,
664
+ syncGridSelection.preserveHidden,
665
+ syncGridSelection.preserveHiddenOnSelectionChange
666
+ );
630
667
  }
631
668
  }
632
669
 
@@ -730,7 +767,12 @@ export class SlickVanillaGridBundle<TData = any> {
730
767
  // using copy extend to do a deep clone has an unwanted side on objects and pageSizes but ES6 spread has other worst side effects
731
768
  // so we will just overwrite the pageSizes when needed, this is the only one causing issues so far.
732
769
  // On a deep extend, Object and Array are extended, but object wrappers on primitive types such as String, Boolean, and Number are not.
733
- if (options?.pagination && (gridOptions.enablePagination || gridOptions.backendServiceApi) && gridOptions.pagination && Array.isArray(gridOptions.pagination.pageSizes)) {
770
+ if (
771
+ options?.pagination &&
772
+ (gridOptions.enablePagination || gridOptions.backendServiceApi) &&
773
+ gridOptions.pagination &&
774
+ Array.isArray(gridOptions.pagination.pageSizes)
775
+ ) {
734
776
  options.pagination.pageSizes = gridOptions.pagination.pageSizes;
735
777
  }
736
778
 
@@ -759,10 +801,15 @@ export class SlickVanillaGridBundle<TData = any> {
759
801
  // internalPostProcess only works (for now) with a GraphQL Service, so make sure it is of that type
760
802
  if (/* backendApiService instanceof GraphqlService || */ typeof backendApiService.getDatasetName === 'function') {
761
803
  backendApi.internalPostProcess = (processResult: any) => {
804
+ // prettier-ignore
762
805
  const datasetName = (backendApi && backendApiService && typeof backendApiService.getDatasetName === 'function') ? backendApiService.getDatasetName() : '';
763
806
  if (processResult && processResult.data && processResult.data[datasetName]) {
764
- const data = processResult.data[datasetName].hasOwnProperty('nodes') ? (processResult as any).data[datasetName].nodes : (processResult as any).data[datasetName];
765
- const totalCount = processResult.data[datasetName].hasOwnProperty('totalCount') ? (processResult as any).data[datasetName].totalCount : (processResult as any).data[datasetName].length;
807
+ const data = processResult.data[datasetName].hasOwnProperty('nodes')
808
+ ? (processResult as any).data[datasetName].nodes
809
+ : (processResult as any).data[datasetName];
810
+ const totalCount = processResult.data[datasetName].hasOwnProperty('totalCount')
811
+ ? (processResult as any).data[datasetName].totalCount
812
+ : (processResult as any).data[datasetName].length;
766
813
  this.refreshGridData(data, totalCount || 0);
767
814
  }
768
815
  };
@@ -784,10 +831,13 @@ export class SlickVanillaGridBundle<TData = any> {
784
831
 
785
832
  // on locale change, we have to manually translate the Headers, GridMenu
786
833
  this.subscriptions.push(
787
- this._eventPubSubService.subscribe('onLanguageChange', (args: { language: string; }) => {
834
+ this._eventPubSubService.subscribe('onLanguageChange', (args: { language: string }) => {
788
835
  if (gridOptions.enableTranslate) {
789
836
  this.extensionService.translateAllExtensions(args.language);
790
- if ((gridOptions.createPreHeaderPanel && gridOptions.createTopHeaderPanel) || (gridOptions.createPreHeaderPanel && !gridOptions.enableDraggableGrouping)) {
837
+ if (
838
+ (gridOptions.createPreHeaderPanel && gridOptions.createTopHeaderPanel) ||
839
+ (gridOptions.createPreHeaderPanel && !gridOptions.enableDraggableGrouping)
840
+ ) {
791
841
  this.headerGroupingService.translateHeaderGrouping();
792
842
  }
793
843
  }
@@ -837,21 +887,22 @@ export class SlickVanillaGridBundle<TData = any> {
837
887
  this.handleOnItemCountChanged(this.dataView?.getFilteredItemCount() || 0, args.itemCount);
838
888
 
839
889
  // when user has resize by content enabled, we'll force a full width calculation since we change our entire dataset
840
- if (args.itemCount > 0 && (this.gridOptions.autosizeColumnsByCellContentOnFirstLoad || this.gridOptions.enableAutoResizeColumnsByCellContent)) {
890
+ if (
891
+ args.itemCount > 0 &&
892
+ (this.gridOptions.autosizeColumnsByCellContentOnFirstLoad || this.gridOptions.enableAutoResizeColumnsByCellContent)
893
+ ) {
841
894
  this.resizerService.resizeColumnsByCellContent(!this.gridOptions?.resizeByContentOnlyOnFirstLoad);
842
895
  }
843
896
  });
844
897
 
845
- if (gridOptions?.enableFiltering && !gridOptions.enableRowDetailView) {
898
+ if ((gridOptions?.enableFiltering || gridOptions?.dataView?.globalItemMetadataProvider) && !gridOptions.enableRowDetailView) {
846
899
  this._eventHandler.subscribe(dataView.onRowsChanged, (_e, { calledOnRowCountChanged, rows }) => {
847
900
  // filtering data with local dataset will not always show correctly unless we call this updateRow/render
848
901
  // also don't use "invalidateRows" since it destroys the entire row and as bad user experience when updating a row
849
902
  // see commit: https://github.com/ghiscoding/aurelia-slickgrid/commit/8c503a4d45fba11cbd8d8cc467fae8d177cc4f60
850
903
  if (!calledOnRowCountChanged && Array.isArray(rows)) {
851
904
  const ranges = grid.getRenderedRange();
852
- rows
853
- .filter(row => row >= ranges.top && row <= ranges.bottom)
854
- .forEach((row: number) => grid.updateRow(row));
905
+ rows.filter((row) => row >= ranges.top && row <= ranges.bottom).forEach((row: number) => grid.updateRow(row));
855
906
  grid.render();
856
907
  }
857
908
  });
@@ -875,6 +926,7 @@ export class SlickVanillaGridBundle<TData = any> {
875
926
  this.loadFilterPresetsWhenDatasetInitialized();
876
927
  }
877
928
 
929
+ // @deprecated @user `dataview.globalItemMetadataProvider.getRowMetadata`
878
930
  // did the user add a colspan callback? If so, hook it into the DataView getItemMetadata
879
931
  if (gridOptions?.colspanCallback && dataView?.getItem && dataView?.getItemMetadata) {
880
932
  dataView.getItemMetadata = (rowNumber: number) => {
@@ -891,6 +943,7 @@ export class SlickVanillaGridBundle<TData = any> {
891
943
  const backendApi = gridOptions.backendServiceApi;
892
944
  const backendApiService = backendApi?.service;
893
945
  const serviceOptions: BackendServiceOption = backendApiService?.options ?? {};
946
+ // prettier-ignore
894
947
  const isExecuteCommandOnInit = (!serviceOptions) ? false : ((serviceOptions?.hasOwnProperty('executeProcessCommandOnInit')) ? serviceOptions['executeProcessCommandOnInit'] : true);
895
948
 
896
949
  if (backendApiService) {
@@ -921,7 +974,7 @@ export class SlickVanillaGridBundle<TData = any> {
921
974
 
922
975
  // execute onInit command when necessary
923
976
  if (backendApi && backendApiService && (backendApi.onInit || isExecuteCommandOnInit)) {
924
- const query = (typeof backendApiService.buildQuery === 'function') ? backendApiService.buildQuery() : '';
977
+ const query = typeof backendApiService.buildQuery === 'function' ? backendApiService.buildQuery() : '';
925
978
  const process = isExecuteCommandOnInit ? (backendApi.process?.(query) ?? null) : (backendApi.onInit?.(query) ?? null);
926
979
 
927
980
  // wrap this inside a microtask to be executed at the end of the task and avoid timing issue since the gridOptions needs to be ready before running this onInit
@@ -939,12 +992,15 @@ export class SlickVanillaGridBundle<TData = any> {
939
992
  const totalItems = this.gridOptions?.pagination?.totalItems ?? 0;
940
993
  if (process instanceof Promise) {
941
994
  process
942
- .then((processResult: any) => backendUtilityService.executeBackendProcessesCallback(startTime, processResult, backendApi, totalItems))
995
+ .then((processResult: any) =>
996
+ backendUtilityService.executeBackendProcessesCallback(startTime, processResult, backendApi, totalItems)
997
+ )
943
998
  .catch((error) => backendUtilityService.onBackendError(error, backendApi));
944
999
  } else if (process && this.rxjs?.isObservable(process)) {
945
1000
  this.subscriptions.push(
946
1001
  (process as Observable<any>).subscribe(
947
- (processResult: any) => backendUtilityService.executeBackendProcessesCallback(startTime, processResult, backendApi, totalItems),
1002
+ (processResult: any) =>
1003
+ backendUtilityService.executeBackendProcessesCallback(startTime, processResult, backendApi, totalItems),
948
1004
  (error: any) => backendUtilityService.onBackendError(error, backendApi)
949
1005
  )
950
1006
  );
@@ -960,14 +1016,19 @@ export class SlickVanillaGridBundle<TData = any> {
960
1016
  }
961
1017
 
962
1018
  protected addBackendInfiniteScrollCallback(): void {
963
- if (this.slickGrid && this.gridOptions.backendServiceApi && this.hasBackendInfiniteScroll() && !this.gridOptions.backendServiceApi?.onScrollEnd) {
1019
+ if (
1020
+ this.slickGrid &&
1021
+ this.gridOptions.backendServiceApi &&
1022
+ this.hasBackendInfiniteScroll() &&
1023
+ !this.gridOptions.backendServiceApi?.onScrollEnd
1024
+ ) {
964
1025
  const onScrollEnd = () => {
965
1026
  this.backendUtilityService.setInfiniteScrollBottomHit(true);
966
1027
 
967
1028
  // even if we're not showing pagination, we still use pagination service behind the scene
968
1029
  // to keep track of the scroll position and fetch next set of data (aka next page)
969
1030
  // we also need a flag to know if we reached the of the dataset or not (no more pages)
970
- this.paginationService.goToNextPage().then(hasNext => {
1031
+ this.paginationService.goToNextPage().then((hasNext) => {
971
1032
  if (!hasNext) {
972
1033
  this.backendUtilityService.setInfiniteScrollBottomHit(false);
973
1034
  }
@@ -980,10 +1041,10 @@ export class SlickVanillaGridBundle<TData = any> {
980
1041
  this._eventHandler.subscribe(this.slickGrid.onScroll, (_e, args) => {
981
1042
  const viewportElm = args.grid.getViewportNode()!;
982
1043
  if (
983
- ['mousewheel', 'scroll'].includes(args.triggeredBy || '')
984
- && this.paginationService?.totalItems
985
- && args.scrollTop > 0
986
- && Math.ceil(viewportElm.offsetHeight + args.scrollTop) >= args.scrollHeight
1044
+ ['mousewheel', 'scroll'].includes(args.triggeredBy || '') &&
1045
+ this.paginationService?.totalItems &&
1046
+ args.scrollTop > 0 &&
1047
+ Math.ceil(viewportElm.offsetHeight + args.scrollTop) >= args.scrollHeight
987
1048
  ) {
988
1049
  if (!this._scrollEndCalled) {
989
1050
  onScrollEnd();
@@ -1005,8 +1066,13 @@ export class SlickVanillaGridBundle<TData = any> {
1005
1066
  }
1006
1067
 
1007
1068
  bindResizeHook(grid: SlickGrid, options: GridOption): void {
1008
- if ((options.autoFitColumnsOnFirstLoad && options.autosizeColumnsByCellContentOnFirstLoad) || (options.enableAutoSizeColumns && options.enableAutoResizeColumnsByCellContent)) {
1009
- throw new Error(`[Slickgrid-Universal] You cannot enable both autosize/fit viewport & resize by content, you must choose which resize technique to use. You can enable these 2 options ("autoFitColumnsOnFirstLoad" and "enableAutoSizeColumns") OR these other 2 options ("autosizeColumnsByCellContentOnFirstLoad" and "enableAutoResizeColumnsByCellContent").`);
1069
+ if (
1070
+ (options.autoFitColumnsOnFirstLoad && options.autosizeColumnsByCellContentOnFirstLoad) ||
1071
+ (options.enableAutoSizeColumns && options.enableAutoResizeColumnsByCellContent)
1072
+ ) {
1073
+ throw new Error(
1074
+ `[Slickgrid-Universal] You cannot enable both autosize/fit viewport & resize by content, you must choose which resize technique to use. You can enable these 2 options ("autoFitColumnsOnFirstLoad" and "enableAutoSizeColumns") OR these other 2 options ("autosizeColumnsByCellContentOnFirstLoad" and "enableAutoResizeColumnsByCellContent").`
1075
+ );
1010
1076
  }
1011
1077
 
1012
1078
  // auto-resize grid on browser resize (optionally provide grid height or width)
@@ -1017,7 +1083,13 @@ export class SlickVanillaGridBundle<TData = any> {
1017
1083
  }
1018
1084
 
1019
1085
  // expand/autofit columns on first page load
1020
- if (grid && options?.enableAutoResize && options.autoFitColumnsOnFirstLoad && options.enableAutoSizeColumns && !this._isAutosizeColsCalled) {
1086
+ if (
1087
+ grid &&
1088
+ options?.enableAutoResize &&
1089
+ options.autoFitColumnsOnFirstLoad &&
1090
+ options.enableAutoSizeColumns &&
1091
+ !this._isAutosizeColsCalled
1092
+ ) {
1021
1093
  grid.autosizeColumns();
1022
1094
  this._isAutosizeColsCalled = true;
1023
1095
  }
@@ -1040,7 +1112,12 @@ export class SlickVanillaGridBundle<TData = any> {
1040
1112
  */
1041
1113
  paginationChanged(pagination: PaginationMetadata): void {
1042
1114
  const isSyncGridSelectionEnabled = this.gridStateService?.needToPreserveRowSelection() ?? false;
1043
- if (this.slickGrid && !isSyncGridSelectionEnabled && this._gridOptions?.backendServiceApi && (this.gridOptions.enableRowSelection || this.gridOptions.enableCheckboxSelector)) {
1115
+ if (
1116
+ this.slickGrid &&
1117
+ !isSyncGridSelectionEnabled &&
1118
+ this._gridOptions?.backendServiceApi &&
1119
+ (this.gridOptions.enableRowSelection || this.gridOptions.enableCheckboxSelector)
1120
+ ) {
1044
1121
  this.slickGrid.setSelectedRows([]);
1045
1122
  }
1046
1123
  const { pageNumber, pageSize } = pagination;
@@ -1049,7 +1126,7 @@ export class SlickVanillaGridBundle<TData = any> {
1049
1126
  }
1050
1127
  this._eventPubSubService.publish('onGridStateChanged', {
1051
1128
  change: { newValues: { pageNumber, pageSize }, type: GridStateType.pagination },
1052
- gridState: this.gridStateService.getCurrentGridState()
1129
+ gridState: this.gridStateService.getCurrentGridState(),
1053
1130
  });
1054
1131
  }
1055
1132
 
@@ -1089,14 +1166,17 @@ export class SlickVanillaGridBundle<TData = any> {
1089
1166
  }
1090
1167
 
1091
1168
  // display the Pagination component only after calling this refresh data first, we call it here so that if we preset pagination page number it will be shown correctly
1092
- this.showPagination = !!(this._gridOptions && (this._gridOptions.enablePagination || (this._gridOptions.backendServiceApi && this._gridOptions.enablePagination === undefined)));
1169
+ this.showPagination = !!(
1170
+ this._gridOptions &&
1171
+ (this._gridOptions.enablePagination || (this._gridOptions.backendServiceApi && this._gridOptions.enablePagination === undefined))
1172
+ );
1093
1173
 
1094
1174
  if (this._paginationOptions && this._gridOptions?.pagination && this._gridOptions?.backendServiceApi) {
1095
1175
  const paginationOptions = this.setPaginationOptionsWhenPresetDefined(this._gridOptions, this._paginationOptions);
1096
1176
 
1097
1177
  // when we have a totalCount use it, else we'll take it from the pagination object
1098
1178
  // only update the total items if it's different to avoid refreshing the UI
1099
- const totalRecords = (totalCount !== undefined) ? totalCount : (this._gridOptions?.pagination?.totalItems);
1179
+ const totalRecords = totalCount !== undefined ? totalCount : this._gridOptions?.pagination?.totalItems;
1100
1180
  if (totalRecords !== undefined && totalRecords !== this.totalItems) {
1101
1181
  this.totalItems = +totalRecords;
1102
1182
  }
@@ -1200,7 +1280,7 @@ export class SlickVanillaGridBundle<TData = any> {
1200
1280
  * We will use this when doing a resize by cell content, if user provided a `width` it won't override it.
1201
1281
  */
1202
1282
  protected copyColumnWidthsReference(columnDefinitions: Column<TData>[]): void {
1203
- columnDefinitions.forEach(col => col.originalWidth = col.width);
1283
+ columnDefinitions.forEach((col) => (col.originalWidth = col.width));
1204
1284
  }
1205
1285
 
1206
1286
  protected displayEmptyDataWarning(showWarning = true): void {
@@ -1216,7 +1296,7 @@ export class SlickVanillaGridBundle<TData = any> {
1216
1296
  startTime: new Date(),
1217
1297
  endTime: new Date(),
1218
1298
  itemCount: currentPageRowItemCount,
1219
- totalItemCount
1299
+ totalItemCount,
1220
1300
  };
1221
1301
  // if custom footer is enabled, then we'll update its metrics
1222
1302
  if (this.slickFooter) {
@@ -1227,6 +1307,11 @@ export class SlickVanillaGridBundle<TData = any> {
1227
1307
  if (this._isLocalGrid && this._gridOptions?.enableEmptyDataWarningMessage) {
1228
1308
  this.displayEmptyDataWarning(currentPageRowItemCount === 0);
1229
1309
  }
1310
+
1311
+ // when autoResize.autoHeight is enabled, we'll want to call a resize
1312
+ if (this._gridOptions.enableAutoResize && this.resizerService.isAutoHeightEnabled && currentPageRowItemCount > 0) {
1313
+ this.resizerService.resizeGrid();
1314
+ }
1230
1315
  }
1231
1316
 
1232
1317
  /** Initialize the Pagination Service once */
@@ -1239,8 +1324,10 @@ export class SlickVanillaGridBundle<TData = any> {
1239
1324
  this.paginationService.totalItems = this.totalItems;
1240
1325
  this.paginationService.init(this.slickGrid, paginationOptions, this.backendServiceApi);
1241
1326
  this.subscriptions.push(
1242
- this._eventPubSubService.subscribe<PaginationMetadata>('onPaginationChanged', paginationChanges => this.paginationChanged(paginationChanges)),
1243
- this._eventPubSubService.subscribe<{ visible: boolean; }>('onPaginationVisibilityChanged', visibility => {
1327
+ this._eventPubSubService.subscribe<PaginationMetadata>('onPaginationChanged', (paginationChanges) =>
1328
+ this.paginationChanged(paginationChanges)
1329
+ ),
1330
+ this._eventPubSubService.subscribe<{ visible: boolean }>('onPaginationVisibilityChanged', (visibility) => {
1244
1331
  this.showPagination = visibility?.visible ?? false;
1245
1332
  if (this.gridOptions?.backendServiceApi) {
1246
1333
  this.backendUtilityService?.refreshBackendDataset(this.gridOptions);
@@ -1273,9 +1360,7 @@ export class SlickVanillaGridBundle<TData = any> {
1273
1360
  * we can use our internal array observer for any changes done via (push, pop, shift, ...)
1274
1361
  */
1275
1362
  protected observeColumnDefinitions(): void {
1276
- this._collectionObservers.push(
1277
- collectionObserver(this.columnDefinitions, this.columnDefinitionsChanged.bind(this))
1278
- );
1363
+ this._collectionObservers.push(collectionObserver(this.columnDefinitions, this.columnDefinitionsChanged.bind(this)));
1279
1364
  }
1280
1365
 
1281
1366
  /**
@@ -1311,11 +1396,13 @@ export class SlickVanillaGridBundle<TData = any> {
1311
1396
  this.updateEditorCollection(column, response); // from Promise
1312
1397
  } else if (response?.status >= 200 && response.status < 300 && typeof response.json === 'function') {
1313
1398
  if (response.bodyUsed) {
1314
- console.warn(`[SlickGrid-Universal] The response body passed to collectionAsync was already read.`
1315
- + `Either pass the dataset from the Response or clone the response first using response.clone()`);
1399
+ console.warn(
1400
+ `[SlickGrid-Universal] The response body passed to collectionAsync was already read.` +
1401
+ `Either pass the dataset from the Response or clone the response first using response.clone()`
1402
+ );
1316
1403
  } else {
1317
1404
  // from Fetch
1318
- (response as Response).json().then(data => this.updateEditorCollection(column, data));
1405
+ (response as Response).json().then((data) => this.updateEditorCollection(column, data));
1319
1406
  }
1320
1407
  } else if (response?.content) {
1321
1408
  this.updateEditorCollection(column, response['content']); // from http-client
@@ -1334,13 +1421,11 @@ export class SlickVanillaGridBundle<TData = any> {
1334
1421
 
1335
1422
  protected insertDynamicPresetColumns(columnId: string, gridPresetColumns: Column<TData>[]): void {
1336
1423
  if (this._columnDefinitions) {
1337
- const columnPosition = this._columnDefinitions.findIndex(c => c.id === columnId);
1424
+ const columnPosition = this._columnDefinitions.findIndex((c) => c.id === columnId);
1338
1425
  if (columnPosition >= 0) {
1339
1426
  const dynColumn = this._columnDefinitions[columnPosition];
1340
- if (dynColumn?.id === columnId && !gridPresetColumns.some(c => c.id === columnId)) {
1341
- columnPosition > 0
1342
- ? gridPresetColumns.splice(columnPosition, 0, dynColumn)
1343
- : gridPresetColumns.unshift(dynColumn);
1427
+ if (dynColumn?.id === columnId && !gridPresetColumns.some((c) => c.id === columnId)) {
1428
+ columnPosition > 0 ? gridPresetColumns.splice(columnPosition, 0, dynColumn) : gridPresetColumns.unshift(dynColumn);
1344
1429
  }
1345
1430
  }
1346
1431
  }
@@ -1349,8 +1434,16 @@ export class SlickVanillaGridBundle<TData = any> {
1349
1434
  /** Load any possible Columns Grid Presets */
1350
1435
  protected loadColumnPresetsWhenDatasetInitialized(): void {
1351
1436
  // if user entered some Columns "presets", we need to reflect them all in the grid
1352
- if (this.slickGrid && this.gridOptions.presets && Array.isArray(this.gridOptions.presets.columns) && this.gridOptions.presets.columns.length > 0) {
1353
- const gridPresetColumns: Column<TData>[] = this.gridStateService.getAssociatedGridColumns(this.slickGrid, this.gridOptions.presets.columns);
1437
+ if (
1438
+ this.slickGrid &&
1439
+ this.gridOptions.presets &&
1440
+ Array.isArray(this.gridOptions.presets.columns) &&
1441
+ this.gridOptions.presets.columns.length > 0
1442
+ ) {
1443
+ const gridPresetColumns: Column<TData>[] = this.gridStateService.getAssociatedGridColumns(
1444
+ this.slickGrid,
1445
+ this.gridOptions.presets.columns
1446
+ );
1354
1447
  if (gridPresetColumns && Array.isArray(gridPresetColumns) && gridPresetColumns.length > 0 && Array.isArray(this._columnDefinitions)) {
1355
1448
  // make sure that the dynamic columns are included in presets (1.Row Move, 2. Row Selection, 3. Row Detail)
1356
1449
  if (this.gridOptions.enableRowMoveManager) {
@@ -1368,7 +1461,7 @@ export class SlickVanillaGridBundle<TData = any> {
1368
1461
 
1369
1462
  // keep copy the original optional `width` properties optionally provided by the user.
1370
1463
  // We will use this when doing a resize by cell content, if user provided a `width` it won't override it.
1371
- gridPresetColumns.forEach(col => col.originalWidth = col.width);
1464
+ gridPresetColumns.forEach((col) => (col.originalWidth = col.width));
1372
1465
 
1373
1466
  // finally set the new presets columns (including checkbox selector if need be)
1374
1467
  this.slickGrid.setColumns(gridPresetColumns);
@@ -1383,7 +1476,10 @@ export class SlickVanillaGridBundle<TData = any> {
1383
1476
  // if user entered some Filter "presets", we need to reflect them all in the DOM
1384
1477
  // also note that a presets of Tree Data Toggling will also call this method because Tree Data toggling does work with data filtering
1385
1478
  // (collapsing a parent will basically use Filter for hidding (aka collapsing) away the child underneat it)
1386
- if (this.gridOptions.presets && (Array.isArray(this.gridOptions.presets.filters) || Array.isArray(this.gridOptions.presets?.treeData?.toggledItems))) {
1479
+ if (
1480
+ this.gridOptions.presets &&
1481
+ (Array.isArray(this.gridOptions.presets.filters) || Array.isArray(this.gridOptions.presets?.treeData?.toggledItems))
1482
+ ) {
1387
1483
  this.filterService.populateColumnFilterSearchTermPresets(this.gridOptions.presets?.filters || []);
1388
1484
  }
1389
1485
  }
@@ -1415,7 +1511,14 @@ export class SlickVanillaGridBundle<TData = any> {
1415
1511
  const presets = this.gridOptions?.presets;
1416
1512
  const selectionModel = this.slickGrid?.getSelectionModel();
1417
1513
  const enableRowSelection = this.gridOptions && (this.gridOptions.enableCheckboxSelector || this.gridOptions.enableRowSelection);
1418
- if (this.slickGrid && this.dataView && enableRowSelection && selectionModel && presets?.rowSelection && (Array.isArray(presets.rowSelection.gridRowIndexes) || Array.isArray(presets.rowSelection.dataContextIds))) {
1514
+ if (
1515
+ this.slickGrid &&
1516
+ this.dataView &&
1517
+ enableRowSelection &&
1518
+ selectionModel &&
1519
+ presets?.rowSelection &&
1520
+ (Array.isArray(presets.rowSelection.gridRowIndexes) || Array.isArray(presets.rowSelection.dataContextIds))
1521
+ ) {
1419
1522
  let dataContextIds = presets.rowSelection.dataContextIds;
1420
1523
  let gridRowIndexes = presets.rowSelection.gridRowIndexes;
1421
1524
 
@@ -1432,7 +1535,7 @@ export class SlickVanillaGridBundle<TData = any> {
1432
1535
  this.dataView!.setSelectedIds(dataContextIds || [], {
1433
1536
  isRowBeingAdded: true,
1434
1537
  shouldTriggerEvent: false, // do not trigger when presetting the grid
1435
- applyRowSelectionToGrid: true
1538
+ applyRowSelectionToGrid: true,
1436
1539
  });
1437
1540
  }
1438
1541
  }
@@ -1443,7 +1546,7 @@ export class SlickVanillaGridBundle<TData = any> {
1443
1546
  if (disposePreviousResources) {
1444
1547
  this.disposeExternalResources();
1445
1548
  }
1446
- resources.forEach(res => this._registeredResources.push(res));
1549
+ resources.forEach((res) => this._registeredResources.push(res));
1447
1550
  this.initializeExternalResources(resources);
1448
1551
  }
1449
1552
 
@@ -1484,7 +1587,10 @@ export class SlickVanillaGridBundle<TData = any> {
1484
1587
  this._registeredResources.push(this.gridService, this.gridStateService);
1485
1588
 
1486
1589
  // when using Grouping/DraggableGrouping/Colspan register its Service
1487
- if ((this.gridOptions.createPreHeaderPanel && this.gridOptions.createTopHeaderPanel) || (this.gridOptions.createPreHeaderPanel && !this.gridOptions.enableDraggableGrouping)) {
1590
+ if (
1591
+ (this.gridOptions.createPreHeaderPanel && this.gridOptions.createTopHeaderPanel) ||
1592
+ (this.gridOptions.createPreHeaderPanel && !this.gridOptions.enableDraggableGrouping)
1593
+ ) {
1488
1594
  this._registeredResources.push(this.headerGroupingService);
1489
1595
  }
1490
1596
 
@@ -1535,7 +1641,11 @@ export class SlickVanillaGridBundle<TData = any> {
1535
1641
  } else if (Array.isArray(flatDatasetInput) && flatDatasetInput.length > 0) {
1536
1642
  // we need to first convert the flat dataset to a hierarchical dataset and then sort it
1537
1643
  // we'll also add props, by mutation, required by the TreeDataService on the flat array like `__hasChildren`, `parentId` and anything else to work properly
1538
- sortedDatasetResult = this.treeDataService.convertFlatParentChildToTreeDatasetAndSort(flatDatasetInput, this._columnDefinitions || [], this.gridOptions);
1644
+ sortedDatasetResult = this.treeDataService.convertFlatParentChildToTreeDatasetAndSort(
1645
+ flatDatasetInput,
1646
+ this._columnDefinitions || [],
1647
+ this.gridOptions
1648
+ );
1539
1649
  this.sharedService.hierarchicalDataset = sortedDatasetResult.hierarchical;
1540
1650
  flatDatasetOutput = sortedDatasetResult.flat;
1541
1651
  }
@@ -1552,8 +1662,10 @@ export class SlickVanillaGridBundle<TData = any> {
1552
1662
  protected loadSlickGridEditors(columnDefinitions: Column<TData>[]): Column<TData>[] {
1553
1663
  const columns = Array.isArray(columnDefinitions) ? columnDefinitions : [];
1554
1664
 
1555
- if (columns.some(col => `${col.id}`.includes('.'))) {
1556
- console.error('[Slickgrid-Universal] Make sure that none of your Column Definition "id" property includes a dot in its name because that will cause some problems with the Editors. For example if your column definition "field" property is "user.firstName" then use "firstName" as the column "id".');
1665
+ if (columns.some((col) => `${col.id}`.includes('.'))) {
1666
+ console.error(
1667
+ '[Slickgrid-Universal] Make sure that none of your Column Definition "id" property includes a dot in its name because that will cause some problems with the Editors. For example if your column definition "field" property is "user.firstName" then use "firstName" as the column "id".'
1668
+ );
1557
1669
  }
1558
1670
 
1559
1671
  return columns.map((column) => {
@@ -1566,10 +1678,16 @@ export class SlickVanillaGridBundle<TData = any> {
1566
1678
  }
1567
1679
 
1568
1680
  protected suggestDateParsingWhenHelpful(): void {
1569
- if (!this.gridOptions.silenceWarnings && this.dataView && this.dataView.getItemCount() > WARN_NO_PREPARSE_DATE_SIZE && !this.gridOptions.preParseDateColumns && this.slickGrid?.getColumns().some(c => isColumnDateType(c.type))) {
1681
+ if (
1682
+ !this.gridOptions.silenceWarnings &&
1683
+ this.dataView &&
1684
+ this.dataView.getItemCount() > WARN_NO_PREPARSE_DATE_SIZE &&
1685
+ !this.gridOptions.preParseDateColumns &&
1686
+ this.slickGrid?.getColumns().some((c) => isColumnDateType(c.type))
1687
+ ) {
1570
1688
  console.warn(
1571
1689
  '[Slickgrid-Universal] For getting better perf, we suggest you enable the `preParseDateColumns` grid option, ' +
1572
- 'for more info visit => https://ghiscoding.gitbook.io/slickgrid-universal/column-functionalities/sorting#pre-parse-date-columns-for-better-perf'
1690
+ 'for more info visit => https://ghiscoding.gitbook.io/slickgrid-universal/column-functionalities/sorting#pre-parse-date-columns-for-better-perf'
1573
1691
  );
1574
1692
  }
1575
1693
  }
@@ -1585,7 +1703,7 @@ export class SlickVanillaGridBundle<TData = any> {
1585
1703
 
1586
1704
  // get current Editor, remove it from the DOm then re-enable it and re-render it with the new collection.
1587
1705
  const currentEditor = this.slickGrid.getCellEditor() as AutocompleterEditor | SelectEditor;
1588
- if (currentEditor?.disable && currentEditor?.renderDomElement) {
1706
+ if (currentEditor?.disable && currentEditor.renderDomElement) {
1589
1707
  if (typeof currentEditor.destroy === 'function') {
1590
1708
  currentEditor.destroy();
1591
1709
  }