@slickgrid-universal/vanilla-bundle 5.11.0 → 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 +102 -53
- 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 +102 -53
- 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 +2 -2
- 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 +9 -9
- package/src/components/slick-vanilla-grid-bundle.ts +213 -100
- package/src/index.ts +11 -2
- package/src/services/universalContainer.service.ts +2 -2
|
@@ -31,10 +31,13 @@ export class SlickVanillaGridBundle {
|
|
|
31
31
|
set dataset(newDataset) {
|
|
32
32
|
const prevDatasetLn = this._currentDatasetLength;
|
|
33
33
|
const isDatasetEqual = dequal(newDataset, this.dataset || []);
|
|
34
|
-
const isDeepCopyDataOnPageLoadEnabled = !!
|
|
34
|
+
const isDeepCopyDataOnPageLoadEnabled = !!this._gridOptions?.enableDeepCopyDatasetOnPageLoad;
|
|
35
35
|
let data = isDeepCopyDataOnPageLoadEnabled ? extend(true, [], newDataset) : newDataset;
|
|
36
36
|
// when Tree Data is enabled and we don't yet have the hierarchical dataset filled, we can force a convert+sort of the array
|
|
37
|
-
if (this.slickGrid &&
|
|
37
|
+
if (this.slickGrid &&
|
|
38
|
+
this.gridOptions?.enableTreeData &&
|
|
39
|
+
Array.isArray(newDataset) &&
|
|
40
|
+
(newDataset.length > 0 || newDataset.length !== prevDatasetLn || !isDatasetEqual)) {
|
|
38
41
|
this._isDatasetHierarchicalInitialized = false;
|
|
39
42
|
data = this.sortTreeDataset(newDataset, !isDatasetEqual); // if dataset changed, then force a refresh anyway
|
|
40
43
|
}
|
|
@@ -87,7 +90,7 @@ export class SlickVanillaGridBundle {
|
|
|
87
90
|
// if we already have grid options, when grid was already initialized, we'll merge with those options
|
|
88
91
|
// else we'll merge with global grid options
|
|
89
92
|
if (this.slickGrid?.getOptions) {
|
|
90
|
-
mergedOptions =
|
|
93
|
+
mergedOptions = extend(true, {}, this.slickGrid.getOptions(), options);
|
|
91
94
|
}
|
|
92
95
|
else {
|
|
93
96
|
mergedOptions = this.mergeGridOptions(options);
|
|
@@ -172,7 +175,7 @@ export class SlickVanillaGridBundle {
|
|
|
172
175
|
gridParentContainerElm.appendChild(this._gridContainerElm);
|
|
173
176
|
// check if the user wants to hide the header row from the start
|
|
174
177
|
// we only want to do this check once in the constructor
|
|
175
|
-
this._hideHeaderRowAfterPageLoad =
|
|
178
|
+
this._hideHeaderRowAfterPageLoad = options?.showHeaderRow === false;
|
|
176
179
|
this._columnDefinitions = columnDefs || [];
|
|
177
180
|
if (this._columnDefinitions.length > 0) {
|
|
178
181
|
this.copyColumnWidthsReference(this._columnDefinitions);
|
|
@@ -181,7 +184,7 @@ export class SlickVanillaGridBundle {
|
|
|
181
184
|
// since a deep copy of grid options would lose original resource refs but we want to keep them as singleton
|
|
182
185
|
this._registeredResources = options?.externalResources || [];
|
|
183
186
|
this._gridOptions = this.mergeGridOptions(options || {});
|
|
184
|
-
const isDeepCopyDataOnPageLoadEnabled = !!
|
|
187
|
+
const isDeepCopyDataOnPageLoadEnabled = !!this._gridOptions?.enableDeepCopyDatasetOnPageLoad;
|
|
185
188
|
// add dark mode CSS class when enabled
|
|
186
189
|
if (this._gridOptions.darkMode) {
|
|
187
190
|
this.setDarkMode(true);
|
|
@@ -197,19 +200,28 @@ export class SlickVanillaGridBundle {
|
|
|
197
200
|
this.gridEventService = services?.gridEventService ?? new GridEventService();
|
|
198
201
|
this.sharedService = services?.sharedService ?? new SharedService();
|
|
199
202
|
this.collectionService = services?.collectionService ?? new CollectionService(this.translaterService);
|
|
200
|
-
this.extensionUtility =
|
|
203
|
+
this.extensionUtility =
|
|
204
|
+
services?.extensionUtility ?? new ExtensionUtility(this.sharedService, this.backendUtilityService, this.translaterService);
|
|
201
205
|
this.filterFactory = new FilterFactory(slickgridConfig, this.translaterService, this.collectionService);
|
|
206
|
+
// prettier-ignore
|
|
202
207
|
this.filterService = services?.filterService ?? new FilterService(this.filterFactory, this._eventPubSubService, this.sharedService, this.backendUtilityService);
|
|
203
208
|
this.resizerService = services?.resizerService ?? new ResizerService(this._eventPubSubService);
|
|
209
|
+
// prettier-ignore
|
|
204
210
|
this.sortService = services?.sortService ?? new SortService(this.collectionService, this.sharedService, this._eventPubSubService, this.backendUtilityService);
|
|
205
211
|
this.treeDataService = services?.treeDataService ?? new TreeDataService(this._eventPubSubService, this.sharedService, this.sortService);
|
|
212
|
+
// prettier-ignore
|
|
206
213
|
this.paginationService = services?.paginationService ?? new PaginationService(this._eventPubSubService, this.sharedService, this.backendUtilityService);
|
|
207
|
-
this.extensionService =
|
|
214
|
+
this.extensionService =
|
|
215
|
+
services?.extensionService ??
|
|
216
|
+
new ExtensionService(this.extensionUtility, this.filterService, this._eventPubSubService, this.sharedService, this.sortService, this.treeDataService, this.translaterService, () => this.gridService);
|
|
217
|
+
// prettier-ignore
|
|
208
218
|
this.gridStateService = services?.gridStateService ?? new GridStateService(this.extensionService, this.filterService, this._eventPubSubService, this.sharedService, this.sortService, this.treeDataService);
|
|
219
|
+
// prettier-ignore
|
|
209
220
|
this.gridService = services?.gridService ?? new GridService(this.gridStateService, this.filterService, this._eventPubSubService, this.paginationService, this.sharedService, this.sortService, this.treeDataService);
|
|
210
221
|
this.headerGroupingService = services?.headerGroupingService ?? new HeaderGroupingService(this.extensionUtility);
|
|
211
222
|
if (hierarchicalDataset) {
|
|
212
|
-
this.sharedService.hierarchicalDataset =
|
|
223
|
+
this.sharedService.hierarchicalDataset =
|
|
224
|
+
(isDeepCopyDataOnPageLoadEnabled ? extend(true, [], hierarchicalDataset) : hierarchicalDataset) || [];
|
|
213
225
|
}
|
|
214
226
|
const eventHandler = new SlickEventHandler();
|
|
215
227
|
// register all service instances in the container
|
|
@@ -291,7 +303,7 @@ export class SlickVanillaGridBundle {
|
|
|
291
303
|
if (shouldEmptyDomElementContainer) {
|
|
292
304
|
this.emptyGridContainerElm();
|
|
293
305
|
}
|
|
294
|
-
this._collectionObservers.forEach(obs => obs?.disconnect());
|
|
306
|
+
this._collectionObservers.forEach((obs) => obs?.disconnect());
|
|
295
307
|
this._eventPubSubService?.dispose();
|
|
296
308
|
this._slickerGridInstances = null;
|
|
297
309
|
}
|
|
@@ -308,7 +320,10 @@ export class SlickVanillaGridBundle {
|
|
|
308
320
|
}
|
|
309
321
|
initialization(gridContainerElm, eventHandler, inputDataset) {
|
|
310
322
|
// 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 &&
|
|
323
|
+
if (this.gridOptions &&
|
|
324
|
+
((this.gridOptions.frozenRow !== undefined && this.gridOptions.frozenRow >= 0) ||
|
|
325
|
+
(this.gridOptions.frozenColumn !== undefined && this.gridOptions.frozenColumn >= 0)) &&
|
|
326
|
+
this.gridOptions.enableMouseWheelScrollHandler === undefined) {
|
|
312
327
|
this.gridOptions.enableMouseWheelScrollHandler = true;
|
|
313
328
|
}
|
|
314
329
|
// create the slickgrid container and add it to the user's grid container
|
|
@@ -505,7 +520,10 @@ export class SlickVanillaGridBundle {
|
|
|
505
520
|
// using copy extend to do a deep clone has an unwanted side on objects and pageSizes but ES6 spread has other worst side effects
|
|
506
521
|
// so we will just overwrite the pageSizes when needed, this is the only one causing issues so far.
|
|
507
522
|
// On a deep extend, Object and Array are extended, but object wrappers on primitive types such as String, Boolean, and Number are not.
|
|
508
|
-
if (options?.pagination &&
|
|
523
|
+
if (options?.pagination &&
|
|
524
|
+
(gridOptions.enablePagination || gridOptions.backendServiceApi) &&
|
|
525
|
+
gridOptions.pagination &&
|
|
526
|
+
Array.isArray(gridOptions.pagination.pageSizes)) {
|
|
509
527
|
options.pagination.pageSizes = gridOptions.pagination.pageSizes;
|
|
510
528
|
}
|
|
511
529
|
// when we use Pagination on Local Grid, it doesn't seem to work without enableFiltering
|
|
@@ -530,10 +548,15 @@ export class SlickVanillaGridBundle {
|
|
|
530
548
|
// internalPostProcess only works (for now) with a GraphQL Service, so make sure it is of that type
|
|
531
549
|
if ( /* backendApiService instanceof GraphqlService || */typeof backendApiService.getDatasetName === 'function') {
|
|
532
550
|
backendApi.internalPostProcess = (processResult) => {
|
|
551
|
+
// prettier-ignore
|
|
533
552
|
const datasetName = (backendApi && backendApiService && typeof backendApiService.getDatasetName === 'function') ? backendApiService.getDatasetName() : '';
|
|
534
553
|
if (processResult && processResult.data && processResult.data[datasetName]) {
|
|
535
|
-
const data = processResult.data[datasetName].hasOwnProperty('nodes')
|
|
536
|
-
|
|
554
|
+
const data = processResult.data[datasetName].hasOwnProperty('nodes')
|
|
555
|
+
? processResult.data[datasetName].nodes
|
|
556
|
+
: processResult.data[datasetName];
|
|
557
|
+
const totalCount = processResult.data[datasetName].hasOwnProperty('totalCount')
|
|
558
|
+
? processResult.data[datasetName].totalCount
|
|
559
|
+
: processResult.data[datasetName].length;
|
|
537
560
|
this.refreshGridData(data, totalCount || 0);
|
|
538
561
|
}
|
|
539
562
|
};
|
|
@@ -554,7 +577,8 @@ export class SlickVanillaGridBundle {
|
|
|
554
577
|
this.subscriptions.push(this._eventPubSubService.subscribe('onLanguageChange', (args) => {
|
|
555
578
|
if (gridOptions.enableTranslate) {
|
|
556
579
|
this.extensionService.translateAllExtensions(args.language);
|
|
557
|
-
if ((gridOptions.createPreHeaderPanel && gridOptions.createTopHeaderPanel) ||
|
|
580
|
+
if ((gridOptions.createPreHeaderPanel && gridOptions.createTopHeaderPanel) ||
|
|
581
|
+
(gridOptions.createPreHeaderPanel && !gridOptions.enableDraggableGrouping)) {
|
|
558
582
|
this.headerGroupingService.translateHeaderGrouping();
|
|
559
583
|
}
|
|
560
584
|
}
|
|
@@ -598,20 +622,19 @@ export class SlickVanillaGridBundle {
|
|
|
598
622
|
this.sharedService.isItemsDateParsed = false;
|
|
599
623
|
this.handleOnItemCountChanged(this.dataView?.getFilteredItemCount() || 0, args.itemCount);
|
|
600
624
|
// when user has resize by content enabled, we'll force a full width calculation since we change our entire dataset
|
|
601
|
-
if (args.itemCount > 0 &&
|
|
625
|
+
if (args.itemCount > 0 &&
|
|
626
|
+
(this.gridOptions.autosizeColumnsByCellContentOnFirstLoad || this.gridOptions.enableAutoResizeColumnsByCellContent)) {
|
|
602
627
|
this.resizerService.resizeColumnsByCellContent(!this.gridOptions?.resizeByContentOnlyOnFirstLoad);
|
|
603
628
|
}
|
|
604
629
|
});
|
|
605
|
-
if (gridOptions?.enableFiltering && !gridOptions.enableRowDetailView) {
|
|
630
|
+
if ((gridOptions?.enableFiltering || gridOptions?.dataView?.globalItemMetadataProvider) && !gridOptions.enableRowDetailView) {
|
|
606
631
|
this._eventHandler.subscribe(dataView.onRowsChanged, (_e, { calledOnRowCountChanged, rows }) => {
|
|
607
632
|
// filtering data with local dataset will not always show correctly unless we call this updateRow/render
|
|
608
633
|
// also don't use "invalidateRows" since it destroys the entire row and as bad user experience when updating a row
|
|
609
634
|
// see commit: https://github.com/ghiscoding/aurelia-slickgrid/commit/8c503a4d45fba11cbd8d8cc467fae8d177cc4f60
|
|
610
635
|
if (!calledOnRowCountChanged && Array.isArray(rows)) {
|
|
611
636
|
const ranges = grid.getRenderedRange();
|
|
612
|
-
rows
|
|
613
|
-
.filter(row => row >= ranges.top && row <= ranges.bottom)
|
|
614
|
-
.forEach((row) => grid.updateRow(row));
|
|
637
|
+
rows.filter((row) => row >= ranges.top && row <= ranges.bottom).forEach((row) => grid.updateRow(row));
|
|
615
638
|
grid.render();
|
|
616
639
|
}
|
|
617
640
|
});
|
|
@@ -631,6 +654,7 @@ export class SlickVanillaGridBundle {
|
|
|
631
654
|
this.loadColumnPresetsWhenDatasetInitialized();
|
|
632
655
|
this.loadFilterPresetsWhenDatasetInitialized();
|
|
633
656
|
}
|
|
657
|
+
// @deprecated @user `dataview.globalItemMetadataProvider.getRowMetadata`
|
|
634
658
|
// did the user add a colspan callback? If so, hook it into the DataView getItemMetadata
|
|
635
659
|
if (gridOptions?.colspanCallback && dataView?.getItem && dataView?.getItemMetadata) {
|
|
636
660
|
dataView.getItemMetadata = (rowNumber) => {
|
|
@@ -646,6 +670,7 @@ export class SlickVanillaGridBundle {
|
|
|
646
670
|
const backendApi = gridOptions.backendServiceApi;
|
|
647
671
|
const backendApiService = backendApi?.service;
|
|
648
672
|
const serviceOptions = backendApiService?.options ?? {};
|
|
673
|
+
// prettier-ignore
|
|
649
674
|
const isExecuteCommandOnInit = (!serviceOptions) ? false : ((serviceOptions?.hasOwnProperty('executeProcessCommandOnInit')) ? serviceOptions['executeProcessCommandOnInit'] : true);
|
|
650
675
|
if (backendApiService) {
|
|
651
676
|
// update backend filters (if need be) BEFORE the query runs (via the onInit command a few lines below)
|
|
@@ -675,7 +700,7 @@ export class SlickVanillaGridBundle {
|
|
|
675
700
|
}
|
|
676
701
|
// execute onInit command when necessary
|
|
677
702
|
if (backendApi && backendApiService && (backendApi.onInit || isExecuteCommandOnInit)) {
|
|
678
|
-
const query =
|
|
703
|
+
const query = typeof backendApiService.buildQuery === 'function' ? backendApiService.buildQuery() : '';
|
|
679
704
|
const process = isExecuteCommandOnInit ? (backendApi.process?.(query) ?? null) : (backendApi.onInit?.(query) ?? null);
|
|
680
705
|
// 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
|
|
681
706
|
queueMicrotask(() => {
|
|
@@ -705,13 +730,16 @@ export class SlickVanillaGridBundle {
|
|
|
705
730
|
}
|
|
706
731
|
}
|
|
707
732
|
addBackendInfiniteScrollCallback() {
|
|
708
|
-
if (this.slickGrid &&
|
|
733
|
+
if (this.slickGrid &&
|
|
734
|
+
this.gridOptions.backendServiceApi &&
|
|
735
|
+
this.hasBackendInfiniteScroll() &&
|
|
736
|
+
!this.gridOptions.backendServiceApi?.onScrollEnd) {
|
|
709
737
|
const onScrollEnd = () => {
|
|
710
738
|
this.backendUtilityService.setInfiniteScrollBottomHit(true);
|
|
711
739
|
// even if we're not showing pagination, we still use pagination service behind the scene
|
|
712
740
|
// to keep track of the scroll position and fetch next set of data (aka next page)
|
|
713
741
|
// we also need a flag to know if we reached the of the dataset or not (no more pages)
|
|
714
|
-
this.paginationService.goToNextPage().then(hasNext => {
|
|
742
|
+
this.paginationService.goToNextPage().then((hasNext) => {
|
|
715
743
|
if (!hasNext) {
|
|
716
744
|
this.backendUtilityService.setInfiniteScrollBottomHit(false);
|
|
717
745
|
}
|
|
@@ -722,10 +750,10 @@ export class SlickVanillaGridBundle {
|
|
|
722
750
|
// run onScrollEnd() method when that happens
|
|
723
751
|
this._eventHandler.subscribe(this.slickGrid.onScroll, (_e, args) => {
|
|
724
752
|
const viewportElm = args.grid.getViewportNode();
|
|
725
|
-
if (['mousewheel', 'scroll'].includes(args.triggeredBy || '')
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
753
|
+
if (['mousewheel', 'scroll'].includes(args.triggeredBy || '') &&
|
|
754
|
+
this.paginationService?.totalItems &&
|
|
755
|
+
args.scrollTop > 0 &&
|
|
756
|
+
Math.ceil(viewportElm.offsetHeight + args.scrollTop) >= args.scrollHeight) {
|
|
729
757
|
if (!this._scrollEndCalled) {
|
|
730
758
|
onScrollEnd();
|
|
731
759
|
this._scrollEndCalled = true;
|
|
@@ -744,7 +772,8 @@ export class SlickVanillaGridBundle {
|
|
|
744
772
|
}
|
|
745
773
|
}
|
|
746
774
|
bindResizeHook(grid, options) {
|
|
747
|
-
if ((options.autoFitColumnsOnFirstLoad && options.autosizeColumnsByCellContentOnFirstLoad) ||
|
|
775
|
+
if ((options.autoFitColumnsOnFirstLoad && options.autosizeColumnsByCellContentOnFirstLoad) ||
|
|
776
|
+
(options.enableAutoSizeColumns && options.enableAutoResizeColumnsByCellContent)) {
|
|
748
777
|
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").`);
|
|
749
778
|
}
|
|
750
779
|
// auto-resize grid on browser resize (optionally provide grid height or width)
|
|
@@ -755,7 +784,11 @@ export class SlickVanillaGridBundle {
|
|
|
755
784
|
this.resizerService.resizeGrid();
|
|
756
785
|
}
|
|
757
786
|
// expand/autofit columns on first page load
|
|
758
|
-
if (grid &&
|
|
787
|
+
if (grid &&
|
|
788
|
+
options?.enableAutoResize &&
|
|
789
|
+
options.autoFitColumnsOnFirstLoad &&
|
|
790
|
+
options.enableAutoSizeColumns &&
|
|
791
|
+
!this._isAutosizeColsCalled) {
|
|
759
792
|
grid.autosizeColumns();
|
|
760
793
|
this._isAutosizeColsCalled = true;
|
|
761
794
|
}
|
|
@@ -776,7 +809,10 @@ export class SlickVanillaGridBundle {
|
|
|
776
809
|
*/
|
|
777
810
|
paginationChanged(pagination) {
|
|
778
811
|
const isSyncGridSelectionEnabled = this.gridStateService?.needToPreserveRowSelection() ?? false;
|
|
779
|
-
if (this.slickGrid &&
|
|
812
|
+
if (this.slickGrid &&
|
|
813
|
+
!isSyncGridSelectionEnabled &&
|
|
814
|
+
this._gridOptions?.backendServiceApi &&
|
|
815
|
+
(this.gridOptions.enableRowSelection || this.gridOptions.enableCheckboxSelector)) {
|
|
780
816
|
this.slickGrid.setSelectedRows([]);
|
|
781
817
|
}
|
|
782
818
|
const { pageNumber, pageSize } = pagination;
|
|
@@ -785,7 +821,7 @@ export class SlickVanillaGridBundle {
|
|
|
785
821
|
}
|
|
786
822
|
this._eventPubSubService.publish('onGridStateChanged', {
|
|
787
823
|
change: { newValues: { pageNumber, pageSize }, type: GridStateType.pagination },
|
|
788
|
-
gridState: this.gridStateService.getCurrentGridState()
|
|
824
|
+
gridState: this.gridStateService.getCurrentGridState(),
|
|
789
825
|
});
|
|
790
826
|
}
|
|
791
827
|
/**
|
|
@@ -819,12 +855,13 @@ export class SlickVanillaGridBundle {
|
|
|
819
855
|
this.slickGrid.invalidate();
|
|
820
856
|
}
|
|
821
857
|
// 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
|
|
822
|
-
this.showPagination = !!(this._gridOptions &&
|
|
858
|
+
this.showPagination = !!(this._gridOptions &&
|
|
859
|
+
(this._gridOptions.enablePagination || (this._gridOptions.backendServiceApi && this._gridOptions.enablePagination === undefined)));
|
|
823
860
|
if (this._paginationOptions && this._gridOptions?.pagination && this._gridOptions?.backendServiceApi) {
|
|
824
861
|
const paginationOptions = this.setPaginationOptionsWhenPresetDefined(this._gridOptions, this._paginationOptions);
|
|
825
862
|
// when we have a totalCount use it, else we'll take it from the pagination object
|
|
826
863
|
// only update the total items if it's different to avoid refreshing the UI
|
|
827
|
-
const totalRecords =
|
|
864
|
+
const totalRecords = totalCount !== undefined ? totalCount : this._gridOptions?.pagination?.totalItems;
|
|
828
865
|
if (totalRecords !== undefined && totalRecords !== this.totalItems) {
|
|
829
866
|
this.totalItems = +totalRecords;
|
|
830
867
|
}
|
|
@@ -922,7 +959,7 @@ export class SlickVanillaGridBundle {
|
|
|
922
959
|
* We will use this when doing a resize by cell content, if user provided a `width` it won't override it.
|
|
923
960
|
*/
|
|
924
961
|
copyColumnWidthsReference(columnDefinitions) {
|
|
925
|
-
columnDefinitions.forEach(col => col.originalWidth = col.width);
|
|
962
|
+
columnDefinitions.forEach((col) => (col.originalWidth = col.width));
|
|
926
963
|
}
|
|
927
964
|
displayEmptyDataWarning(showWarning = true) {
|
|
928
965
|
if (this.gridOptions.enableEmptyDataWarningMessage) {
|
|
@@ -936,7 +973,7 @@ export class SlickVanillaGridBundle {
|
|
|
936
973
|
startTime: new Date(),
|
|
937
974
|
endTime: new Date(),
|
|
938
975
|
itemCount: currentPageRowItemCount,
|
|
939
|
-
totalItemCount
|
|
976
|
+
totalItemCount,
|
|
940
977
|
};
|
|
941
978
|
// if custom footer is enabled, then we'll update its metrics
|
|
942
979
|
if (this.slickFooter) {
|
|
@@ -956,7 +993,7 @@ export class SlickVanillaGridBundle {
|
|
|
956
993
|
};
|
|
957
994
|
this.paginationService.totalItems = this.totalItems;
|
|
958
995
|
this.paginationService.init(this.slickGrid, paginationOptions, this.backendServiceApi);
|
|
959
|
-
this.subscriptions.push(this._eventPubSubService.subscribe('onPaginationChanged', paginationChanges => this.paginationChanged(paginationChanges)), this._eventPubSubService.subscribe('onPaginationVisibilityChanged', visibility => {
|
|
996
|
+
this.subscriptions.push(this._eventPubSubService.subscribe('onPaginationChanged', (paginationChanges) => this.paginationChanged(paginationChanges)), this._eventPubSubService.subscribe('onPaginationVisibilityChanged', (visibility) => {
|
|
960
997
|
this.showPagination = visibility?.visible ?? false;
|
|
961
998
|
if (this.gridOptions?.backendServiceApi) {
|
|
962
999
|
this.backendUtilityService?.refreshBackendDataset(this.gridOptions);
|
|
@@ -1020,12 +1057,12 @@ export class SlickVanillaGridBundle {
|
|
|
1020
1057
|
}
|
|
1021
1058
|
else if (response?.status >= 200 && response.status < 300 && typeof response.json === 'function') {
|
|
1022
1059
|
if (response.bodyUsed) {
|
|
1023
|
-
console.warn(`[SlickGrid-Universal] The response body passed to collectionAsync was already read.`
|
|
1024
|
-
|
|
1060
|
+
console.warn(`[SlickGrid-Universal] The response body passed to collectionAsync was already read.` +
|
|
1061
|
+
`Either pass the dataset from the Response or clone the response first using response.clone()`);
|
|
1025
1062
|
}
|
|
1026
1063
|
else {
|
|
1027
1064
|
// from Fetch
|
|
1028
|
-
response.json().then(data => this.updateEditorCollection(column, data));
|
|
1065
|
+
response.json().then((data) => this.updateEditorCollection(column, data));
|
|
1029
1066
|
}
|
|
1030
1067
|
}
|
|
1031
1068
|
else if (response?.content) {
|
|
@@ -1043,13 +1080,11 @@ export class SlickVanillaGridBundle {
|
|
|
1043
1080
|
}
|
|
1044
1081
|
insertDynamicPresetColumns(columnId, gridPresetColumns) {
|
|
1045
1082
|
if (this._columnDefinitions) {
|
|
1046
|
-
const columnPosition = this._columnDefinitions.findIndex(c => c.id === columnId);
|
|
1083
|
+
const columnPosition = this._columnDefinitions.findIndex((c) => c.id === columnId);
|
|
1047
1084
|
if (columnPosition >= 0) {
|
|
1048
1085
|
const dynColumn = this._columnDefinitions[columnPosition];
|
|
1049
|
-
if (dynColumn?.id === columnId && !gridPresetColumns.some(c => c.id === columnId)) {
|
|
1050
|
-
columnPosition > 0
|
|
1051
|
-
? gridPresetColumns.splice(columnPosition, 0, dynColumn)
|
|
1052
|
-
: gridPresetColumns.unshift(dynColumn);
|
|
1086
|
+
if (dynColumn?.id === columnId && !gridPresetColumns.some((c) => c.id === columnId)) {
|
|
1087
|
+
columnPosition > 0 ? gridPresetColumns.splice(columnPosition, 0, dynColumn) : gridPresetColumns.unshift(dynColumn);
|
|
1053
1088
|
}
|
|
1054
1089
|
}
|
|
1055
1090
|
}
|
|
@@ -1057,7 +1092,10 @@ export class SlickVanillaGridBundle {
|
|
|
1057
1092
|
/** Load any possible Columns Grid Presets */
|
|
1058
1093
|
loadColumnPresetsWhenDatasetInitialized() {
|
|
1059
1094
|
// if user entered some Columns "presets", we need to reflect them all in the grid
|
|
1060
|
-
if (this.slickGrid &&
|
|
1095
|
+
if (this.slickGrid &&
|
|
1096
|
+
this.gridOptions.presets &&
|
|
1097
|
+
Array.isArray(this.gridOptions.presets.columns) &&
|
|
1098
|
+
this.gridOptions.presets.columns.length > 0) {
|
|
1061
1099
|
const gridPresetColumns = this.gridStateService.getAssociatedGridColumns(this.slickGrid, this.gridOptions.presets.columns);
|
|
1062
1100
|
if (gridPresetColumns && Array.isArray(gridPresetColumns) && gridPresetColumns.length > 0 && Array.isArray(this._columnDefinitions)) {
|
|
1063
1101
|
// make sure that the dynamic columns are included in presets (1.Row Move, 2. Row Selection, 3. Row Detail)
|
|
@@ -1075,7 +1113,7 @@ export class SlickVanillaGridBundle {
|
|
|
1075
1113
|
}
|
|
1076
1114
|
// keep copy the original optional `width` properties optionally provided by the user.
|
|
1077
1115
|
// We will use this when doing a resize by cell content, if user provided a `width` it won't override it.
|
|
1078
|
-
gridPresetColumns.forEach(col => col.originalWidth = col.width);
|
|
1116
|
+
gridPresetColumns.forEach((col) => (col.originalWidth = col.width));
|
|
1079
1117
|
// finally set the new presets columns (including checkbox selector if need be)
|
|
1080
1118
|
this.slickGrid.setColumns(gridPresetColumns);
|
|
1081
1119
|
this.sharedService.visibleColumns = gridPresetColumns;
|
|
@@ -1088,7 +1126,8 @@ export class SlickVanillaGridBundle {
|
|
|
1088
1126
|
// if user entered some Filter "presets", we need to reflect them all in the DOM
|
|
1089
1127
|
// also note that a presets of Tree Data Toggling will also call this method because Tree Data toggling does work with data filtering
|
|
1090
1128
|
// (collapsing a parent will basically use Filter for hidding (aka collapsing) away the child underneat it)
|
|
1091
|
-
if (this.gridOptions.presets &&
|
|
1129
|
+
if (this.gridOptions.presets &&
|
|
1130
|
+
(Array.isArray(this.gridOptions.presets.filters) || Array.isArray(this.gridOptions.presets?.treeData?.toggledItems))) {
|
|
1092
1131
|
this.filterService.populateColumnFilterSearchTermPresets(this.gridOptions.presets?.filters || []);
|
|
1093
1132
|
}
|
|
1094
1133
|
}
|
|
@@ -1118,7 +1157,12 @@ export class SlickVanillaGridBundle {
|
|
|
1118
1157
|
const presets = this.gridOptions?.presets;
|
|
1119
1158
|
const selectionModel = this.slickGrid?.getSelectionModel();
|
|
1120
1159
|
const enableRowSelection = this.gridOptions && (this.gridOptions.enableCheckboxSelector || this.gridOptions.enableRowSelection);
|
|
1121
|
-
if (this.slickGrid &&
|
|
1160
|
+
if (this.slickGrid &&
|
|
1161
|
+
this.dataView &&
|
|
1162
|
+
enableRowSelection &&
|
|
1163
|
+
selectionModel &&
|
|
1164
|
+
presets?.rowSelection &&
|
|
1165
|
+
(Array.isArray(presets.rowSelection.gridRowIndexes) || Array.isArray(presets.rowSelection.dataContextIds))) {
|
|
1122
1166
|
let dataContextIds = presets.rowSelection.dataContextIds;
|
|
1123
1167
|
let gridRowIndexes = presets.rowSelection.gridRowIndexes;
|
|
1124
1168
|
// maps the IDs to the Grid Rows and vice versa, the "dataContextIds" has precedence over the other
|
|
@@ -1134,7 +1178,7 @@ export class SlickVanillaGridBundle {
|
|
|
1134
1178
|
this.dataView.setSelectedIds(dataContextIds || [], {
|
|
1135
1179
|
isRowBeingAdded: true,
|
|
1136
1180
|
shouldTriggerEvent: false, // do not trigger when presetting the grid
|
|
1137
|
-
applyRowSelectionToGrid: true
|
|
1181
|
+
applyRowSelectionToGrid: true,
|
|
1138
1182
|
});
|
|
1139
1183
|
}
|
|
1140
1184
|
}
|
|
@@ -1144,7 +1188,7 @@ export class SlickVanillaGridBundle {
|
|
|
1144
1188
|
if (disposePreviousResources) {
|
|
1145
1189
|
this.disposeExternalResources();
|
|
1146
1190
|
}
|
|
1147
|
-
resources.forEach(res => this._registeredResources.push(res));
|
|
1191
|
+
resources.forEach((res) => this._registeredResources.push(res));
|
|
1148
1192
|
this.initializeExternalResources(resources);
|
|
1149
1193
|
}
|
|
1150
1194
|
resetExternalResources() {
|
|
@@ -1179,7 +1223,8 @@ export class SlickVanillaGridBundle {
|
|
|
1179
1223
|
// push all other Services that we want to be registered
|
|
1180
1224
|
this._registeredResources.push(this.gridService, this.gridStateService);
|
|
1181
1225
|
// when using Grouping/DraggableGrouping/Colspan register its Service
|
|
1182
|
-
if ((this.gridOptions.createPreHeaderPanel && this.gridOptions.createTopHeaderPanel) ||
|
|
1226
|
+
if ((this.gridOptions.createPreHeaderPanel && this.gridOptions.createTopHeaderPanel) ||
|
|
1227
|
+
(this.gridOptions.createPreHeaderPanel && !this.gridOptions.enableDraggableGrouping)) {
|
|
1183
1228
|
this._registeredResources.push(this.headerGroupingService);
|
|
1184
1229
|
}
|
|
1185
1230
|
// when using Tree Data View, register its Service
|
|
@@ -1237,7 +1282,7 @@ export class SlickVanillaGridBundle {
|
|
|
1237
1282
|
/** Prepare and load all SlickGrid editors, if an async editor is found then we'll also execute it. */
|
|
1238
1283
|
loadSlickGridEditors(columnDefinitions) {
|
|
1239
1284
|
const columns = Array.isArray(columnDefinitions) ? columnDefinitions : [];
|
|
1240
|
-
if (columns.some(col => `${col.id}`.includes('.'))) {
|
|
1285
|
+
if (columns.some((col) => `${col.id}`.includes('.'))) {
|
|
1241
1286
|
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".');
|
|
1242
1287
|
}
|
|
1243
1288
|
return columns.map((column) => {
|
|
@@ -1249,7 +1294,11 @@ export class SlickVanillaGridBundle {
|
|
|
1249
1294
|
});
|
|
1250
1295
|
}
|
|
1251
1296
|
suggestDateParsingWhenHelpful() {
|
|
1252
|
-
if (!this.gridOptions.silenceWarnings &&
|
|
1297
|
+
if (!this.gridOptions.silenceWarnings &&
|
|
1298
|
+
this.dataView &&
|
|
1299
|
+
this.dataView.getItemCount() > WARN_NO_PREPARSE_DATE_SIZE &&
|
|
1300
|
+
!this.gridOptions.preParseDateColumns &&
|
|
1301
|
+
this.slickGrid?.getColumns().some((c) => isColumnDateType(c.type))) {
|
|
1253
1302
|
console.warn('[Slickgrid-Universal] For getting better perf, we suggest you enable the `preParseDateColumns` grid option, ' +
|
|
1254
1303
|
'for more info visit => https://ghiscoding.gitbook.io/slickgrid-universal/column-functionalities/sorting#pre-parse-date-columns-for-better-perf');
|
|
1255
1304
|
}
|
|
@@ -1264,7 +1313,7 @@ export class SlickVanillaGridBundle {
|
|
|
1264
1313
|
column.editor.disabled = false;
|
|
1265
1314
|
// get current Editor, remove it from the DOm then re-enable it and re-render it with the new collection.
|
|
1266
1315
|
const currentEditor = this.slickGrid.getCellEditor();
|
|
1267
|
-
if (currentEditor?.disable && currentEditor
|
|
1316
|
+
if (currentEditor?.disable && currentEditor.renderDomElement) {
|
|
1268
1317
|
if (typeof currentEditor.destroy === 'function') {
|
|
1269
1318
|
currentEditor.destroy();
|
|
1270
1319
|
}
|