@slickgrid-universal/vanilla-bundle 5.10.2 → 5.12.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.
- package/dist/cjs/components/slick-vanilla-grid-bundle.js +127 -59
- package/dist/cjs/components/slick-vanilla-grid-bundle.js.map +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/services/universalContainer.service.js +2 -2
- package/dist/cjs/services/universalContainer.service.js.map +1 -1
- package/dist/esm/components/slick-vanilla-grid-bundle.js +129 -60
- package/dist/esm/components/slick-vanilla-grid-bundle.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/services/universalContainer.service.js +2 -2
- package/dist/esm/services/universalContainer.service.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/components/slick-vanilla-grid-bundle.d.ts +11 -1
- package/dist/types/components/slick-vanilla-grid-bundle.d.ts.map +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +10 -10
- package/src/components/slick-vanilla-grid-bundle.ts +240 -103
- package/src/index.ts +11 -2
- package/src/services/universalContainer.service.ts +2 -2
|
@@ -21,13 +21,7 @@ class SlickVanillaGridBundle {
|
|
|
21
21
|
return this._columnDefinitions || [];
|
|
22
22
|
}
|
|
23
23
|
set columnDefinitions(columnDefinitions) {
|
|
24
|
-
this.
|
|
25
|
-
if (this._slickgridInitialized) {
|
|
26
|
-
this.updateColumnDefinitionsList(this._columnDefinitions);
|
|
27
|
-
}
|
|
28
|
-
if (columnDefinitions.length > 0) {
|
|
29
|
-
this.copyColumnWidthsReference(columnDefinitions);
|
|
30
|
-
}
|
|
24
|
+
this.columnDefinitionsChanged(columnDefinitions);
|
|
31
25
|
}
|
|
32
26
|
get dataset() {
|
|
33
27
|
return this.dataView?.getItems() || [];
|
|
@@ -35,10 +29,13 @@ class SlickVanillaGridBundle {
|
|
|
35
29
|
set dataset(newDataset) {
|
|
36
30
|
const prevDatasetLn = this._currentDatasetLength;
|
|
37
31
|
const isDatasetEqual = (0, lite_1.dequal)(newDataset, this.dataset || []);
|
|
38
|
-
const isDeepCopyDataOnPageLoadEnabled = !!
|
|
32
|
+
const isDeepCopyDataOnPageLoadEnabled = !!this._gridOptions?.enableDeepCopyDatasetOnPageLoad;
|
|
39
33
|
let data = isDeepCopyDataOnPageLoadEnabled ? (0, utils_1.extend)(true, [], newDataset) : newDataset;
|
|
40
34
|
// when Tree Data is enabled and we don't yet have the hierarchical dataset filled, we can force a convert+sort of the array
|
|
41
|
-
if (this.slickGrid &&
|
|
35
|
+
if (this.slickGrid &&
|
|
36
|
+
this.gridOptions?.enableTreeData &&
|
|
37
|
+
Array.isArray(newDataset) &&
|
|
38
|
+
(newDataset.length > 0 || newDataset.length !== prevDatasetLn || !isDatasetEqual)) {
|
|
42
39
|
this._isDatasetHierarchicalInitialized = false;
|
|
43
40
|
data = this.sortTreeDataset(newDataset, !isDatasetEqual); // if dataset changed, then force a refresh anyway
|
|
44
41
|
}
|
|
@@ -86,11 +83,12 @@ class SlickVanillaGridBundle {
|
|
|
86
83
|
return this._gridOptions || {};
|
|
87
84
|
}
|
|
88
85
|
set gridOptions(options) {
|
|
86
|
+
options ??= {};
|
|
89
87
|
let mergedOptions;
|
|
90
88
|
// if we already have grid options, when grid was already initialized, we'll merge with those options
|
|
91
89
|
// else we'll merge with global grid options
|
|
92
90
|
if (this.slickGrid?.getOptions) {
|
|
93
|
-
mergedOptions = (
|
|
91
|
+
mergedOptions = (0, utils_1.extend)(true, {}, this.slickGrid.getOptions(), options);
|
|
94
92
|
}
|
|
95
93
|
else {
|
|
96
94
|
mergedOptions = this.mergeGridOptions(options);
|
|
@@ -147,6 +145,8 @@ class SlickVanillaGridBundle {
|
|
|
147
145
|
constructor(gridParentContainerElm, columnDefs, options, dataset, hierarchicalDataset, services) {
|
|
148
146
|
this._currentDatasetLength = 0;
|
|
149
147
|
this._darkMode = false;
|
|
148
|
+
this._collectionObservers = [];
|
|
149
|
+
this._gridOptions = {};
|
|
150
150
|
this._hideHeaderRowAfterPageLoad = false;
|
|
151
151
|
this._isAutosizeColsCalled = false;
|
|
152
152
|
this._isDatasetInitialized = false;
|
|
@@ -173,7 +173,7 @@ class SlickVanillaGridBundle {
|
|
|
173
173
|
gridParentContainerElm.appendChild(this._gridContainerElm);
|
|
174
174
|
// check if the user wants to hide the header row from the start
|
|
175
175
|
// we only want to do this check once in the constructor
|
|
176
|
-
this._hideHeaderRowAfterPageLoad =
|
|
176
|
+
this._hideHeaderRowAfterPageLoad = options?.showHeaderRow === false;
|
|
177
177
|
this._columnDefinitions = columnDefs || [];
|
|
178
178
|
if (this._columnDefinitions.length > 0) {
|
|
179
179
|
this.copyColumnWidthsReference(this._columnDefinitions);
|
|
@@ -182,7 +182,7 @@ class SlickVanillaGridBundle {
|
|
|
182
182
|
// since a deep copy of grid options would lose original resource refs but we want to keep them as singleton
|
|
183
183
|
this._registeredResources = options?.externalResources || [];
|
|
184
184
|
this._gridOptions = this.mergeGridOptions(options || {});
|
|
185
|
-
const isDeepCopyDataOnPageLoadEnabled = !!
|
|
185
|
+
const isDeepCopyDataOnPageLoadEnabled = !!this._gridOptions?.enableDeepCopyDatasetOnPageLoad;
|
|
186
186
|
// add dark mode CSS class when enabled
|
|
187
187
|
if (this._gridOptions.darkMode) {
|
|
188
188
|
this.setDarkMode(true);
|
|
@@ -198,19 +198,28 @@ class SlickVanillaGridBundle {
|
|
|
198
198
|
this.gridEventService = services?.gridEventService ?? new common_1.GridEventService();
|
|
199
199
|
this.sharedService = services?.sharedService ?? new common_1.SharedService();
|
|
200
200
|
this.collectionService = services?.collectionService ?? new common_1.CollectionService(this.translaterService);
|
|
201
|
-
this.extensionUtility =
|
|
201
|
+
this.extensionUtility =
|
|
202
|
+
services?.extensionUtility ?? new common_1.ExtensionUtility(this.sharedService, this.backendUtilityService, this.translaterService);
|
|
202
203
|
this.filterFactory = new common_1.FilterFactory(slickgridConfig, this.translaterService, this.collectionService);
|
|
204
|
+
// prettier-ignore
|
|
203
205
|
this.filterService = services?.filterService ?? new common_1.FilterService(this.filterFactory, this._eventPubSubService, this.sharedService, this.backendUtilityService);
|
|
204
206
|
this.resizerService = services?.resizerService ?? new common_1.ResizerService(this._eventPubSubService);
|
|
207
|
+
// prettier-ignore
|
|
205
208
|
this.sortService = services?.sortService ?? new common_1.SortService(this.collectionService, this.sharedService, this._eventPubSubService, this.backendUtilityService);
|
|
206
209
|
this.treeDataService = services?.treeDataService ?? new common_1.TreeDataService(this._eventPubSubService, this.sharedService, this.sortService);
|
|
210
|
+
// prettier-ignore
|
|
207
211
|
this.paginationService = services?.paginationService ?? new common_1.PaginationService(this._eventPubSubService, this.sharedService, this.backendUtilityService);
|
|
208
|
-
this.extensionService =
|
|
212
|
+
this.extensionService =
|
|
213
|
+
services?.extensionService ??
|
|
214
|
+
new common_1.ExtensionService(this.extensionUtility, this.filterService, this._eventPubSubService, this.sharedService, this.sortService, this.treeDataService, this.translaterService, () => this.gridService);
|
|
215
|
+
// prettier-ignore
|
|
209
216
|
this.gridStateService = services?.gridStateService ?? new common_1.GridStateService(this.extensionService, this.filterService, this._eventPubSubService, this.sharedService, this.sortService, this.treeDataService);
|
|
217
|
+
// prettier-ignore
|
|
210
218
|
this.gridService = services?.gridService ?? new common_1.GridService(this.gridStateService, this.filterService, this._eventPubSubService, this.paginationService, this.sharedService, this.sortService, this.treeDataService);
|
|
211
219
|
this.headerGroupingService = services?.headerGroupingService ?? new common_1.HeaderGroupingService(this.extensionUtility);
|
|
212
220
|
if (hierarchicalDataset) {
|
|
213
|
-
this.sharedService.hierarchicalDataset =
|
|
221
|
+
this.sharedService.hierarchicalDataset =
|
|
222
|
+
(isDeepCopyDataOnPageLoadEnabled ? (0, utils_1.extend)(true, [], hierarchicalDataset) : hierarchicalDataset) || [];
|
|
214
223
|
}
|
|
215
224
|
const eventHandler = new common_1.SlickEventHandler();
|
|
216
225
|
// register all service instances in the container
|
|
@@ -292,6 +301,7 @@ class SlickVanillaGridBundle {
|
|
|
292
301
|
if (shouldEmptyDomElementContainer) {
|
|
293
302
|
this.emptyGridContainerElm();
|
|
294
303
|
}
|
|
304
|
+
this._collectionObservers.forEach((obs) => obs?.disconnect());
|
|
295
305
|
this._eventPubSubService?.dispose();
|
|
296
306
|
this._slickerGridInstances = null;
|
|
297
307
|
}
|
|
@@ -308,7 +318,10 @@ class SlickVanillaGridBundle {
|
|
|
308
318
|
}
|
|
309
319
|
initialization(gridContainerElm, eventHandler, inputDataset) {
|
|
310
320
|
// when detecting a frozen grid, we'll automatically enable the mousewheel scroll handler so that we can scroll from both left/right frozen containers
|
|
311
|
-
if (this.gridOptions &&
|
|
321
|
+
if (this.gridOptions &&
|
|
322
|
+
((this.gridOptions.frozenRow !== undefined && this.gridOptions.frozenRow >= 0) ||
|
|
323
|
+
(this.gridOptions.frozenColumn !== undefined && this.gridOptions.frozenColumn >= 0)) &&
|
|
324
|
+
this.gridOptions.enableMouseWheelScrollHandler === undefined) {
|
|
312
325
|
this.gridOptions.enableMouseWheelScrollHandler = true;
|
|
313
326
|
}
|
|
314
327
|
// create the slickgrid container and add it to the user's grid container
|
|
@@ -490,6 +503,8 @@ class SlickVanillaGridBundle {
|
|
|
490
503
|
this._eventPubSubService.publish('onSlickerGridCreated', this.instances);
|
|
491
504
|
this._isGridInitialized = true;
|
|
492
505
|
this.suggestDateParsingWhenHelpful();
|
|
506
|
+
// subscribe to column definitions assignment changes
|
|
507
|
+
this.observeColumnDefinitions();
|
|
493
508
|
}
|
|
494
509
|
hasBackendInfiniteScroll() {
|
|
495
510
|
return !!this.backendService?.options?.infiniteScroll;
|
|
@@ -503,7 +518,10 @@ class SlickVanillaGridBundle {
|
|
|
503
518
|
// using copy extend to do a deep clone has an unwanted side on objects and pageSizes but ES6 spread has other worst side effects
|
|
504
519
|
// so we will just overwrite the pageSizes when needed, this is the only one causing issues so far.
|
|
505
520
|
// On a deep extend, Object and Array are extended, but object wrappers on primitive types such as String, Boolean, and Number are not.
|
|
506
|
-
if (options?.pagination &&
|
|
521
|
+
if (options?.pagination &&
|
|
522
|
+
(gridOptions.enablePagination || gridOptions.backendServiceApi) &&
|
|
523
|
+
gridOptions.pagination &&
|
|
524
|
+
Array.isArray(gridOptions.pagination.pageSizes)) {
|
|
507
525
|
options.pagination.pageSizes = gridOptions.pagination.pageSizes;
|
|
508
526
|
}
|
|
509
527
|
// when we use Pagination on Local Grid, it doesn't seem to work without enableFiltering
|
|
@@ -528,10 +546,15 @@ class SlickVanillaGridBundle {
|
|
|
528
546
|
// internalPostProcess only works (for now) with a GraphQL Service, so make sure it is of that type
|
|
529
547
|
if ( /* backendApiService instanceof GraphqlService || */typeof backendApiService.getDatasetName === 'function') {
|
|
530
548
|
backendApi.internalPostProcess = (processResult) => {
|
|
549
|
+
// prettier-ignore
|
|
531
550
|
const datasetName = (backendApi && backendApiService && typeof backendApiService.getDatasetName === 'function') ? backendApiService.getDatasetName() : '';
|
|
532
551
|
if (processResult && processResult.data && processResult.data[datasetName]) {
|
|
533
|
-
const data = processResult.data[datasetName].hasOwnProperty('nodes')
|
|
534
|
-
|
|
552
|
+
const data = processResult.data[datasetName].hasOwnProperty('nodes')
|
|
553
|
+
? processResult.data[datasetName].nodes
|
|
554
|
+
: processResult.data[datasetName];
|
|
555
|
+
const totalCount = processResult.data[datasetName].hasOwnProperty('totalCount')
|
|
556
|
+
? processResult.data[datasetName].totalCount
|
|
557
|
+
: processResult.data[datasetName].length;
|
|
535
558
|
this.refreshGridData(data, totalCount || 0);
|
|
536
559
|
}
|
|
537
560
|
};
|
|
@@ -552,7 +575,8 @@ class SlickVanillaGridBundle {
|
|
|
552
575
|
this.subscriptions.push(this._eventPubSubService.subscribe('onLanguageChange', (args) => {
|
|
553
576
|
if (gridOptions.enableTranslate) {
|
|
554
577
|
this.extensionService.translateAllExtensions(args.language);
|
|
555
|
-
if ((gridOptions.createPreHeaderPanel && gridOptions.createTopHeaderPanel) ||
|
|
578
|
+
if ((gridOptions.createPreHeaderPanel && gridOptions.createTopHeaderPanel) ||
|
|
579
|
+
(gridOptions.createPreHeaderPanel && !gridOptions.enableDraggableGrouping)) {
|
|
556
580
|
this.headerGroupingService.translateHeaderGrouping();
|
|
557
581
|
}
|
|
558
582
|
}
|
|
@@ -596,20 +620,19 @@ class SlickVanillaGridBundle {
|
|
|
596
620
|
this.sharedService.isItemsDateParsed = false;
|
|
597
621
|
this.handleOnItemCountChanged(this.dataView?.getFilteredItemCount() || 0, args.itemCount);
|
|
598
622
|
// when user has resize by content enabled, we'll force a full width calculation since we change our entire dataset
|
|
599
|
-
if (args.itemCount > 0 &&
|
|
623
|
+
if (args.itemCount > 0 &&
|
|
624
|
+
(this.gridOptions.autosizeColumnsByCellContentOnFirstLoad || this.gridOptions.enableAutoResizeColumnsByCellContent)) {
|
|
600
625
|
this.resizerService.resizeColumnsByCellContent(!this.gridOptions?.resizeByContentOnlyOnFirstLoad);
|
|
601
626
|
}
|
|
602
627
|
});
|
|
603
|
-
if (gridOptions?.enableFiltering && !gridOptions.enableRowDetailView) {
|
|
628
|
+
if ((gridOptions?.enableFiltering || gridOptions?.dataView?.globalItemMetadataProvider) && !gridOptions.enableRowDetailView) {
|
|
604
629
|
this._eventHandler.subscribe(dataView.onRowsChanged, (_e, { calledOnRowCountChanged, rows }) => {
|
|
605
630
|
// filtering data with local dataset will not always show correctly unless we call this updateRow/render
|
|
606
631
|
// also don't use "invalidateRows" since it destroys the entire row and as bad user experience when updating a row
|
|
607
632
|
// see commit: https://github.com/ghiscoding/aurelia-slickgrid/commit/8c503a4d45fba11cbd8d8cc467fae8d177cc4f60
|
|
608
633
|
if (!calledOnRowCountChanged && Array.isArray(rows)) {
|
|
609
634
|
const ranges = grid.getRenderedRange();
|
|
610
|
-
rows
|
|
611
|
-
.filter(row => row >= ranges.top && row <= ranges.bottom)
|
|
612
|
-
.forEach((row) => grid.updateRow(row));
|
|
635
|
+
rows.filter((row) => row >= ranges.top && row <= ranges.bottom).forEach((row) => grid.updateRow(row));
|
|
613
636
|
grid.render();
|
|
614
637
|
}
|
|
615
638
|
});
|
|
@@ -629,6 +652,7 @@ class SlickVanillaGridBundle {
|
|
|
629
652
|
this.loadColumnPresetsWhenDatasetInitialized();
|
|
630
653
|
this.loadFilterPresetsWhenDatasetInitialized();
|
|
631
654
|
}
|
|
655
|
+
// @deprecated @user `dataview.globalItemMetadataProvider.getRowMetadata`
|
|
632
656
|
// did the user add a colspan callback? If so, hook it into the DataView getItemMetadata
|
|
633
657
|
if (gridOptions?.colspanCallback && dataView?.getItem && dataView?.getItemMetadata) {
|
|
634
658
|
dataView.getItemMetadata = (rowNumber) => {
|
|
@@ -644,6 +668,7 @@ class SlickVanillaGridBundle {
|
|
|
644
668
|
const backendApi = gridOptions.backendServiceApi;
|
|
645
669
|
const backendApiService = backendApi?.service;
|
|
646
670
|
const serviceOptions = backendApiService?.options ?? {};
|
|
671
|
+
// prettier-ignore
|
|
647
672
|
const isExecuteCommandOnInit = (!serviceOptions) ? false : ((serviceOptions?.hasOwnProperty('executeProcessCommandOnInit')) ? serviceOptions['executeProcessCommandOnInit'] : true);
|
|
648
673
|
if (backendApiService) {
|
|
649
674
|
// update backend filters (if need be) BEFORE the query runs (via the onInit command a few lines below)
|
|
@@ -673,7 +698,7 @@ class SlickVanillaGridBundle {
|
|
|
673
698
|
}
|
|
674
699
|
// execute onInit command when necessary
|
|
675
700
|
if (backendApi && backendApiService && (backendApi.onInit || isExecuteCommandOnInit)) {
|
|
676
|
-
const query =
|
|
701
|
+
const query = typeof backendApiService.buildQuery === 'function' ? backendApiService.buildQuery() : '';
|
|
677
702
|
const process = isExecuteCommandOnInit ? (backendApi.process?.(query) ?? null) : (backendApi.onInit?.(query) ?? null);
|
|
678
703
|
// 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
|
|
679
704
|
queueMicrotask(() => {
|
|
@@ -703,13 +728,16 @@ class SlickVanillaGridBundle {
|
|
|
703
728
|
}
|
|
704
729
|
}
|
|
705
730
|
addBackendInfiniteScrollCallback() {
|
|
706
|
-
if (this.slickGrid &&
|
|
731
|
+
if (this.slickGrid &&
|
|
732
|
+
this.gridOptions.backendServiceApi &&
|
|
733
|
+
this.hasBackendInfiniteScroll() &&
|
|
734
|
+
!this.gridOptions.backendServiceApi?.onScrollEnd) {
|
|
707
735
|
const onScrollEnd = () => {
|
|
708
736
|
this.backendUtilityService.setInfiniteScrollBottomHit(true);
|
|
709
737
|
// even if we're not showing pagination, we still use pagination service behind the scene
|
|
710
738
|
// to keep track of the scroll position and fetch next set of data (aka next page)
|
|
711
739
|
// we also need a flag to know if we reached the of the dataset or not (no more pages)
|
|
712
|
-
this.paginationService.goToNextPage().then(hasNext => {
|
|
740
|
+
this.paginationService.goToNextPage().then((hasNext) => {
|
|
713
741
|
if (!hasNext) {
|
|
714
742
|
this.backendUtilityService.setInfiniteScrollBottomHit(false);
|
|
715
743
|
}
|
|
@@ -720,10 +748,10 @@ class SlickVanillaGridBundle {
|
|
|
720
748
|
// run onScrollEnd() method when that happens
|
|
721
749
|
this._eventHandler.subscribe(this.slickGrid.onScroll, (_e, args) => {
|
|
722
750
|
const viewportElm = args.grid.getViewportNode();
|
|
723
|
-
if (['mousewheel', 'scroll'].includes(args.triggeredBy || '')
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
751
|
+
if (['mousewheel', 'scroll'].includes(args.triggeredBy || '') &&
|
|
752
|
+
this.paginationService?.totalItems &&
|
|
753
|
+
args.scrollTop > 0 &&
|
|
754
|
+
Math.ceil(viewportElm.offsetHeight + args.scrollTop) >= args.scrollHeight) {
|
|
727
755
|
if (!this._scrollEndCalled) {
|
|
728
756
|
onScrollEnd();
|
|
729
757
|
this._scrollEndCalled = true;
|
|
@@ -742,7 +770,8 @@ class SlickVanillaGridBundle {
|
|
|
742
770
|
}
|
|
743
771
|
}
|
|
744
772
|
bindResizeHook(grid, options) {
|
|
745
|
-
if ((options.autoFitColumnsOnFirstLoad && options.autosizeColumnsByCellContentOnFirstLoad) ||
|
|
773
|
+
if ((options.autoFitColumnsOnFirstLoad && options.autosizeColumnsByCellContentOnFirstLoad) ||
|
|
774
|
+
(options.enableAutoSizeColumns && options.enableAutoResizeColumnsByCellContent)) {
|
|
746
775
|
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").`);
|
|
747
776
|
}
|
|
748
777
|
// auto-resize grid on browser resize (optionally provide grid height or width)
|
|
@@ -753,7 +782,11 @@ class SlickVanillaGridBundle {
|
|
|
753
782
|
this.resizerService.resizeGrid();
|
|
754
783
|
}
|
|
755
784
|
// expand/autofit columns on first page load
|
|
756
|
-
if (grid &&
|
|
785
|
+
if (grid &&
|
|
786
|
+
options?.enableAutoResize &&
|
|
787
|
+
options.autoFitColumnsOnFirstLoad &&
|
|
788
|
+
options.enableAutoSizeColumns &&
|
|
789
|
+
!this._isAutosizeColsCalled) {
|
|
757
790
|
grid.autosizeColumns();
|
|
758
791
|
this._isAutosizeColsCalled = true;
|
|
759
792
|
}
|
|
@@ -774,7 +807,10 @@ class SlickVanillaGridBundle {
|
|
|
774
807
|
*/
|
|
775
808
|
paginationChanged(pagination) {
|
|
776
809
|
const isSyncGridSelectionEnabled = this.gridStateService?.needToPreserveRowSelection() ?? false;
|
|
777
|
-
if (this.slickGrid &&
|
|
810
|
+
if (this.slickGrid &&
|
|
811
|
+
!isSyncGridSelectionEnabled &&
|
|
812
|
+
this._gridOptions?.backendServiceApi &&
|
|
813
|
+
(this.gridOptions.enableRowSelection || this.gridOptions.enableCheckboxSelector)) {
|
|
778
814
|
this.slickGrid.setSelectedRows([]);
|
|
779
815
|
}
|
|
780
816
|
const { pageNumber, pageSize } = pagination;
|
|
@@ -783,7 +819,7 @@ class SlickVanillaGridBundle {
|
|
|
783
819
|
}
|
|
784
820
|
this._eventPubSubService.publish('onGridStateChanged', {
|
|
785
821
|
change: { newValues: { pageNumber, pageSize }, type: common_1.GridStateType.pagination },
|
|
786
|
-
gridState: this.gridStateService.getCurrentGridState()
|
|
822
|
+
gridState: this.gridStateService.getCurrentGridState(),
|
|
787
823
|
});
|
|
788
824
|
}
|
|
789
825
|
/**
|
|
@@ -817,12 +853,13 @@ class SlickVanillaGridBundle {
|
|
|
817
853
|
this.slickGrid.invalidate();
|
|
818
854
|
}
|
|
819
855
|
// 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
|
|
820
|
-
this.showPagination = !!(this._gridOptions &&
|
|
856
|
+
this.showPagination = !!(this._gridOptions &&
|
|
857
|
+
(this._gridOptions.enablePagination || (this._gridOptions.backendServiceApi && this._gridOptions.enablePagination === undefined)));
|
|
821
858
|
if (this._paginationOptions && this._gridOptions?.pagination && this._gridOptions?.backendServiceApi) {
|
|
822
859
|
const paginationOptions = this.setPaginationOptionsWhenPresetDefined(this._gridOptions, this._paginationOptions);
|
|
823
860
|
// when we have a totalCount use it, else we'll take it from the pagination object
|
|
824
861
|
// only update the total items if it's different to avoid refreshing the UI
|
|
825
|
-
const totalRecords =
|
|
862
|
+
const totalRecords = totalCount !== undefined ? totalCount : this._gridOptions?.pagination?.totalItems;
|
|
826
863
|
if (totalRecords !== undefined && totalRecords !== this.totalItems) {
|
|
827
864
|
this.totalItems = +totalRecords;
|
|
828
865
|
}
|
|
@@ -920,7 +957,7 @@ class SlickVanillaGridBundle {
|
|
|
920
957
|
* We will use this when doing a resize by cell content, if user provided a `width` it won't override it.
|
|
921
958
|
*/
|
|
922
959
|
copyColumnWidthsReference(columnDefinitions) {
|
|
923
|
-
columnDefinitions.forEach(col => col.originalWidth = col.width);
|
|
960
|
+
columnDefinitions.forEach((col) => (col.originalWidth = col.width));
|
|
924
961
|
}
|
|
925
962
|
displayEmptyDataWarning(showWarning = true) {
|
|
926
963
|
if (this.gridOptions.enableEmptyDataWarningMessage) {
|
|
@@ -934,7 +971,7 @@ class SlickVanillaGridBundle {
|
|
|
934
971
|
startTime: new Date(),
|
|
935
972
|
endTime: new Date(),
|
|
936
973
|
itemCount: currentPageRowItemCount,
|
|
937
|
-
totalItemCount
|
|
974
|
+
totalItemCount,
|
|
938
975
|
};
|
|
939
976
|
// if custom footer is enabled, then we'll update its metrics
|
|
940
977
|
if (this.slickFooter) {
|
|
@@ -954,7 +991,7 @@ class SlickVanillaGridBundle {
|
|
|
954
991
|
};
|
|
955
992
|
this.paginationService.totalItems = this.totalItems;
|
|
956
993
|
this.paginationService.init(this.slickGrid, paginationOptions, this.backendServiceApi);
|
|
957
|
-
this.subscriptions.push(this._eventPubSubService.subscribe('onPaginationChanged', paginationChanges => this.paginationChanged(paginationChanges)), this._eventPubSubService.subscribe('onPaginationVisibilityChanged', visibility => {
|
|
994
|
+
this.subscriptions.push(this._eventPubSubService.subscribe('onPaginationChanged', (paginationChanges) => this.paginationChanged(paginationChanges)), this._eventPubSubService.subscribe('onPaginationVisibilityChanged', (visibility) => {
|
|
958
995
|
this.showPagination = visibility?.visible ?? false;
|
|
959
996
|
if (this.gridOptions?.backendServiceApi) {
|
|
960
997
|
this.backendUtilityService?.refreshBackendDataset(this.gridOptions);
|
|
@@ -966,6 +1003,25 @@ class SlickVanillaGridBundle {
|
|
|
966
1003
|
this._isPaginationInitialized = true;
|
|
967
1004
|
}
|
|
968
1005
|
}
|
|
1006
|
+
/** handler for when column definitions changes */
|
|
1007
|
+
columnDefinitionsChanged(columnDefinitions) {
|
|
1008
|
+
if (columnDefinitions) {
|
|
1009
|
+
this._columnDefinitions = columnDefinitions;
|
|
1010
|
+
}
|
|
1011
|
+
if (this._isGridInitialized) {
|
|
1012
|
+
this.updateColumnDefinitionsList(this.columnDefinitions);
|
|
1013
|
+
}
|
|
1014
|
+
if (this.columnDefinitions.length > 0) {
|
|
1015
|
+
this.copyColumnWidthsReference(this.columnDefinitions);
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
/**
|
|
1019
|
+
* assignment changes are not triggering on the column definitions, for that
|
|
1020
|
+
* we can use our internal array observer for any changes done via (push, pop, shift, ...)
|
|
1021
|
+
*/
|
|
1022
|
+
observeColumnDefinitions() {
|
|
1023
|
+
this._collectionObservers.push((0, common_1.collectionObserver)(this.columnDefinitions, this.columnDefinitionsChanged.bind(this)));
|
|
1024
|
+
}
|
|
969
1025
|
/**
|
|
970
1026
|
* Render (or dispose) the Pagination Component, user can optionally provide False (to not show it) which will in term dispose of the Pagination,
|
|
971
1027
|
* also while disposing we can choose to omit the disposable of the Pagination Service (if we are simply toggling the Pagination, we want to keep the Service alive)
|
|
@@ -999,12 +1055,12 @@ class SlickVanillaGridBundle {
|
|
|
999
1055
|
}
|
|
1000
1056
|
else if (response?.status >= 200 && response.status < 300 && typeof response.json === 'function') {
|
|
1001
1057
|
if (response.bodyUsed) {
|
|
1002
|
-
console.warn(`[SlickGrid-Universal] The response body passed to collectionAsync was already read.`
|
|
1003
|
-
|
|
1058
|
+
console.warn(`[SlickGrid-Universal] The response body passed to collectionAsync was already read.` +
|
|
1059
|
+
`Either pass the dataset from the Response or clone the response first using response.clone()`);
|
|
1004
1060
|
}
|
|
1005
1061
|
else {
|
|
1006
1062
|
// from Fetch
|
|
1007
|
-
response.json().then(data => this.updateEditorCollection(column, data));
|
|
1063
|
+
response.json().then((data) => this.updateEditorCollection(column, data));
|
|
1008
1064
|
}
|
|
1009
1065
|
}
|
|
1010
1066
|
else if (response?.content) {
|
|
@@ -1022,13 +1078,11 @@ class SlickVanillaGridBundle {
|
|
|
1022
1078
|
}
|
|
1023
1079
|
insertDynamicPresetColumns(columnId, gridPresetColumns) {
|
|
1024
1080
|
if (this._columnDefinitions) {
|
|
1025
|
-
const columnPosition = this._columnDefinitions.findIndex(c => c.id === columnId);
|
|
1081
|
+
const columnPosition = this._columnDefinitions.findIndex((c) => c.id === columnId);
|
|
1026
1082
|
if (columnPosition >= 0) {
|
|
1027
1083
|
const dynColumn = this._columnDefinitions[columnPosition];
|
|
1028
|
-
if (dynColumn?.id === columnId && !gridPresetColumns.some(c => c.id === columnId)) {
|
|
1029
|
-
columnPosition > 0
|
|
1030
|
-
? gridPresetColumns.splice(columnPosition, 0, dynColumn)
|
|
1031
|
-
: gridPresetColumns.unshift(dynColumn);
|
|
1084
|
+
if (dynColumn?.id === columnId && !gridPresetColumns.some((c) => c.id === columnId)) {
|
|
1085
|
+
columnPosition > 0 ? gridPresetColumns.splice(columnPosition, 0, dynColumn) : gridPresetColumns.unshift(dynColumn);
|
|
1032
1086
|
}
|
|
1033
1087
|
}
|
|
1034
1088
|
}
|
|
@@ -1036,7 +1090,10 @@ class SlickVanillaGridBundle {
|
|
|
1036
1090
|
/** Load any possible Columns Grid Presets */
|
|
1037
1091
|
loadColumnPresetsWhenDatasetInitialized() {
|
|
1038
1092
|
// if user entered some Columns "presets", we need to reflect them all in the grid
|
|
1039
|
-
if (this.slickGrid &&
|
|
1093
|
+
if (this.slickGrid &&
|
|
1094
|
+
this.gridOptions.presets &&
|
|
1095
|
+
Array.isArray(this.gridOptions.presets.columns) &&
|
|
1096
|
+
this.gridOptions.presets.columns.length > 0) {
|
|
1040
1097
|
const gridPresetColumns = this.gridStateService.getAssociatedGridColumns(this.slickGrid, this.gridOptions.presets.columns);
|
|
1041
1098
|
if (gridPresetColumns && Array.isArray(gridPresetColumns) && gridPresetColumns.length > 0 && Array.isArray(this._columnDefinitions)) {
|
|
1042
1099
|
// make sure that the dynamic columns are included in presets (1.Row Move, 2. Row Selection, 3. Row Detail)
|
|
@@ -1054,7 +1111,7 @@ class SlickVanillaGridBundle {
|
|
|
1054
1111
|
}
|
|
1055
1112
|
// keep copy the original optional `width` properties optionally provided by the user.
|
|
1056
1113
|
// We will use this when doing a resize by cell content, if user provided a `width` it won't override it.
|
|
1057
|
-
gridPresetColumns.forEach(col => col.originalWidth = col.width);
|
|
1114
|
+
gridPresetColumns.forEach((col) => (col.originalWidth = col.width));
|
|
1058
1115
|
// finally set the new presets columns (including checkbox selector if need be)
|
|
1059
1116
|
this.slickGrid.setColumns(gridPresetColumns);
|
|
1060
1117
|
this.sharedService.visibleColumns = gridPresetColumns;
|
|
@@ -1067,7 +1124,8 @@ class SlickVanillaGridBundle {
|
|
|
1067
1124
|
// if user entered some Filter "presets", we need to reflect them all in the DOM
|
|
1068
1125
|
// also note that a presets of Tree Data Toggling will also call this method because Tree Data toggling does work with data filtering
|
|
1069
1126
|
// (collapsing a parent will basically use Filter for hidding (aka collapsing) away the child underneat it)
|
|
1070
|
-
if (this.gridOptions.presets &&
|
|
1127
|
+
if (this.gridOptions.presets &&
|
|
1128
|
+
(Array.isArray(this.gridOptions.presets.filters) || Array.isArray(this.gridOptions.presets?.treeData?.toggledItems))) {
|
|
1071
1129
|
this.filterService.populateColumnFilterSearchTermPresets(this.gridOptions.presets?.filters || []);
|
|
1072
1130
|
}
|
|
1073
1131
|
}
|
|
@@ -1097,7 +1155,12 @@ class SlickVanillaGridBundle {
|
|
|
1097
1155
|
const presets = this.gridOptions?.presets;
|
|
1098
1156
|
const selectionModel = this.slickGrid?.getSelectionModel();
|
|
1099
1157
|
const enableRowSelection = this.gridOptions && (this.gridOptions.enableCheckboxSelector || this.gridOptions.enableRowSelection);
|
|
1100
|
-
if (this.slickGrid &&
|
|
1158
|
+
if (this.slickGrid &&
|
|
1159
|
+
this.dataView &&
|
|
1160
|
+
enableRowSelection &&
|
|
1161
|
+
selectionModel &&
|
|
1162
|
+
presets?.rowSelection &&
|
|
1163
|
+
(Array.isArray(presets.rowSelection.gridRowIndexes) || Array.isArray(presets.rowSelection.dataContextIds))) {
|
|
1101
1164
|
let dataContextIds = presets.rowSelection.dataContextIds;
|
|
1102
1165
|
let gridRowIndexes = presets.rowSelection.gridRowIndexes;
|
|
1103
1166
|
// maps the IDs to the Grid Rows and vice versa, the "dataContextIds" has precedence over the other
|
|
@@ -1113,7 +1176,7 @@ class SlickVanillaGridBundle {
|
|
|
1113
1176
|
this.dataView.setSelectedIds(dataContextIds || [], {
|
|
1114
1177
|
isRowBeingAdded: true,
|
|
1115
1178
|
shouldTriggerEvent: false, // do not trigger when presetting the grid
|
|
1116
|
-
applyRowSelectionToGrid: true
|
|
1179
|
+
applyRowSelectionToGrid: true,
|
|
1117
1180
|
});
|
|
1118
1181
|
}
|
|
1119
1182
|
}
|
|
@@ -1123,7 +1186,7 @@ class SlickVanillaGridBundle {
|
|
|
1123
1186
|
if (disposePreviousResources) {
|
|
1124
1187
|
this.disposeExternalResources();
|
|
1125
1188
|
}
|
|
1126
|
-
resources.forEach(res => this._registeredResources.push(res));
|
|
1189
|
+
resources.forEach((res) => this._registeredResources.push(res));
|
|
1127
1190
|
this.initializeExternalResources(resources);
|
|
1128
1191
|
}
|
|
1129
1192
|
resetExternalResources() {
|
|
@@ -1158,7 +1221,8 @@ class SlickVanillaGridBundle {
|
|
|
1158
1221
|
// push all other Services that we want to be registered
|
|
1159
1222
|
this._registeredResources.push(this.gridService, this.gridStateService);
|
|
1160
1223
|
// when using Grouping/DraggableGrouping/Colspan register its Service
|
|
1161
|
-
if ((this.gridOptions.createPreHeaderPanel && this.gridOptions.createTopHeaderPanel) ||
|
|
1224
|
+
if ((this.gridOptions.createPreHeaderPanel && this.gridOptions.createTopHeaderPanel) ||
|
|
1225
|
+
(this.gridOptions.createPreHeaderPanel && !this.gridOptions.enableDraggableGrouping)) {
|
|
1162
1226
|
this._registeredResources.push(this.headerGroupingService);
|
|
1163
1227
|
}
|
|
1164
1228
|
// when using Tree Data View, register its Service
|
|
@@ -1216,7 +1280,7 @@ class SlickVanillaGridBundle {
|
|
|
1216
1280
|
/** Prepare and load all SlickGrid editors, if an async editor is found then we'll also execute it. */
|
|
1217
1281
|
loadSlickGridEditors(columnDefinitions) {
|
|
1218
1282
|
const columns = Array.isArray(columnDefinitions) ? columnDefinitions : [];
|
|
1219
|
-
if (columns.some(col => `${col.id}`.includes('.'))) {
|
|
1283
|
+
if (columns.some((col) => `${col.id}`.includes('.'))) {
|
|
1220
1284
|
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".');
|
|
1221
1285
|
}
|
|
1222
1286
|
return columns.map((column) => {
|
|
@@ -1228,7 +1292,11 @@ class SlickVanillaGridBundle {
|
|
|
1228
1292
|
});
|
|
1229
1293
|
}
|
|
1230
1294
|
suggestDateParsingWhenHelpful() {
|
|
1231
|
-
if (!this.gridOptions.silenceWarnings &&
|
|
1295
|
+
if (!this.gridOptions.silenceWarnings &&
|
|
1296
|
+
this.dataView &&
|
|
1297
|
+
this.dataView.getItemCount() > WARN_NO_PREPARSE_DATE_SIZE &&
|
|
1298
|
+
!this.gridOptions.preParseDateColumns &&
|
|
1299
|
+
this.slickGrid?.getColumns().some((c) => (0, common_1.isColumnDateType)(c.type))) {
|
|
1232
1300
|
console.warn('[Slickgrid-Universal] For getting better perf, we suggest you enable the `preParseDateColumns` grid option, ' +
|
|
1233
1301
|
'for more info visit => https://ghiscoding.gitbook.io/slickgrid-universal/column-functionalities/sorting#pre-parse-date-columns-for-better-perf');
|
|
1234
1302
|
}
|
|
@@ -1243,7 +1311,7 @@ class SlickVanillaGridBundle {
|
|
|
1243
1311
|
column.editor.disabled = false;
|
|
1244
1312
|
// get current Editor, remove it from the DOm then re-enable it and re-render it with the new collection.
|
|
1245
1313
|
const currentEditor = this.slickGrid.getCellEditor();
|
|
1246
|
-
if (currentEditor?.disable && currentEditor
|
|
1314
|
+
if (currentEditor?.disable && currentEditor.renderDomElement) {
|
|
1247
1315
|
if (typeof currentEditor.destroy === 'function') {
|
|
1248
1316
|
currentEditor.destroy();
|
|
1249
1317
|
}
|