@slickgrid-universal/vanilla-bundle 5.14.0 → 9.0.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/README.md +0 -3
- package/dist/{types/components → components}/slick-vanilla-grid-bundle.d.ts +5 -5
- package/dist/components/slick-vanilla-grid-bundle.d.ts.map +1 -0
- package/dist/{esm/components → components}/slick-vanilla-grid-bundle.js +37 -53
- package/dist/components/slick-vanilla-grid-bundle.js.map +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/index.d.ts.map +1 -0
- package/dist/{cjs/interfaces → interfaces}/index.js.map +1 -1
- package/dist/{types/interfaces → interfaces}/slickerGridInstance.interface.d.ts +0 -2
- package/dist/interfaces/slickerGridInstance.interface.d.ts.map +1 -0
- package/dist/interfaces/slickerGridInstance.interface.js.map +1 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/universalContainer.service.d.ts.map +1 -0
- package/dist/services/universalContainer.service.js.map +1 -0
- package/package.json +15 -18
- package/src/components/slick-vanilla-grid-bundle.ts +41 -64
- package/src/interfaces/slickerGridInstance.interface.ts +0 -3
- package/dist/cjs/components/slick-vanilla-grid-bundle.js +0 -1309
- package/dist/cjs/components/slick-vanilla-grid-bundle.js.map +0 -1
- package/dist/cjs/index.js +0 -55
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/interfaces/index.js +0 -3
- package/dist/cjs/interfaces/slickerGridInstance.interface.js +0 -3
- package/dist/cjs/interfaces/slickerGridInstance.interface.js.map +0 -1
- package/dist/cjs/services/index.js +0 -18
- package/dist/cjs/services/index.js.map +0 -1
- package/dist/cjs/services/universalContainer.service.js +0 -26
- package/dist/cjs/services/universalContainer.service.js.map +0 -1
- package/dist/esm/components/slick-vanilla-grid-bundle.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/interfaces/index.js.map +0 -1
- package/dist/esm/interfaces/slickerGridInstance.interface.js.map +0 -1
- package/dist/esm/services/index.js.map +0 -1
- package/dist/esm/services/universalContainer.service.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/types/components/slick-vanilla-grid-bundle.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/interfaces/index.d.ts.map +0 -1
- package/dist/types/interfaces/slickerGridInstance.interface.d.ts.map +0 -1
- package/dist/types/services/index.d.ts.map +0 -1
- package/dist/types/services/universalContainer.service.d.ts.map +0 -1
- /package/dist/{types/index.d.ts → index.d.ts} +0 -0
- /package/dist/{esm/index.js → index.js} +0 -0
- /package/dist/{types/interfaces → interfaces}/index.d.ts +0 -0
- /package/dist/{esm/interfaces → interfaces}/index.js +0 -0
- /package/dist/{esm/interfaces → interfaces}/slickerGridInstance.interface.js +0 -0
- /package/dist/{types/services → services}/index.d.ts +0 -0
- /package/dist/{esm/services → services}/index.js +0 -0
- /package/dist/{types/services → services}/universalContainer.service.d.ts +0 -0
- /package/dist/{esm/services → services}/universalContainer.service.js +0 -0
|
@@ -1,1309 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SlickVanillaGridBundle = void 0;
|
|
4
|
-
const lite_1 = require("dequal/lite");
|
|
5
|
-
const common_1 = require("@slickgrid-universal/common");
|
|
6
|
-
const utils_1 = require("@slickgrid-universal/utils");
|
|
7
|
-
const event_pub_sub_1 = require("@slickgrid-universal/event-pub-sub");
|
|
8
|
-
const empty_warning_component_1 = require("@slickgrid-universal/empty-warning-component");
|
|
9
|
-
const custom_footer_component_1 = require("@slickgrid-universal/custom-footer-component");
|
|
10
|
-
const pagination_component_1 = require("@slickgrid-universal/pagination-component");
|
|
11
|
-
const universalContainer_service_js_1 = require("../services/universalContainer.service.js");
|
|
12
|
-
const WARN_NO_PREPARSE_DATE_SIZE = 10000; // data size to warn user when pre-parse isn't enabled
|
|
13
|
-
class SlickVanillaGridBundle {
|
|
14
|
-
get backendService() {
|
|
15
|
-
return this.gridOptions.backendServiceApi?.service;
|
|
16
|
-
}
|
|
17
|
-
get eventHandler() {
|
|
18
|
-
return this._eventHandler;
|
|
19
|
-
}
|
|
20
|
-
get columnDefinitions() {
|
|
21
|
-
return this._columnDefinitions || [];
|
|
22
|
-
}
|
|
23
|
-
set columnDefinitions(columnDefinitions) {
|
|
24
|
-
this.columnDefinitionsChanged(columnDefinitions);
|
|
25
|
-
}
|
|
26
|
-
get dataset() {
|
|
27
|
-
return this.dataView?.getItems() || [];
|
|
28
|
-
}
|
|
29
|
-
set dataset(newDataset) {
|
|
30
|
-
const prevDatasetLn = this._currentDatasetLength;
|
|
31
|
-
const isDatasetEqual = (0, lite_1.dequal)(newDataset, this.dataset || []);
|
|
32
|
-
const isDeepCopyDataOnPageLoadEnabled = !!this._gridOptions?.enableDeepCopyDatasetOnPageLoad;
|
|
33
|
-
let data = isDeepCopyDataOnPageLoadEnabled ? (0, utils_1.extend)(true, [], newDataset) : newDataset;
|
|
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
|
|
35
|
-
if (this.slickGrid &&
|
|
36
|
-
this.gridOptions?.enableTreeData &&
|
|
37
|
-
Array.isArray(newDataset) &&
|
|
38
|
-
(newDataset.length > 0 || newDataset.length !== prevDatasetLn || !isDatasetEqual)) {
|
|
39
|
-
this._isDatasetHierarchicalInitialized = false;
|
|
40
|
-
data = this.sortTreeDataset(newDataset, !isDatasetEqual); // if dataset changed, then force a refresh anyway
|
|
41
|
-
}
|
|
42
|
-
this.refreshGridData(data || []);
|
|
43
|
-
this._currentDatasetLength = (newDataset || []).length;
|
|
44
|
-
// expand/autofit columns on first page load
|
|
45
|
-
// we can assume that if the prevDataset was empty then we are on first load
|
|
46
|
-
if (this.slickGrid && this.gridOptions.autoFitColumnsOnFirstLoad && prevDatasetLn === 0 && !this._isAutosizeColsCalled) {
|
|
47
|
-
this.slickGrid.autosizeColumns();
|
|
48
|
-
this._isAutosizeColsCalled = true;
|
|
49
|
-
}
|
|
50
|
-
this.suggestDateParsingWhenHelpful();
|
|
51
|
-
}
|
|
52
|
-
get datasetHierarchical() {
|
|
53
|
-
return this.sharedService.hierarchicalDataset;
|
|
54
|
-
}
|
|
55
|
-
set datasetHierarchical(newHierarchicalDataset) {
|
|
56
|
-
const isDatasetEqual = (0, lite_1.dequal)(newHierarchicalDataset, this.sharedService.hierarchicalDataset || []);
|
|
57
|
-
const prevFlatDatasetLn = this._currentDatasetLength;
|
|
58
|
-
this.sharedService.hierarchicalDataset = newHierarchicalDataset;
|
|
59
|
-
if (newHierarchicalDataset && this.columnDefinitions && this.filterService?.clearFilters) {
|
|
60
|
-
this.filterService.clearFilters();
|
|
61
|
-
}
|
|
62
|
-
// when a hierarchical dataset is set afterward, we can reset the flat dataset and call a tree data sort that will overwrite the flat dataset
|
|
63
|
-
if (this.dataView && newHierarchicalDataset && this.slickGrid && this.sortService?.processTreeDataInitialSort) {
|
|
64
|
-
this.sortService.processTreeDataInitialSort();
|
|
65
|
-
// we also need to reset/refresh the Tree Data filters because if we inserted new item(s) then it might not show up without doing this refresh
|
|
66
|
-
// however we need to queue our process until the flat dataset is ready, so we can queue a microtask to execute the DataView refresh only after everything is ready
|
|
67
|
-
queueMicrotask(() => {
|
|
68
|
-
const flatDatasetLn = this.dataView?.getItemCount() ?? 0;
|
|
69
|
-
if (flatDatasetLn > 0 && (flatDatasetLn !== prevFlatDatasetLn || !isDatasetEqual)) {
|
|
70
|
-
this.filterService.refreshTreeDataFilters();
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
this._isDatasetHierarchicalInitialized = true;
|
|
75
|
-
}
|
|
76
|
-
set eventPubSubService(pubSub) {
|
|
77
|
-
this._eventPubSubService = pubSub;
|
|
78
|
-
}
|
|
79
|
-
set isDatasetHierarchicalInitialized(isInitialized) {
|
|
80
|
-
this._isDatasetHierarchicalInitialized = isInitialized;
|
|
81
|
-
}
|
|
82
|
-
get gridOptions() {
|
|
83
|
-
return this._gridOptions || {};
|
|
84
|
-
}
|
|
85
|
-
set gridOptions(options) {
|
|
86
|
-
options ??= {};
|
|
87
|
-
let mergedOptions;
|
|
88
|
-
// if we already have grid options, when grid was already initialized, we'll merge with those options
|
|
89
|
-
// else we'll merge with global grid options
|
|
90
|
-
if (this.slickGrid?.getOptions) {
|
|
91
|
-
mergedOptions = (0, utils_1.extend)(true, {}, this.slickGrid.getOptions(), options);
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
mergedOptions = this.mergeGridOptions(options);
|
|
95
|
-
}
|
|
96
|
-
if (this.sharedService?.gridOptions && this.slickGrid?.setOptions) {
|
|
97
|
-
this.sharedService.gridOptions = mergedOptions;
|
|
98
|
-
this.slickGrid.setOptions(mergedOptions, false, true); // make sure to supressColumnCheck (3rd arg) to avoid problem with changeColumnsArrangement() and custom grid view
|
|
99
|
-
this.slickGrid.reRenderColumns(true); // then call a re-render since we did supressColumnCheck on previous setOptions
|
|
100
|
-
}
|
|
101
|
-
// add/remove dark mode CSS class to parent container
|
|
102
|
-
this.setDarkMode(options.darkMode);
|
|
103
|
-
this._gridOptions = mergedOptions;
|
|
104
|
-
}
|
|
105
|
-
get paginationOptions() {
|
|
106
|
-
return this._paginationOptions;
|
|
107
|
-
}
|
|
108
|
-
set paginationOptions(newPaginationOptions) {
|
|
109
|
-
if (newPaginationOptions && this._paginationOptions) {
|
|
110
|
-
this._paginationOptions = { ...this._paginationOptions, ...newPaginationOptions };
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
this._paginationOptions = newPaginationOptions;
|
|
114
|
-
}
|
|
115
|
-
this.gridOptions.pagination = this._paginationOptions;
|
|
116
|
-
this.paginationService.updateTotalItems(newPaginationOptions?.totalItems ?? 0, true);
|
|
117
|
-
}
|
|
118
|
-
get isDatasetInitialized() {
|
|
119
|
-
return this._isDatasetInitialized;
|
|
120
|
-
}
|
|
121
|
-
set isDatasetInitialized(isInitialized) {
|
|
122
|
-
this._isDatasetInitialized = isInitialized;
|
|
123
|
-
}
|
|
124
|
-
get isGridInitialized() {
|
|
125
|
-
return this._isGridInitialized;
|
|
126
|
-
}
|
|
127
|
-
get instances() {
|
|
128
|
-
return this._slickerGridInstances;
|
|
129
|
-
}
|
|
130
|
-
get extensions() {
|
|
131
|
-
return this._extensions;
|
|
132
|
-
}
|
|
133
|
-
get registeredResources() {
|
|
134
|
-
return this._registeredResources;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Slicker Grid Bundle constructor
|
|
138
|
-
* @param {Object} gridParentContainerElm - div HTML DOM element container
|
|
139
|
-
* @param {Array<Column>} columnDefs - Column Definitions
|
|
140
|
-
* @param {Object} options - Grid Options
|
|
141
|
-
* @param {Array<Object>} dataset - Dataset
|
|
142
|
-
* @param {Array<Object>} hierarchicalDataset - Hierarchical Dataset
|
|
143
|
-
* @param {Object} services - Typically only used for Unit Testing when we want to pass Mocked/Stub Services
|
|
144
|
-
*/
|
|
145
|
-
constructor(gridParentContainerElm, columnDefs, options, dataset, hierarchicalDataset, services) {
|
|
146
|
-
this._currentDatasetLength = 0;
|
|
147
|
-
this._darkMode = false;
|
|
148
|
-
this._collectionObservers = [];
|
|
149
|
-
this._gridOptions = {};
|
|
150
|
-
this._hideHeaderRowAfterPageLoad = false;
|
|
151
|
-
this._isAutosizeColsCalled = false;
|
|
152
|
-
this._isDatasetInitialized = false;
|
|
153
|
-
this._isDatasetHierarchicalInitialized = false;
|
|
154
|
-
this._isGridInitialized = false;
|
|
155
|
-
this._isLocalGrid = true;
|
|
156
|
-
this._isPaginationInitialized = false;
|
|
157
|
-
this._registeredResources = [];
|
|
158
|
-
this._scrollEndCalled = false;
|
|
159
|
-
this._slickgridInitialized = false;
|
|
160
|
-
this.customDataView = false;
|
|
161
|
-
this.totalItems = 0;
|
|
162
|
-
this.subscriptions = [];
|
|
163
|
-
this.showPagination = false;
|
|
164
|
-
// make sure that the grid container doesn't already have the "slickgrid-container" css class
|
|
165
|
-
// if it does then we won't create yet another grid, just stop there
|
|
166
|
-
if (!gridParentContainerElm || gridParentContainerElm.querySelectorAll('.slickgrid-container').length !== 0) {
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
gridParentContainerElm.classList.add('grid-pane');
|
|
170
|
-
this._gridParentContainerElm = gridParentContainerElm;
|
|
171
|
-
this._gridContainerElm = document.createElement('div');
|
|
172
|
-
this._gridContainerElm.classList.add('slickgrid-container');
|
|
173
|
-
gridParentContainerElm.appendChild(this._gridContainerElm);
|
|
174
|
-
// check if the user wants to hide the header row from the start
|
|
175
|
-
// we only want to do this check once in the constructor
|
|
176
|
-
this._hideHeaderRowAfterPageLoad = options?.showHeaderRow === false;
|
|
177
|
-
this._columnDefinitions = columnDefs || [];
|
|
178
|
-
if (this._columnDefinitions.length > 0) {
|
|
179
|
-
this.copyColumnWidthsReference(this._columnDefinitions);
|
|
180
|
-
}
|
|
181
|
-
// save resource refs to register before the grid options are merged and possibly deep copied
|
|
182
|
-
// since a deep copy of grid options would lose original resource refs but we want to keep them as singleton
|
|
183
|
-
this._registeredResources = options?.externalResources || [];
|
|
184
|
-
this._gridOptions = this.mergeGridOptions(options || {});
|
|
185
|
-
const isDeepCopyDataOnPageLoadEnabled = !!this._gridOptions?.enableDeepCopyDatasetOnPageLoad;
|
|
186
|
-
// add dark mode CSS class when enabled
|
|
187
|
-
if (this._gridOptions.darkMode) {
|
|
188
|
-
this.setDarkMode(true);
|
|
189
|
-
}
|
|
190
|
-
this.universalContainerService = services?.universalContainerService ?? new universalContainer_service_js_1.UniversalContainerService();
|
|
191
|
-
// if user is providing a Translate Service, it has to be passed under the "translater" grid option
|
|
192
|
-
this.translaterService = services?.translaterService ?? this._gridOptions?.translater;
|
|
193
|
-
// initialize and assign all Service Dependencies
|
|
194
|
-
this._eventPubSubService = services?.eventPubSubService ?? new event_pub_sub_1.EventPubSubService(gridParentContainerElm);
|
|
195
|
-
this._eventPubSubService.eventNamingStyle = this._gridOptions?.eventNamingStyle ?? event_pub_sub_1.EventNamingStyle.camelCase;
|
|
196
|
-
const slickgridConfig = new common_1.SlickgridConfig();
|
|
197
|
-
this.backendUtilityService = services?.backendUtilityService ?? new common_1.BackendUtilityService();
|
|
198
|
-
this.gridEventService = services?.gridEventService ?? new common_1.GridEventService();
|
|
199
|
-
this.sharedService = services?.sharedService ?? new common_1.SharedService();
|
|
200
|
-
this.collectionService = services?.collectionService ?? new common_1.CollectionService(this.translaterService);
|
|
201
|
-
this.extensionUtility =
|
|
202
|
-
services?.extensionUtility ?? new common_1.ExtensionUtility(this.sharedService, this.backendUtilityService, this.translaterService);
|
|
203
|
-
this.filterFactory = new common_1.FilterFactory(slickgridConfig, this.translaterService, this.collectionService);
|
|
204
|
-
// prettier-ignore
|
|
205
|
-
this.filterService = services?.filterService ?? new common_1.FilterService(this.filterFactory, this._eventPubSubService, this.sharedService, this.backendUtilityService);
|
|
206
|
-
this.resizerService = services?.resizerService ?? new common_1.ResizerService(this._eventPubSubService);
|
|
207
|
-
// prettier-ignore
|
|
208
|
-
this.sortService = services?.sortService ?? new common_1.SortService(this.collectionService, this.sharedService, this._eventPubSubService, this.backendUtilityService);
|
|
209
|
-
this.treeDataService = services?.treeDataService ?? new common_1.TreeDataService(this._eventPubSubService, this.sharedService, this.sortService);
|
|
210
|
-
// prettier-ignore
|
|
211
|
-
this.paginationService = services?.paginationService ?? new common_1.PaginationService(this._eventPubSubService, this.sharedService, this.backendUtilityService);
|
|
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
|
|
216
|
-
this.gridStateService = services?.gridStateService ?? new common_1.GridStateService(this.extensionService, this.filterService, this._eventPubSubService, this.sharedService, this.sortService, this.treeDataService);
|
|
217
|
-
// prettier-ignore
|
|
218
|
-
this.gridService = services?.gridService ?? new common_1.GridService(this.gridStateService, this.filterService, this._eventPubSubService, this.paginationService, this.sharedService, this.sortService, this.treeDataService);
|
|
219
|
-
this.headerGroupingService = services?.headerGroupingService ?? new common_1.HeaderGroupingService(this.extensionUtility);
|
|
220
|
-
if (hierarchicalDataset) {
|
|
221
|
-
this.sharedService.hierarchicalDataset =
|
|
222
|
-
(isDeepCopyDataOnPageLoadEnabled ? (0, utils_1.extend)(true, [], hierarchicalDataset) : hierarchicalDataset) || [];
|
|
223
|
-
}
|
|
224
|
-
const eventHandler = new common_1.SlickEventHandler();
|
|
225
|
-
// register all service instances in the container
|
|
226
|
-
this.universalContainerService.registerInstance('PubSubService', this._eventPubSubService); // external resources require this one registration (ExcelExport, TextExport)
|
|
227
|
-
this.universalContainerService.registerInstance('EventPubSubService', this._eventPubSubService);
|
|
228
|
-
this.universalContainerService.registerInstance('ExtensionUtility', this.extensionUtility);
|
|
229
|
-
this.universalContainerService.registerInstance('FilterService', this.filterService);
|
|
230
|
-
this.universalContainerService.registerInstance('CollectionService', this.collectionService);
|
|
231
|
-
this.universalContainerService.registerInstance('ExtensionService', this.extensionService);
|
|
232
|
-
this.universalContainerService.registerInstance('GridEventService', this.gridEventService);
|
|
233
|
-
this.universalContainerService.registerInstance('GridService', this.gridService);
|
|
234
|
-
this.universalContainerService.registerInstance('GridStateService', this.gridStateService);
|
|
235
|
-
this.universalContainerService.registerInstance('HeaderGroupingService', this.headerGroupingService);
|
|
236
|
-
this.universalContainerService.registerInstance('PaginationService', this.paginationService);
|
|
237
|
-
this.universalContainerService.registerInstance('ResizerService', this.resizerService);
|
|
238
|
-
this.universalContainerService.registerInstance('SharedService', this.sharedService);
|
|
239
|
-
this.universalContainerService.registerInstance('SortService', this.sortService);
|
|
240
|
-
this.universalContainerService.registerInstance('TranslaterService', this.translaterService);
|
|
241
|
-
this.universalContainerService.registerInstance('TreeDataService', this.treeDataService);
|
|
242
|
-
this.initialization(this._gridContainerElm, eventHandler, dataset);
|
|
243
|
-
}
|
|
244
|
-
emptyGridContainerElm() {
|
|
245
|
-
const gridContainerId = this.gridOptions?.gridContainerId ?? 'grid1';
|
|
246
|
-
const gridContainerElm = document.querySelector(`#${gridContainerId}`);
|
|
247
|
-
(0, common_1.emptyElement)(gridContainerElm);
|
|
248
|
-
}
|
|
249
|
-
/** Dispose of the Component */
|
|
250
|
-
dispose(shouldEmptyDomElementContainer = false) {
|
|
251
|
-
this._eventPubSubService?.publish('onBeforeGridDestroy', this.slickGrid);
|
|
252
|
-
this._eventHandler?.unsubscribeAll();
|
|
253
|
-
this._eventPubSubService?.publish('onAfterGridDestroyed', true);
|
|
254
|
-
// dispose the Services
|
|
255
|
-
this.extensionService?.dispose();
|
|
256
|
-
this.filterService?.dispose();
|
|
257
|
-
this.gridEventService?.dispose();
|
|
258
|
-
this.gridService?.dispose();
|
|
259
|
-
this.gridStateService?.dispose();
|
|
260
|
-
this.headerGroupingService?.dispose();
|
|
261
|
-
this.paginationService?.dispose();
|
|
262
|
-
this.resizerService?.dispose();
|
|
263
|
-
this.sortService?.dispose();
|
|
264
|
-
this.treeDataService?.dispose();
|
|
265
|
-
this.universalContainerService?.dispose();
|
|
266
|
-
// dispose backend service when defined and a dispose method exists
|
|
267
|
-
this.backendService?.dispose?.();
|
|
268
|
-
// dispose all registered external resources
|
|
269
|
-
this.disposeExternalResources();
|
|
270
|
-
// dispose the Components
|
|
271
|
-
this.slickFooter?.dispose();
|
|
272
|
-
this.slickEmptyWarning?.dispose();
|
|
273
|
-
this.paginationComponent?.dispose();
|
|
274
|
-
(0, common_1.unsubscribeAll)(this.subscriptions);
|
|
275
|
-
this._eventPubSubService?.unsubscribeAll();
|
|
276
|
-
this.dataView?.setItems([]);
|
|
277
|
-
if (typeof this.dataView?.destroy === 'function') {
|
|
278
|
-
this.dataView?.destroy();
|
|
279
|
-
}
|
|
280
|
-
this.slickGrid?.destroy(true);
|
|
281
|
-
this.slickGrid = null;
|
|
282
|
-
(0, common_1.emptyElement)(this._gridContainerElm);
|
|
283
|
-
(0, common_1.emptyElement)(this._gridParentContainerElm);
|
|
284
|
-
this._gridContainerElm?.remove();
|
|
285
|
-
this._gridParentContainerElm?.remove();
|
|
286
|
-
if (this.backendServiceApi) {
|
|
287
|
-
for (const prop of Object.keys(this.backendServiceApi)) {
|
|
288
|
-
this.backendServiceApi[prop] = null;
|
|
289
|
-
}
|
|
290
|
-
this.backendServiceApi = undefined;
|
|
291
|
-
}
|
|
292
|
-
for (const prop of Object.keys(this.columnDefinitions)) {
|
|
293
|
-
this.columnDefinitions[prop] = null;
|
|
294
|
-
}
|
|
295
|
-
for (const prop of Object.keys(this.sharedService)) {
|
|
296
|
-
this.sharedService[prop] = null;
|
|
297
|
-
}
|
|
298
|
-
this.datasetHierarchical = undefined;
|
|
299
|
-
this._columnDefinitions = [];
|
|
300
|
-
// we could optionally also empty the content of the grid container DOM element
|
|
301
|
-
if (shouldEmptyDomElementContainer) {
|
|
302
|
-
this.emptyGridContainerElm();
|
|
303
|
-
}
|
|
304
|
-
this._collectionObservers.forEach((obs) => obs?.disconnect());
|
|
305
|
-
this._eventPubSubService?.dispose();
|
|
306
|
-
this._slickerGridInstances = null;
|
|
307
|
-
}
|
|
308
|
-
disposeExternalResources() {
|
|
309
|
-
if (Array.isArray(this._registeredResources)) {
|
|
310
|
-
while (this._registeredResources.length > 0) {
|
|
311
|
-
const res = this._registeredResources.pop();
|
|
312
|
-
if (res?.dispose) {
|
|
313
|
-
res.dispose();
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
this._registeredResources = [];
|
|
318
|
-
}
|
|
319
|
-
initialization(gridContainerElm, eventHandler, inputDataset) {
|
|
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
|
|
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) {
|
|
325
|
-
this.gridOptions.enableMouseWheelScrollHandler = true;
|
|
326
|
-
}
|
|
327
|
-
// create the slickgrid container and add it to the user's grid container
|
|
328
|
-
this._gridContainerElm = gridContainerElm;
|
|
329
|
-
this._eventPubSubService.publish('onBeforeGridCreate', true);
|
|
330
|
-
this._isAutosizeColsCalled = false;
|
|
331
|
-
this._eventHandler = eventHandler;
|
|
332
|
-
this._gridOptions = this.mergeGridOptions(this._gridOptions || {});
|
|
333
|
-
this.backendServiceApi = this._gridOptions?.backendServiceApi;
|
|
334
|
-
this._isLocalGrid = !this.backendServiceApi; // considered a local grid if it doesn't have a backend service set
|
|
335
|
-
this._eventPubSubService.eventNamingStyle = this._gridOptions?.eventNamingStyle ?? event_pub_sub_1.EventNamingStyle.camelCase;
|
|
336
|
-
this._paginationOptions = this.gridOptions?.pagination;
|
|
337
|
-
// unless specified, we'll create an internal postProcess callback (currently only available for GraphQL)
|
|
338
|
-
if (this._gridOptions.backendServiceApi && !this._gridOptions.backendServiceApi?.disableInternalPostProcess) {
|
|
339
|
-
this.createBackendApiInternalPostProcessCallback(this._gridOptions);
|
|
340
|
-
}
|
|
341
|
-
if (!this.customDataView) {
|
|
342
|
-
const dataviewInlineFilters = this._gridOptions?.dataView?.inlineFilters ?? false;
|
|
343
|
-
let dataViewOptions = { ...this._gridOptions.dataView, inlineFilters: dataviewInlineFilters };
|
|
344
|
-
if (this.gridOptions.draggableGrouping || this.gridOptions.enableGrouping) {
|
|
345
|
-
this.groupItemMetadataProvider = new common_1.SlickGroupItemMetadataProvider();
|
|
346
|
-
this.sharedService.groupItemMetadataProvider = this.groupItemMetadataProvider;
|
|
347
|
-
dataViewOptions = { ...dataViewOptions, groupItemMetadataProvider: this.groupItemMetadataProvider };
|
|
348
|
-
}
|
|
349
|
-
this.dataView = new common_1.SlickDataView(dataViewOptions, this._eventPubSubService);
|
|
350
|
-
this._eventPubSubService.publish('onDataviewCreated', this.dataView);
|
|
351
|
-
}
|
|
352
|
-
// get any possible Services that user want to register which don't require SlickGrid to be instantiated
|
|
353
|
-
// RxJS Resource is in this lot because it has to be registered before anything else and doesn't require SlickGrid to be initialized
|
|
354
|
-
this.preRegisterResources();
|
|
355
|
-
// prepare and load all SlickGrid editors, if an async editor is found then we'll also execute it.
|
|
356
|
-
this._columnDefinitions = this.loadSlickGridEditors(this._columnDefinitions || []);
|
|
357
|
-
// if the user wants to automatically add a Custom Editor Formatter, we need to call the auto add function again
|
|
358
|
-
if (this._gridOptions?.autoAddCustomEditorFormatter) {
|
|
359
|
-
(0, common_1.autoAddEditorFormatterToColumnsWithEditor)(this._columnDefinitions, this._gridOptions.autoAddCustomEditorFormatter);
|
|
360
|
-
}
|
|
361
|
-
// save reference for all columns before they optionally become hidden/visible
|
|
362
|
-
this.sharedService.allColumns = this._columnDefinitions;
|
|
363
|
-
this.sharedService.visibleColumns = this._columnDefinitions;
|
|
364
|
-
// TODO: revisit later, this is conflicting with Grid State & Presets
|
|
365
|
-
// before certain extentions/plugins potentially adds extra columns not created by the user itself (RowMove, RowDetail, RowSelections)
|
|
366
|
-
// we'll subscribe to the event and push back the change to the user so they always use full column defs array including extra cols
|
|
367
|
-
// this.subscriptions.push(
|
|
368
|
-
// this._eventPubSubService.subscribe<{ columns: Column[]; pluginName: string }>('onPluginColumnsChanged', data => {
|
|
369
|
-
// this._columnDefinitions = this.columnDefinitions = data.columns;
|
|
370
|
-
// })
|
|
371
|
-
// );
|
|
372
|
-
// after subscribing to potential columns changed, we are ready to create these optional extensions
|
|
373
|
-
// when we did find some to create (RowMove, RowDetail, RowSelections), it will automatically modify column definitions (by previous subscribe)
|
|
374
|
-
this.extensionService.createExtensionsBeforeGridCreation(this._columnDefinitions, this._gridOptions);
|
|
375
|
-
// if user entered some Pinning/Frozen "presets", we need to apply them in the grid options
|
|
376
|
-
if (this.gridOptions.presets?.pinning) {
|
|
377
|
-
this.gridOptions = { ...this.gridOptions, ...this.gridOptions.presets.pinning };
|
|
378
|
-
}
|
|
379
|
-
this.slickGrid = new common_1.SlickGrid(gridContainerElm, this.dataView, this._columnDefinitions, this._gridOptions, this._eventPubSubService);
|
|
380
|
-
this.sharedService.dataView = this.dataView;
|
|
381
|
-
this.sharedService.slickGrid = this.slickGrid;
|
|
382
|
-
this.sharedService.gridContainerElement = this._gridContainerElm;
|
|
383
|
-
if (this.groupItemMetadataProvider) {
|
|
384
|
-
this.slickGrid.registerPlugin(this.groupItemMetadataProvider); // register GroupItemMetadataProvider when Grouping is enabled
|
|
385
|
-
}
|
|
386
|
-
this.extensionService.bindDifferentExtensions();
|
|
387
|
-
this.bindDifferentHooks(this.slickGrid, this._gridOptions, this.dataView);
|
|
388
|
-
this._slickgridInitialized = true;
|
|
389
|
-
// when it's a frozen grid, we need to keep the frozen column id for reference if we ever show/hide column from ColumnPicker/GridMenu afterward
|
|
390
|
-
const frozenColumnIndex = this._gridOptions?.frozenColumn ?? -1;
|
|
391
|
-
if (frozenColumnIndex >= 0 && frozenColumnIndex <= this._columnDefinitions.length && this._columnDefinitions.length > 0) {
|
|
392
|
-
this.sharedService.frozenVisibleColumnId = this._columnDefinitions[frozenColumnIndex]?.id ?? '';
|
|
393
|
-
}
|
|
394
|
-
// get any possible Services that user want to register
|
|
395
|
-
this.registerResources();
|
|
396
|
-
// initialize the SlickGrid grid
|
|
397
|
-
this.slickGrid.init();
|
|
398
|
-
// initialized the resizer service only after SlickGrid is initialized
|
|
399
|
-
// if we don't we end up binding our resize to a grid element that doesn't yet exist in the DOM and the resizer service will fail silently (because it has a try/catch that unbinds the resize without throwing back)
|
|
400
|
-
this.resizerService.init(this.slickGrid, this._gridParentContainerElm);
|
|
401
|
-
// user could show a custom footer with the data metrics (dataset length and last updated timestamp)
|
|
402
|
-
if (!this.gridOptions.enablePagination && this.gridOptions.showCustomFooter && this.gridOptions.customFooterOptions) {
|
|
403
|
-
this.slickFooter = new custom_footer_component_1.SlickFooterComponent(this.slickGrid, this.gridOptions.customFooterOptions, this._eventPubSubService, this.translaterService);
|
|
404
|
-
this.slickFooter.renderFooter(this._gridParentContainerElm);
|
|
405
|
-
}
|
|
406
|
-
// load the data in the DataView (unless it's a hierarchical dataset, if so it will be loaded after the initial tree sort)
|
|
407
|
-
inputDataset = inputDataset || [];
|
|
408
|
-
const initialDataset = this.gridOptions?.enableTreeData ? this.sortTreeDataset(inputDataset) : inputDataset;
|
|
409
|
-
if (this.dataView) {
|
|
410
|
-
this.dataView.beginUpdate();
|
|
411
|
-
this.dataView.setItems(initialDataset, this._gridOptions.datasetIdPropertyName);
|
|
412
|
-
this._currentDatasetLength = inputDataset.length;
|
|
413
|
-
this.dataView.endUpdate();
|
|
414
|
-
}
|
|
415
|
-
// if you don't want the items that are not visible (due to being filtered out or being on a different page)
|
|
416
|
-
// to stay selected, pass 'false' to the second arg
|
|
417
|
-
if (this.slickGrid?.getSelectionModel() && this._gridOptions?.dataView?.hasOwnProperty('syncGridSelection')) {
|
|
418
|
-
// if we are using a Backend Service, we will do an extra flag check, the reason is because it might have some unintended behaviors
|
|
419
|
-
// with the BackendServiceApi because technically the data in the page changes the DataView on every page change.
|
|
420
|
-
let preservedRowSelectionWithBackend = false;
|
|
421
|
-
if (this._gridOptions.backendServiceApi && this._gridOptions.dataView.hasOwnProperty('syncGridSelectionWithBackendService')) {
|
|
422
|
-
preservedRowSelectionWithBackend = this._gridOptions.dataView.syncGridSelectionWithBackendService;
|
|
423
|
-
}
|
|
424
|
-
const syncGridSelection = this._gridOptions.dataView.syncGridSelection;
|
|
425
|
-
if (typeof syncGridSelection === 'boolean') {
|
|
426
|
-
let preservedRowSelection = syncGridSelection;
|
|
427
|
-
if (!this._isLocalGrid) {
|
|
428
|
-
// when using BackendServiceApi, we'll be using the "syncGridSelectionWithBackendService" flag BUT "syncGridSelection" must also be set to True
|
|
429
|
-
preservedRowSelection = syncGridSelection && preservedRowSelectionWithBackend;
|
|
430
|
-
}
|
|
431
|
-
this.dataView?.syncGridSelection(this.slickGrid, preservedRowSelection);
|
|
432
|
-
}
|
|
433
|
-
else if (typeof syncGridSelection === 'object') {
|
|
434
|
-
this.dataView?.syncGridSelection(this.slickGrid, syncGridSelection.preserveHidden, syncGridSelection.preserveHiddenOnSelectionChange);
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
if ((this.dataView?.getLength() ?? 0) > 0) {
|
|
438
|
-
if (!this._isDatasetInitialized && (this._gridOptions.enableCheckboxSelector || this._gridOptions.enableRowSelection)) {
|
|
439
|
-
this.loadRowSelectionPresetWhenExists();
|
|
440
|
-
}
|
|
441
|
-
this.loadFilterPresetsWhenDatasetInitialized();
|
|
442
|
-
this._isDatasetInitialized = true;
|
|
443
|
-
}
|
|
444
|
-
else {
|
|
445
|
-
this.displayEmptyDataWarning(true);
|
|
446
|
-
}
|
|
447
|
-
// user might want to hide the header row on page load but still have `enableFiltering: true`
|
|
448
|
-
// if that is the case, we need to hide the headerRow ONLY AFTER all filters got created & dataView exist
|
|
449
|
-
if (this._hideHeaderRowAfterPageLoad) {
|
|
450
|
-
this.showHeaderRow(false);
|
|
451
|
-
this.sharedService.hideHeaderRowAfterPageLoad = this._hideHeaderRowAfterPageLoad;
|
|
452
|
-
}
|
|
453
|
-
// on cell click, mainly used with the columnDef.action callback
|
|
454
|
-
this.gridEventService.bindOnBeforeEditCell(this.slickGrid);
|
|
455
|
-
this.gridEventService.bindOnCellChange(this.slickGrid);
|
|
456
|
-
this.gridEventService.bindOnClick(this.slickGrid);
|
|
457
|
-
// bind the Backend Service API callback functions only after the grid is initialized
|
|
458
|
-
// because the preProcess() and onInit() might get triggered
|
|
459
|
-
if (this.gridOptions?.backendServiceApi) {
|
|
460
|
-
this.bindBackendCallbackFunctions(this.gridOptions);
|
|
461
|
-
}
|
|
462
|
-
// publish & dispatch certain events
|
|
463
|
-
this._eventPubSubService.publish('onGridCreated', this.slickGrid);
|
|
464
|
-
// after the DataView is created & updated execute some processes & dispatch some events
|
|
465
|
-
if (!this.customDataView) {
|
|
466
|
-
this.executeAfterDataviewCreated(this.gridOptions);
|
|
467
|
-
}
|
|
468
|
-
// bind resize ONLY after the dataView is ready
|
|
469
|
-
this.bindResizeHook(this.slickGrid, this.gridOptions);
|
|
470
|
-
// local grid, check if we need to show the Pagination
|
|
471
|
-
// if so then also check if there's any presets and finally initialize the PaginationService
|
|
472
|
-
// a local grid with Pagination presets will potentially have a different total of items, we'll need to get it from the DataView and update our total
|
|
473
|
-
if (this.gridOptions?.enablePagination && this._isLocalGrid) {
|
|
474
|
-
this.showPagination = true;
|
|
475
|
-
this.loadLocalGridPagination(this.dataset);
|
|
476
|
-
}
|
|
477
|
-
// once the grid is created, we'll return its instance (we do this to return Transient Services from DI)
|
|
478
|
-
this._slickerGridInstances = {
|
|
479
|
-
// Slick Grid & DataView objects
|
|
480
|
-
dataView: this.dataView,
|
|
481
|
-
slickGrid: this.slickGrid,
|
|
482
|
-
// public methods
|
|
483
|
-
dispose: this.dispose.bind(this),
|
|
484
|
-
// return all available Services (non-singleton)
|
|
485
|
-
backendService: this.backendService,
|
|
486
|
-
eventPubSubService: this._eventPubSubService,
|
|
487
|
-
filterService: this.filterService,
|
|
488
|
-
gridEventService: this.gridEventService,
|
|
489
|
-
gridStateService: this.gridStateService,
|
|
490
|
-
gridService: this.gridService,
|
|
491
|
-
groupingService: this.headerGroupingService,
|
|
492
|
-
headerGroupingService: this.headerGroupingService,
|
|
493
|
-
extensionService: this.extensionService,
|
|
494
|
-
extensionUtility: this.extensionUtility,
|
|
495
|
-
paginationService: this.paginationService,
|
|
496
|
-
resizerService: this.resizerService,
|
|
497
|
-
sortService: this.sortService,
|
|
498
|
-
treeDataService: this.treeDataService,
|
|
499
|
-
};
|
|
500
|
-
// addons (SlickGrid extra plugins/controls)
|
|
501
|
-
this._extensions = this.extensionService?.extensionList;
|
|
502
|
-
// all instances (SlickGrid, DataView & all Services)
|
|
503
|
-
this._eventPubSubService.publish('onSlickerGridCreated', this.instances);
|
|
504
|
-
this._isGridInitialized = true;
|
|
505
|
-
this.suggestDateParsingWhenHelpful();
|
|
506
|
-
// subscribe to column definitions assignment changes
|
|
507
|
-
this.observeColumnDefinitions();
|
|
508
|
-
}
|
|
509
|
-
hasBackendInfiniteScroll() {
|
|
510
|
-
return !!this.backendService?.options?.infiniteScroll;
|
|
511
|
-
}
|
|
512
|
-
mergeGridOptions(gridOptions) {
|
|
513
|
-
const options = (0, utils_1.extend)(true, {}, common_1.GlobalGridOptions, gridOptions);
|
|
514
|
-
// also make sure to show the header row if user have enabled filtering
|
|
515
|
-
if (options.enableFiltering && !options.showHeaderRow) {
|
|
516
|
-
options.showHeaderRow = options.enableFiltering;
|
|
517
|
-
}
|
|
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
|
|
519
|
-
// so we will just overwrite the pageSizes when needed, this is the only one causing issues so far.
|
|
520
|
-
// On a deep extend, Object and Array are extended, but object wrappers on primitive types such as String, Boolean, and Number are not.
|
|
521
|
-
if (options?.pagination &&
|
|
522
|
-
(gridOptions.enablePagination || gridOptions.backendServiceApi) &&
|
|
523
|
-
gridOptions.pagination &&
|
|
524
|
-
Array.isArray(gridOptions.pagination.pageSizes)) {
|
|
525
|
-
options.pagination.pageSizes = gridOptions.pagination.pageSizes;
|
|
526
|
-
}
|
|
527
|
-
// when we use Pagination on Local Grid, it doesn't seem to work without enableFiltering
|
|
528
|
-
// so we'll enable the filtering but we'll keep the header row hidden
|
|
529
|
-
if (this.sharedService && !options.enableFiltering && options.enablePagination && this._isLocalGrid) {
|
|
530
|
-
options.enableFiltering = true;
|
|
531
|
-
options.showHeaderRow = false;
|
|
532
|
-
this._hideHeaderRowAfterPageLoad = true;
|
|
533
|
-
this.sharedService.hideHeaderRowAfterPageLoad = true;
|
|
534
|
-
}
|
|
535
|
-
return options;
|
|
536
|
-
}
|
|
537
|
-
/**
|
|
538
|
-
* Define our internal Post Process callback, it will execute internally after we get back result from the Process backend call
|
|
539
|
-
* Currently ONLY available with the GraphQL Backend Service.
|
|
540
|
-
* The behavior is to refresh the Dataset & Pagination without requiring the user to create his own PostProcess every time
|
|
541
|
-
*/
|
|
542
|
-
createBackendApiInternalPostProcessCallback(gridOptions) {
|
|
543
|
-
const backendApi = gridOptions?.backendServiceApi;
|
|
544
|
-
if (backendApi?.service) {
|
|
545
|
-
const backendApiService = backendApi.service;
|
|
546
|
-
// internalPostProcess only works (for now) with a GraphQL Service, so make sure it is of that type
|
|
547
|
-
if ( /* backendApiService instanceof GraphqlService || */typeof backendApiService.getDatasetName === 'function') {
|
|
548
|
-
backendApi.internalPostProcess = (processResult) => {
|
|
549
|
-
// prettier-ignore
|
|
550
|
-
const datasetName = (backendApi && backendApiService && typeof backendApiService.getDatasetName === 'function') ? backendApiService.getDatasetName() : '';
|
|
551
|
-
if (processResult && processResult.data && processResult.data[datasetName]) {
|
|
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;
|
|
558
|
-
this.refreshGridData(data, totalCount || 0);
|
|
559
|
-
}
|
|
560
|
-
};
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
bindDifferentHooks(grid, gridOptions, dataView) {
|
|
565
|
-
// if user is providing a Translate Service, we need to add our PubSub Service (but only after creating all dependencies)
|
|
566
|
-
// so that we can later subscribe to the "onLanguageChange" event and translate any texts whenever that get triggered
|
|
567
|
-
if (gridOptions.enableTranslate && this.translaterService?.addPubSubMessaging) {
|
|
568
|
-
this.translaterService.addPubSubMessaging(this._eventPubSubService);
|
|
569
|
-
}
|
|
570
|
-
// translate them all on first load, then on each language change
|
|
571
|
-
if (gridOptions.enableTranslate) {
|
|
572
|
-
this.extensionService.translateAllExtensions();
|
|
573
|
-
}
|
|
574
|
-
// on locale change, we have to manually translate the Headers, GridMenu
|
|
575
|
-
this.subscriptions.push(this._eventPubSubService.subscribe('onLanguageChange', (args) => {
|
|
576
|
-
if (gridOptions.enableTranslate) {
|
|
577
|
-
this.extensionService.translateAllExtensions(args.language);
|
|
578
|
-
if ((gridOptions.createPreHeaderPanel && gridOptions.createTopHeaderPanel) ||
|
|
579
|
-
(gridOptions.createPreHeaderPanel && !gridOptions.enableDraggableGrouping)) {
|
|
580
|
-
this.headerGroupingService.translateHeaderGrouping();
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
}));
|
|
584
|
-
// if user set an onInit Backend, we'll run it right away (and if so, we also need to run preProcess, internalPostProcess & postProcess)
|
|
585
|
-
if (gridOptions.backendServiceApi) {
|
|
586
|
-
const backendApi = gridOptions.backendServiceApi;
|
|
587
|
-
if (backendApi?.service?.init) {
|
|
588
|
-
backendApi.service.init(backendApi.options, gridOptions.pagination, this.slickGrid, this.sharedService);
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
if (dataView && grid) {
|
|
592
|
-
// after all events are exposed
|
|
593
|
-
// we can bind external filter (backend) when available or default onFilter (dataView)
|
|
594
|
-
if (gridOptions.enableFiltering) {
|
|
595
|
-
this.filterService.init(grid);
|
|
596
|
-
// bind external filter (backend) unless specified to use the local one
|
|
597
|
-
if (gridOptions.backendServiceApi && !gridOptions.backendServiceApi.useLocalFiltering) {
|
|
598
|
-
this.filterService.bindBackendOnFilter(grid);
|
|
599
|
-
}
|
|
600
|
-
else {
|
|
601
|
-
this.filterService.bindLocalOnFilter(grid);
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
// bind external sorting (backend) when available or default onSort (dataView)
|
|
605
|
-
if (gridOptions.enableSorting) {
|
|
606
|
-
// bind external sorting (backend) unless specified to use the local one
|
|
607
|
-
if (gridOptions.backendServiceApi && !gridOptions.backendServiceApi.useLocalSorting) {
|
|
608
|
-
this.sortService.bindBackendOnSort(grid);
|
|
609
|
-
}
|
|
610
|
-
else {
|
|
611
|
-
this.sortService.bindLocalOnSort(grid);
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
// When data changes in the DataView, we need to refresh the metrics and/or display a warning if the dataset is empty
|
|
615
|
-
this._eventHandler.subscribe(dataView.onRowCountChanged, (_e, args) => {
|
|
616
|
-
if (!gridOptions.enableRowDetailView || !Array.isArray(args.changedRows) || args.changedRows.length === args.itemCount) {
|
|
617
|
-
grid.invalidate();
|
|
618
|
-
}
|
|
619
|
-
else {
|
|
620
|
-
grid.invalidateRows(args.changedRows);
|
|
621
|
-
grid.render();
|
|
622
|
-
}
|
|
623
|
-
this.handleOnItemCountChanged(this.dataView?.getFilteredItemCount() || 0, this.dataView?.getItemCount() ?? 0);
|
|
624
|
-
});
|
|
625
|
-
this._eventHandler.subscribe(dataView.onSetItemsCalled, (_e, args) => {
|
|
626
|
-
this.sharedService.isItemsDateParsed = false;
|
|
627
|
-
this.handleOnItemCountChanged(this.dataView?.getFilteredItemCount() || 0, args.itemCount);
|
|
628
|
-
// when user has resize by content enabled, we'll force a full width calculation since we change our entire dataset
|
|
629
|
-
if (args.itemCount > 0 &&
|
|
630
|
-
(gridOptions.autosizeColumnsByCellContentOnFirstLoad || gridOptions.enableAutoResizeColumnsByCellContent)) {
|
|
631
|
-
this.resizerService.resizeColumnsByCellContent(!gridOptions?.resizeByContentOnlyOnFirstLoad);
|
|
632
|
-
}
|
|
633
|
-
});
|
|
634
|
-
if ((gridOptions?.enableFiltering || gridOptions?.dataView?.globalItemMetadataProvider) && !gridOptions.enableRowDetailView) {
|
|
635
|
-
this._eventHandler.subscribe(dataView.onRowsChanged, (_e, { calledOnRowCountChanged, rows }) => {
|
|
636
|
-
// filtering data with local dataset will not always show correctly unless we call this updateRow/render
|
|
637
|
-
// also don't use "invalidateRows" since it destroys the entire row and as bad user experience when updating a row
|
|
638
|
-
// see commit: https://github.com/ghiscoding/aurelia-slickgrid/commit/8c503a4d45fba11cbd8d8cc467fae8d177cc4f60
|
|
639
|
-
if (!calledOnRowCountChanged && Array.isArray(rows)) {
|
|
640
|
-
const ranges = grid.getRenderedRange();
|
|
641
|
-
rows.filter((row) => row >= ranges.top && row <= ranges.bottom).forEach((row) => grid.updateRow(row));
|
|
642
|
-
grid.render();
|
|
643
|
-
}
|
|
644
|
-
});
|
|
645
|
-
}
|
|
646
|
-
// when column are reordered, we need to update the visibleColumn array
|
|
647
|
-
this._eventHandler.subscribe(grid.onColumnsReordered, (_e, args) => {
|
|
648
|
-
this.sharedService.hasColumnsReordered = true;
|
|
649
|
-
this.sharedService.visibleColumns = args.impactedColumns;
|
|
650
|
-
});
|
|
651
|
-
this._eventHandler.subscribe(grid.onSetOptions, (_e, args) => {
|
|
652
|
-
// add/remove dark mode CSS class when enabled
|
|
653
|
-
if (args.optionsBefore.darkMode !== args.optionsAfter.darkMode) {
|
|
654
|
-
this.setDarkMode(args.optionsAfter.darkMode);
|
|
655
|
-
}
|
|
656
|
-
});
|
|
657
|
-
// load any presets if any (after dataset is initialized)
|
|
658
|
-
this.loadColumnPresetsWhenDatasetInitialized();
|
|
659
|
-
this.loadFilterPresetsWhenDatasetInitialized();
|
|
660
|
-
}
|
|
661
|
-
// @deprecated @use `dataview.globalItemMetadataProvider.getRowMetadata`
|
|
662
|
-
// did the user add a colspan callback? If so, hook it into the DataView getItemMetadata
|
|
663
|
-
if (gridOptions?.colspanCallback && dataView?.getItem && dataView?.getItemMetadata) {
|
|
664
|
-
dataView.getItemMetadata = (rowNumber) => {
|
|
665
|
-
let callbackResult = null;
|
|
666
|
-
if (gridOptions.colspanCallback) {
|
|
667
|
-
callbackResult = gridOptions.colspanCallback(dataView.getItem(rowNumber));
|
|
668
|
-
}
|
|
669
|
-
return callbackResult;
|
|
670
|
-
};
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
bindBackendCallbackFunctions(gridOptions) {
|
|
674
|
-
const backendApi = gridOptions.backendServiceApi;
|
|
675
|
-
const backendApiService = backendApi?.service;
|
|
676
|
-
const serviceOptions = backendApiService?.options ?? {};
|
|
677
|
-
// prettier-ignore
|
|
678
|
-
const isExecuteCommandOnInit = (!serviceOptions) ? false : ((serviceOptions?.hasOwnProperty('executeProcessCommandOnInit')) ? serviceOptions['executeProcessCommandOnInit'] : true);
|
|
679
|
-
if (backendApiService) {
|
|
680
|
-
// update backend filters (if need be) BEFORE the query runs (via the onInit command a few lines below)
|
|
681
|
-
// if user entered some any "presets", we need to reflect them all in the grid
|
|
682
|
-
if (gridOptions?.presets) {
|
|
683
|
-
// Filters "presets"
|
|
684
|
-
if (backendApiService.updateFilters && Array.isArray(gridOptions.presets.filters) && gridOptions.presets.filters.length > 0) {
|
|
685
|
-
backendApiService.updateFilters(gridOptions.presets.filters, true);
|
|
686
|
-
}
|
|
687
|
-
// Sorters "presets"
|
|
688
|
-
if (backendApiService.updateSorters && Array.isArray(gridOptions.presets.sorters) && gridOptions.presets.sorters.length > 0) {
|
|
689
|
-
// when using multi-column sort, we can have multiple but on single sort then only grab the first sort provided
|
|
690
|
-
const sortColumns = this._gridOptions?.multiColumnSort ? gridOptions.presets.sorters : gridOptions.presets.sorters.slice(0, 1);
|
|
691
|
-
backendApiService.updateSorters(undefined, sortColumns);
|
|
692
|
-
}
|
|
693
|
-
// Pagination "presets"
|
|
694
|
-
if (backendApiService.updatePagination && gridOptions.presets.pagination && !this.hasBackendInfiniteScroll()) {
|
|
695
|
-
const { pageNumber, pageSize } = gridOptions.presets.pagination;
|
|
696
|
-
backendApiService.updatePagination(pageNumber, pageSize);
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
else {
|
|
700
|
-
const columnFilters = this.filterService.getColumnFilters();
|
|
701
|
-
if (columnFilters && backendApiService.updateFilters) {
|
|
702
|
-
backendApiService.updateFilters(columnFilters, false);
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
// execute onInit command when necessary
|
|
706
|
-
if (backendApi && backendApiService && (backendApi.onInit || isExecuteCommandOnInit)) {
|
|
707
|
-
const query = typeof backendApiService.buildQuery === 'function' ? backendApiService.buildQuery() : '';
|
|
708
|
-
const process = isExecuteCommandOnInit ? (backendApi.process?.(query) ?? null) : (backendApi.onInit?.(query) ?? null);
|
|
709
|
-
// 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
|
|
710
|
-
queueMicrotask(() => {
|
|
711
|
-
const backendUtilityService = this.backendUtilityService;
|
|
712
|
-
// keep start time & end timestamps & return it after process execution
|
|
713
|
-
const startTime = new Date();
|
|
714
|
-
// run any pre-process, if defined, for example a spinner
|
|
715
|
-
if (backendApi.preProcess) {
|
|
716
|
-
backendApi.preProcess();
|
|
717
|
-
}
|
|
718
|
-
// the processes can be a Promise (like Http)
|
|
719
|
-
const totalItems = this.gridOptions?.pagination?.totalItems ?? 0;
|
|
720
|
-
if (process instanceof Promise) {
|
|
721
|
-
process
|
|
722
|
-
.then((processResult) => backendUtilityService.executeBackendProcessesCallback(startTime, processResult, backendApi, totalItems))
|
|
723
|
-
.catch((error) => backendUtilityService.onBackendError(error, backendApi));
|
|
724
|
-
}
|
|
725
|
-
else if (process && this.rxjs?.isObservable(process)) {
|
|
726
|
-
this.subscriptions.push(process.subscribe((processResult) => backendUtilityService.executeBackendProcessesCallback(startTime, processResult, backendApi, totalItems), (error) => backendUtilityService.onBackendError(error, backendApi)));
|
|
727
|
-
}
|
|
728
|
-
});
|
|
729
|
-
}
|
|
730
|
-
// when user enables Infinite Scroll
|
|
731
|
-
if (backendApi.service.options?.infiniteScroll) {
|
|
732
|
-
this.addBackendInfiniteScrollCallback();
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
addBackendInfiniteScrollCallback() {
|
|
737
|
-
if (this.slickGrid &&
|
|
738
|
-
this.gridOptions.backendServiceApi &&
|
|
739
|
-
this.hasBackendInfiniteScroll() &&
|
|
740
|
-
!this.gridOptions.backendServiceApi?.onScrollEnd) {
|
|
741
|
-
const onScrollEnd = () => {
|
|
742
|
-
this.backendUtilityService.setInfiniteScrollBottomHit(true);
|
|
743
|
-
// even if we're not showing pagination, we still use pagination service behind the scene
|
|
744
|
-
// to keep track of the scroll position and fetch next set of data (aka next page)
|
|
745
|
-
// we also need a flag to know if we reached the of the dataset or not (no more pages)
|
|
746
|
-
this.paginationService.goToNextPage().then((hasNext) => {
|
|
747
|
-
if (!hasNext) {
|
|
748
|
-
this.backendUtilityService.setInfiniteScrollBottomHit(false);
|
|
749
|
-
}
|
|
750
|
-
});
|
|
751
|
-
};
|
|
752
|
-
this.gridOptions.backendServiceApi.onScrollEnd = onScrollEnd;
|
|
753
|
-
// subscribe to SlickGrid onScroll to determine when reaching the end of the scroll bottom position
|
|
754
|
-
// run onScrollEnd() method when that happens
|
|
755
|
-
this._eventHandler.subscribe(this.slickGrid.onScroll, (_e, args) => {
|
|
756
|
-
const viewportElm = args.grid.getViewportNode();
|
|
757
|
-
if (['mousewheel', 'scroll'].includes(args.triggeredBy || '') &&
|
|
758
|
-
this.paginationService?.totalItems &&
|
|
759
|
-
args.scrollTop > 0 &&
|
|
760
|
-
Math.ceil(viewportElm.offsetHeight + args.scrollTop) >= args.scrollHeight) {
|
|
761
|
-
if (!this._scrollEndCalled) {
|
|
762
|
-
onScrollEnd();
|
|
763
|
-
this._scrollEndCalled = true;
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
});
|
|
767
|
-
// use postProcess to identify when scrollEnd process is finished to avoid calling the scrollEnd multiple times
|
|
768
|
-
// we also need to keep a ref of the user's postProcess and call it after our own postProcess
|
|
769
|
-
const orgPostProcess = this.gridOptions.backendServiceApi.postProcess;
|
|
770
|
-
this.gridOptions.backendServiceApi.postProcess = (processResult) => {
|
|
771
|
-
this._scrollEndCalled = false;
|
|
772
|
-
if (orgPostProcess) {
|
|
773
|
-
orgPostProcess(processResult);
|
|
774
|
-
}
|
|
775
|
-
};
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
bindResizeHook(grid, options) {
|
|
779
|
-
if ((options.autoFitColumnsOnFirstLoad && options.autosizeColumnsByCellContentOnFirstLoad) ||
|
|
780
|
-
(options.enableAutoSizeColumns && options.enableAutoResizeColumnsByCellContent)) {
|
|
781
|
-
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").`);
|
|
782
|
-
}
|
|
783
|
-
// auto-resize grid on browser resize (optionally provide grid height or width)
|
|
784
|
-
if (options.gridHeight || options.gridWidth) {
|
|
785
|
-
this.resizerService.resizeGrid(0, { height: options.gridHeight, width: options.gridWidth });
|
|
786
|
-
}
|
|
787
|
-
else {
|
|
788
|
-
this.resizerService.resizeGrid();
|
|
789
|
-
}
|
|
790
|
-
// expand/autofit columns on first page load
|
|
791
|
-
if (grid &&
|
|
792
|
-
options?.enableAutoResize &&
|
|
793
|
-
options.autoFitColumnsOnFirstLoad &&
|
|
794
|
-
options.enableAutoSizeColumns &&
|
|
795
|
-
!this._isAutosizeColsCalled) {
|
|
796
|
-
grid.autosizeColumns();
|
|
797
|
-
this._isAutosizeColsCalled = true;
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
|
-
executeAfterDataviewCreated(gridOptions) {
|
|
801
|
-
// if user entered some Sort "presets", we need to reflect them all in the DOM
|
|
802
|
-
if (gridOptions.enableSorting) {
|
|
803
|
-
if (gridOptions.presets && Array.isArray(gridOptions.presets.sorters)) {
|
|
804
|
-
// when using multi-column sort, we can have multiple but on single sort then only grab the first sort provided
|
|
805
|
-
const sortColumns = this._gridOptions?.multiColumnSort ? gridOptions.presets.sorters : gridOptions.presets.sorters.slice(0, 1);
|
|
806
|
-
this.sortService.loadGridSorters(sortColumns);
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
}
|
|
810
|
-
/**
|
|
811
|
-
* On a Pagination changed, we will trigger a Grid State changed with the new pagination info
|
|
812
|
-
* Also if we use Row Selection or the Checkbox Selector with a Backend Service (Odata, GraphQL), we need to reset any selection
|
|
813
|
-
*/
|
|
814
|
-
paginationChanged(pagination) {
|
|
815
|
-
const isSyncGridSelectionEnabled = this.gridStateService?.needToPreserveRowSelection() ?? false;
|
|
816
|
-
if (this.slickGrid &&
|
|
817
|
-
!isSyncGridSelectionEnabled &&
|
|
818
|
-
this._gridOptions?.backendServiceApi &&
|
|
819
|
-
(this.gridOptions.enableRowSelection || this.gridOptions.enableCheckboxSelector)) {
|
|
820
|
-
this.slickGrid.setSelectedRows([]);
|
|
821
|
-
}
|
|
822
|
-
const { pageNumber, pageSize } = pagination;
|
|
823
|
-
if (this.sharedService && pageSize !== undefined && pageNumber !== undefined) {
|
|
824
|
-
this.sharedService.currentPagination = { pageNumber, pageSize };
|
|
825
|
-
}
|
|
826
|
-
this._eventPubSubService.publish('onGridStateChanged', {
|
|
827
|
-
change: { newValues: { pageNumber, pageSize }, type: common_1.GridStateType.pagination },
|
|
828
|
-
gridState: this.gridStateService.getCurrentGridState(),
|
|
829
|
-
});
|
|
830
|
-
}
|
|
831
|
-
/**
|
|
832
|
-
* When dataset changes, we need to refresh the entire grid UI & possibly resize it as well
|
|
833
|
-
* @param dataset
|
|
834
|
-
*/
|
|
835
|
-
refreshGridData(dataset, totalCount) {
|
|
836
|
-
// local grid, check if we need to show the Pagination
|
|
837
|
-
// if so then also check if there's any presets and finally initialize the PaginationService
|
|
838
|
-
// a local grid with Pagination presets will potentially have a different total of items, we'll need to get it from the DataView and update our total
|
|
839
|
-
if (this.slickGrid && this._gridOptions) {
|
|
840
|
-
if (this._gridOptions.enableEmptyDataWarningMessage && Array.isArray(dataset)) {
|
|
841
|
-
const finalTotalCount = totalCount || dataset.length;
|
|
842
|
-
this.displayEmptyDataWarning(finalTotalCount < 1);
|
|
843
|
-
}
|
|
844
|
-
if (Array.isArray(dataset) && this.slickGrid && this.dataView?.setItems) {
|
|
845
|
-
this.dataView.setItems(dataset, this._gridOptions.datasetIdPropertyName);
|
|
846
|
-
if (!this._gridOptions.backendServiceApi && !this._gridOptions.enableTreeData) {
|
|
847
|
-
this.dataView.reSort();
|
|
848
|
-
}
|
|
849
|
-
if (dataset.length > 0) {
|
|
850
|
-
if (!this._isDatasetInitialized) {
|
|
851
|
-
this.loadFilterPresetsWhenDatasetInitialized();
|
|
852
|
-
if (this._gridOptions.enableCheckboxSelector) {
|
|
853
|
-
this.loadRowSelectionPresetWhenExists();
|
|
854
|
-
}
|
|
855
|
-
}
|
|
856
|
-
this._isDatasetInitialized = true;
|
|
857
|
-
}
|
|
858
|
-
if (dataset) {
|
|
859
|
-
this.slickGrid.invalidate();
|
|
860
|
-
}
|
|
861
|
-
// 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
|
|
862
|
-
this.showPagination = !!(this._gridOptions &&
|
|
863
|
-
(this._gridOptions.enablePagination || (this._gridOptions.backendServiceApi && this._gridOptions.enablePagination === undefined)));
|
|
864
|
-
if (this._paginationOptions && this._gridOptions?.pagination && this._gridOptions?.backendServiceApi) {
|
|
865
|
-
const paginationOptions = this.setPaginationOptionsWhenPresetDefined(this._gridOptions, this._paginationOptions);
|
|
866
|
-
// when we have a totalCount use it, else we'll take it from the pagination object
|
|
867
|
-
// only update the total items if it's different to avoid refreshing the UI
|
|
868
|
-
const totalRecords = totalCount !== undefined ? totalCount : this._gridOptions?.pagination?.totalItems;
|
|
869
|
-
if (totalRecords !== undefined && totalRecords !== this.totalItems) {
|
|
870
|
-
this.totalItems = +totalRecords;
|
|
871
|
-
}
|
|
872
|
-
// initialize the Pagination Service with new pagination options (which might have presets)
|
|
873
|
-
if (!this._isPaginationInitialized) {
|
|
874
|
-
this.initializePaginationService(paginationOptions);
|
|
875
|
-
}
|
|
876
|
-
else {
|
|
877
|
-
// update the pagination service with the new total
|
|
878
|
-
this.paginationService.updateTotalItems(this.totalItems);
|
|
879
|
-
}
|
|
880
|
-
}
|
|
881
|
-
// resize the grid inside a slight timeout, in case other DOM element changed prior to the resize (like a filter/pagination changed)
|
|
882
|
-
if (this.slickGrid && this._gridOptions.enableAutoResize) {
|
|
883
|
-
const delay = this._gridOptions.autoResize && this._gridOptions.autoResize.delay;
|
|
884
|
-
this.resizerService.resizeGrid(delay || 10);
|
|
885
|
-
}
|
|
886
|
-
}
|
|
887
|
-
}
|
|
888
|
-
}
|
|
889
|
-
/**
|
|
890
|
-
* Dynamically change or update the column definitions list.
|
|
891
|
-
* We will re-render the grid so that the new header and data shows up correctly.
|
|
892
|
-
* If using translater, we also need to trigger a re-translate of the column headers
|
|
893
|
-
*/
|
|
894
|
-
updateColumnDefinitionsList(newColumnDefinitions) {
|
|
895
|
-
if (this.slickGrid && this._gridOptions && Array.isArray(newColumnDefinitions)) {
|
|
896
|
-
// map the Editor model to editorClass and load editor collectionAsync
|
|
897
|
-
newColumnDefinitions = this.loadSlickGridEditors(newColumnDefinitions);
|
|
898
|
-
// if the user wants to automatically add a Custom Editor Formatter, we need to call the auto add function again
|
|
899
|
-
if (this._gridOptions.autoAddCustomEditorFormatter) {
|
|
900
|
-
(0, common_1.autoAddEditorFormatterToColumnsWithEditor)(newColumnDefinitions, this._gridOptions.autoAddCustomEditorFormatter);
|
|
901
|
-
}
|
|
902
|
-
if (this._gridOptions.enableTranslate) {
|
|
903
|
-
this.extensionService.translateColumnHeaders(undefined, newColumnDefinitions);
|
|
904
|
-
}
|
|
905
|
-
else {
|
|
906
|
-
this.extensionService.renderColumnHeaders(newColumnDefinitions, true);
|
|
907
|
-
}
|
|
908
|
-
if (this.slickGrid && this._gridOptions?.enableAutoSizeColumns) {
|
|
909
|
-
this.slickGrid.autosizeColumns();
|
|
910
|
-
}
|
|
911
|
-
else if (this._gridOptions?.enableAutoResizeColumnsByCellContent && this.resizerService?.resizeColumnsByCellContent) {
|
|
912
|
-
this.resizerService.resizeColumnsByCellContent();
|
|
913
|
-
}
|
|
914
|
-
}
|
|
915
|
-
}
|
|
916
|
-
/**
|
|
917
|
-
* Show the filter row displayed on first row, we can optionally pass false to hide it.
|
|
918
|
-
* @param showing
|
|
919
|
-
*/
|
|
920
|
-
showHeaderRow(showing = true) {
|
|
921
|
-
this.slickGrid?.setHeaderRowVisibility(showing);
|
|
922
|
-
if (this.slickGrid && showing === true && this._isGridInitialized) {
|
|
923
|
-
this.slickGrid.setColumns(this.columnDefinitions);
|
|
924
|
-
}
|
|
925
|
-
return showing;
|
|
926
|
-
}
|
|
927
|
-
setData(data, shouldAutosizeColumns = false) {
|
|
928
|
-
if (shouldAutosizeColumns) {
|
|
929
|
-
this._isAutosizeColsCalled = false;
|
|
930
|
-
this._currentDatasetLength = 0;
|
|
931
|
-
}
|
|
932
|
-
this.dataset = data || [];
|
|
933
|
-
}
|
|
934
|
-
/**
|
|
935
|
-
* Check if there's any Pagination Presets defined in the Grid Options,
|
|
936
|
-
* if there are then load them in the paginationOptions object
|
|
937
|
-
*/
|
|
938
|
-
setPaginationOptionsWhenPresetDefined(gridOptions, paginationOptions) {
|
|
939
|
-
if (gridOptions.presets?.pagination && paginationOptions && !this._isPaginationInitialized) {
|
|
940
|
-
if (this.hasBackendInfiniteScroll()) {
|
|
941
|
-
console.warn('[Slickgrid-Universal] `presets.pagination` is not supported with Infinite Scroll, reverting to first page.');
|
|
942
|
-
}
|
|
943
|
-
else {
|
|
944
|
-
paginationOptions.pageSize = gridOptions.presets.pagination.pageSize;
|
|
945
|
-
paginationOptions.pageNumber = gridOptions.presets.pagination.pageNumber;
|
|
946
|
-
}
|
|
947
|
-
}
|
|
948
|
-
return paginationOptions;
|
|
949
|
-
}
|
|
950
|
-
setDarkMode(dark = false) {
|
|
951
|
-
if (dark) {
|
|
952
|
-
this._gridParentContainerElm.classList.add('slick-dark-mode');
|
|
953
|
-
}
|
|
954
|
-
else {
|
|
955
|
-
this._gridParentContainerElm.classList.remove('slick-dark-mode');
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
|
-
// --
|
|
959
|
-
// protected functions
|
|
960
|
-
// ------------------
|
|
961
|
-
/**
|
|
962
|
-
* Loop through all column definitions and copy the original optional `width` properties optionally provided by the user.
|
|
963
|
-
* We will use this when doing a resize by cell content, if user provided a `width` it won't override it.
|
|
964
|
-
*/
|
|
965
|
-
copyColumnWidthsReference(columnDefinitions) {
|
|
966
|
-
columnDefinitions.forEach((col) => (col.originalWidth = col.width));
|
|
967
|
-
}
|
|
968
|
-
displayEmptyDataWarning(showWarning = true) {
|
|
969
|
-
if (this.gridOptions.enableEmptyDataWarningMessage) {
|
|
970
|
-
this.slickEmptyWarning?.showEmptyDataMessage(showWarning);
|
|
971
|
-
}
|
|
972
|
-
}
|
|
973
|
-
/** When data changes in the DataView, we'll refresh the metrics and/or display a warning if the dataset is empty */
|
|
974
|
-
handleOnItemCountChanged(currentPageRowItemCount, totalItemCount) {
|
|
975
|
-
this._currentDatasetLength = totalItemCount;
|
|
976
|
-
this.metrics = {
|
|
977
|
-
startTime: new Date(),
|
|
978
|
-
endTime: new Date(),
|
|
979
|
-
itemCount: currentPageRowItemCount,
|
|
980
|
-
totalItemCount,
|
|
981
|
-
};
|
|
982
|
-
// if custom footer is enabled, then we'll update its metrics
|
|
983
|
-
if (this.slickFooter) {
|
|
984
|
-
this.slickFooter.metrics = this.metrics;
|
|
985
|
-
}
|
|
986
|
-
// when using local (in-memory) dataset, we'll display a warning message when filtered data is empty
|
|
987
|
-
if (this._isLocalGrid && this._gridOptions?.enableEmptyDataWarningMessage) {
|
|
988
|
-
this.displayEmptyDataWarning(currentPageRowItemCount === 0);
|
|
989
|
-
}
|
|
990
|
-
// when autoResize.autoHeight is enabled, we'll want to call a resize
|
|
991
|
-
if (this._gridOptions.enableAutoResize && this.resizerService.isAutoHeightEnabled && currentPageRowItemCount > 0) {
|
|
992
|
-
this.resizerService.resizeGrid();
|
|
993
|
-
}
|
|
994
|
-
}
|
|
995
|
-
/** Initialize the Pagination Service once */
|
|
996
|
-
initializePaginationService(paginationOptions) {
|
|
997
|
-
if (this.slickGrid && this.gridOptions) {
|
|
998
|
-
this.paginationData = {
|
|
999
|
-
gridOptions: this.gridOptions,
|
|
1000
|
-
paginationService: this.paginationService,
|
|
1001
|
-
};
|
|
1002
|
-
this.paginationService.totalItems = this.totalItems;
|
|
1003
|
-
this.paginationService.init(this.slickGrid, paginationOptions, this.backendServiceApi);
|
|
1004
|
-
this.subscriptions.push(this._eventPubSubService.subscribe('onPaginationChanged', (paginationChanges) => this.paginationChanged(paginationChanges)), this._eventPubSubService.subscribe('onPaginationVisibilityChanged', (visibility) => {
|
|
1005
|
-
this.showPagination = visibility?.visible ?? false;
|
|
1006
|
-
if (this.gridOptions?.backendServiceApi) {
|
|
1007
|
-
this.backendUtilityService?.refreshBackendDataset(this.gridOptions);
|
|
1008
|
-
}
|
|
1009
|
-
this.renderPagination(this.showPagination);
|
|
1010
|
-
}));
|
|
1011
|
-
// also initialize (render) the pagination component
|
|
1012
|
-
this.renderPagination();
|
|
1013
|
-
this._isPaginationInitialized = true;
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
|
-
/** handler for when column definitions changes */
|
|
1017
|
-
columnDefinitionsChanged(columnDefinitions) {
|
|
1018
|
-
if (columnDefinitions) {
|
|
1019
|
-
this._columnDefinitions = columnDefinitions;
|
|
1020
|
-
}
|
|
1021
|
-
if (this._isGridInitialized) {
|
|
1022
|
-
this.updateColumnDefinitionsList(this.columnDefinitions);
|
|
1023
|
-
}
|
|
1024
|
-
if (this.columnDefinitions.length > 0) {
|
|
1025
|
-
this.copyColumnWidthsReference(this.columnDefinitions);
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
/**
|
|
1029
|
-
* assignment changes are not triggering on the column definitions, for that
|
|
1030
|
-
* we can use our internal array observer for any changes done via (push, pop, shift, ...)
|
|
1031
|
-
*/
|
|
1032
|
-
observeColumnDefinitions() {
|
|
1033
|
-
this._collectionObservers.push((0, common_1.collectionObserver)(this.columnDefinitions, this.columnDefinitionsChanged.bind(this)));
|
|
1034
|
-
}
|
|
1035
|
-
/**
|
|
1036
|
-
* Render (or dispose) the Pagination Component, user can optionally provide False (to not show it) which will in term dispose of the Pagination,
|
|
1037
|
-
* 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)
|
|
1038
|
-
* @param {Boolean} showPagination - show (new render) or not (dispose) the Pagination
|
|
1039
|
-
* @param {Boolean} shouldDisposePaginationService - when disposing the Pagination, do we also want to dispose of the Pagination Service? (defaults to True)
|
|
1040
|
-
*/
|
|
1041
|
-
renderPagination(showPagination = true) {
|
|
1042
|
-
if (this.slickGrid && this._gridOptions?.enablePagination && !this._isPaginationInitialized && showPagination) {
|
|
1043
|
-
const PaginationClass = (this.gridOptions.customPaginationComponent ?? pagination_component_1.SlickPaginationComponent);
|
|
1044
|
-
this.paginationComponent = new PaginationClass();
|
|
1045
|
-
this.paginationComponent.init(this.slickGrid, this.paginationService, this._eventPubSubService, this.translaterService);
|
|
1046
|
-
this.paginationComponent.renderPagination(this._gridParentContainerElm);
|
|
1047
|
-
this._isPaginationInitialized = true;
|
|
1048
|
-
}
|
|
1049
|
-
else if (!showPagination) {
|
|
1050
|
-
this.paginationComponent?.dispose();
|
|
1051
|
-
this._isPaginationInitialized = false;
|
|
1052
|
-
}
|
|
1053
|
-
}
|
|
1054
|
-
/** Load the Editor Collection asynchronously and replace the "collection" property when Promise resolves */
|
|
1055
|
-
loadEditorCollectionAsync(column) {
|
|
1056
|
-
if (column?.editor) {
|
|
1057
|
-
column.editor.disabled = true; // disable the Editor DOM element, we'll re-enable it after receiving the collection with "updateEditorCollection()"
|
|
1058
|
-
(0, common_1.fetchAsPromise)(column.editor.collectionAsync, this.rxjs).then((resolvedCollection) => {
|
|
1059
|
-
this.updateEditorCollection(column, resolvedCollection);
|
|
1060
|
-
});
|
|
1061
|
-
}
|
|
1062
|
-
}
|
|
1063
|
-
insertDynamicPresetColumns(columnId, gridPresetColumns) {
|
|
1064
|
-
if (this._columnDefinitions) {
|
|
1065
|
-
const columnPosition = this._columnDefinitions.findIndex((c) => c.id === columnId);
|
|
1066
|
-
if (columnPosition >= 0) {
|
|
1067
|
-
const dynColumn = this._columnDefinitions[columnPosition];
|
|
1068
|
-
if (dynColumn?.id === columnId && !gridPresetColumns.some((c) => c.id === columnId)) {
|
|
1069
|
-
columnPosition > 0 ? gridPresetColumns.splice(columnPosition, 0, dynColumn) : gridPresetColumns.unshift(dynColumn);
|
|
1070
|
-
}
|
|
1071
|
-
}
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
|
-
/** Load any possible Columns Grid Presets */
|
|
1075
|
-
loadColumnPresetsWhenDatasetInitialized() {
|
|
1076
|
-
// if user entered some Columns "presets", we need to reflect them all in the grid
|
|
1077
|
-
if (this.slickGrid &&
|
|
1078
|
-
this.gridOptions.presets &&
|
|
1079
|
-
Array.isArray(this.gridOptions.presets.columns) &&
|
|
1080
|
-
this.gridOptions.presets.columns.length > 0) {
|
|
1081
|
-
const gridPresetColumns = this.gridStateService.getAssociatedGridColumns(this.slickGrid, this.gridOptions.presets.columns);
|
|
1082
|
-
if (gridPresetColumns && Array.isArray(gridPresetColumns) && gridPresetColumns.length > 0 && Array.isArray(this._columnDefinitions)) {
|
|
1083
|
-
// make sure that the dynamic columns are included in presets (1.Row Move, 2. Row Selection, 3. Row Detail)
|
|
1084
|
-
if (this.gridOptions.enableRowMoveManager) {
|
|
1085
|
-
const rmmColId = this.gridOptions?.rowMoveManager?.columnId ?? '_move';
|
|
1086
|
-
this.insertDynamicPresetColumns(rmmColId, gridPresetColumns);
|
|
1087
|
-
}
|
|
1088
|
-
if (this.gridOptions.enableCheckboxSelector) {
|
|
1089
|
-
const chkColId = this.gridOptions?.checkboxSelector?.columnId ?? '_checkbox_selector';
|
|
1090
|
-
this.insertDynamicPresetColumns(chkColId, gridPresetColumns);
|
|
1091
|
-
}
|
|
1092
|
-
if (this.gridOptions.enableRowDetailView) {
|
|
1093
|
-
const rdvColId = this.gridOptions?.rowDetailView?.columnId ?? '_detail_selector';
|
|
1094
|
-
this.insertDynamicPresetColumns(rdvColId, gridPresetColumns);
|
|
1095
|
-
}
|
|
1096
|
-
// keep copy the original optional `width` properties optionally provided by the user.
|
|
1097
|
-
// We will use this when doing a resize by cell content, if user provided a `width` it won't override it.
|
|
1098
|
-
gridPresetColumns.forEach((col) => (col.originalWidth = col.width));
|
|
1099
|
-
// finally set the new presets columns (including checkbox selector if need be)
|
|
1100
|
-
this.slickGrid.setColumns(gridPresetColumns);
|
|
1101
|
-
this.sharedService.visibleColumns = gridPresetColumns;
|
|
1102
|
-
}
|
|
1103
|
-
}
|
|
1104
|
-
}
|
|
1105
|
-
/** Load any possible Filters Grid Presets */
|
|
1106
|
-
loadFilterPresetsWhenDatasetInitialized() {
|
|
1107
|
-
if (this.gridOptions && !this.customDataView) {
|
|
1108
|
-
// if user entered some Filter "presets", we need to reflect them all in the DOM
|
|
1109
|
-
// also note that a presets of Tree Data Toggling will also call this method because Tree Data toggling does work with data filtering
|
|
1110
|
-
// (collapsing a parent will basically use Filter for hidding (aka collapsing) away the child underneat it)
|
|
1111
|
-
if (this.gridOptions.presets &&
|
|
1112
|
-
(Array.isArray(this.gridOptions.presets.filters) || Array.isArray(this.gridOptions.presets?.treeData?.toggledItems))) {
|
|
1113
|
-
this.filterService.populateColumnFilterSearchTermPresets(this.gridOptions.presets?.filters || []);
|
|
1114
|
-
}
|
|
1115
|
-
}
|
|
1116
|
-
}
|
|
1117
|
-
/**
|
|
1118
|
-
* local grid, check if we need to show the Pagination
|
|
1119
|
-
* if so then also check if there's any presets and finally initialize the PaginationService
|
|
1120
|
-
* a local grid with Pagination presets will potentially have a different total of items, we'll need to get it from the DataView and update our total
|
|
1121
|
-
*/
|
|
1122
|
-
loadLocalGridPagination(dataset) {
|
|
1123
|
-
if (this.gridOptions && this._paginationOptions) {
|
|
1124
|
-
this.totalItems = Array.isArray(dataset) ? dataset.length : 0;
|
|
1125
|
-
if (this._paginationOptions && this.dataView?.getPagingInfo) {
|
|
1126
|
-
const slickPagingInfo = this.dataView.getPagingInfo();
|
|
1127
|
-
if (slickPagingInfo?.hasOwnProperty('totalRows') && this._paginationOptions.totalItems !== slickPagingInfo.totalRows) {
|
|
1128
|
-
this.totalItems = slickPagingInfo?.totalRows || 0;
|
|
1129
|
-
}
|
|
1130
|
-
}
|
|
1131
|
-
this._paginationOptions.totalItems = this.totalItems;
|
|
1132
|
-
const paginationOptions = this.setPaginationOptionsWhenPresetDefined(this.gridOptions, this._paginationOptions);
|
|
1133
|
-
this.initializePaginationService(paginationOptions);
|
|
1134
|
-
}
|
|
1135
|
-
}
|
|
1136
|
-
/** Load any Row Selections into the DataView that were presets by the user */
|
|
1137
|
-
loadRowSelectionPresetWhenExists() {
|
|
1138
|
-
// if user entered some Row Selections "presets"
|
|
1139
|
-
const presets = this.gridOptions?.presets;
|
|
1140
|
-
const selectionModel = this.slickGrid?.getSelectionModel();
|
|
1141
|
-
const enableRowSelection = this.gridOptions && (this.gridOptions.enableCheckboxSelector || this.gridOptions.enableRowSelection);
|
|
1142
|
-
if (this.slickGrid &&
|
|
1143
|
-
this.dataView &&
|
|
1144
|
-
enableRowSelection &&
|
|
1145
|
-
selectionModel &&
|
|
1146
|
-
presets?.rowSelection &&
|
|
1147
|
-
(Array.isArray(presets.rowSelection.gridRowIndexes) || Array.isArray(presets.rowSelection.dataContextIds))) {
|
|
1148
|
-
let dataContextIds = presets.rowSelection.dataContextIds;
|
|
1149
|
-
let gridRowIndexes = presets.rowSelection.gridRowIndexes;
|
|
1150
|
-
// maps the IDs to the Grid Rows and vice versa, the "dataContextIds" has precedence over the other
|
|
1151
|
-
if (Array.isArray(dataContextIds) && dataContextIds.length > 0) {
|
|
1152
|
-
gridRowIndexes = this.dataView.mapIdsToRows(dataContextIds) || [];
|
|
1153
|
-
}
|
|
1154
|
-
else if (Array.isArray(gridRowIndexes) && gridRowIndexes.length > 0) {
|
|
1155
|
-
dataContextIds = this.dataView.mapRowsToIds(gridRowIndexes) || [];
|
|
1156
|
-
}
|
|
1157
|
-
// apply row selection when defined as grid presets
|
|
1158
|
-
if (this.slickGrid && Array.isArray(gridRowIndexes)) {
|
|
1159
|
-
this.slickGrid.setSelectedRows(gridRowIndexes);
|
|
1160
|
-
this.dataView.setSelectedIds(dataContextIds || [], {
|
|
1161
|
-
isRowBeingAdded: true,
|
|
1162
|
-
shouldTriggerEvent: false, // do not trigger when presetting the grid
|
|
1163
|
-
applyRowSelectionToGrid: true,
|
|
1164
|
-
});
|
|
1165
|
-
}
|
|
1166
|
-
}
|
|
1167
|
-
}
|
|
1168
|
-
/** Add a register a new external resource, user could also optional dispose all previous resources before pushing any new resources to the resources array list. */
|
|
1169
|
-
registerExternalResources(resources, disposePreviousResources = false) {
|
|
1170
|
-
if (disposePreviousResources) {
|
|
1171
|
-
this.disposeExternalResources();
|
|
1172
|
-
}
|
|
1173
|
-
resources.forEach((res) => this._registeredResources.push(res));
|
|
1174
|
-
this.initializeExternalResources(resources);
|
|
1175
|
-
}
|
|
1176
|
-
resetExternalResources() {
|
|
1177
|
-
this._registeredResources = [];
|
|
1178
|
-
}
|
|
1179
|
-
/** Pre-Register any Resource that don't require SlickGrid to be instantiated (for example RxJS Resource) */
|
|
1180
|
-
preRegisterResources() {
|
|
1181
|
-
// bind & initialize all Components/Services that were tagged as enabled
|
|
1182
|
-
// register all services by executing their init method and providing them with the Grid object
|
|
1183
|
-
if (Array.isArray(this._registeredResources)) {
|
|
1184
|
-
for (const resource of this._registeredResources) {
|
|
1185
|
-
if (resource?.className === 'RxJsResource') {
|
|
1186
|
-
this.registerRxJsResource(resource);
|
|
1187
|
-
}
|
|
1188
|
-
}
|
|
1189
|
-
}
|
|
1190
|
-
}
|
|
1191
|
-
initializeExternalResources(resources) {
|
|
1192
|
-
if (Array.isArray(resources)) {
|
|
1193
|
-
for (const resource of resources) {
|
|
1194
|
-
if (this.slickGrid && typeof resource.init === 'function') {
|
|
1195
|
-
resource.init(this.slickGrid, this.universalContainerService);
|
|
1196
|
-
}
|
|
1197
|
-
}
|
|
1198
|
-
}
|
|
1199
|
-
}
|
|
1200
|
-
registerResources() {
|
|
1201
|
-
// at this point, we consider all the registered services as external services, anything else registered afterward aren't external
|
|
1202
|
-
if (Array.isArray(this._registeredResources)) {
|
|
1203
|
-
this.sharedService.externalRegisteredResources = this._registeredResources;
|
|
1204
|
-
}
|
|
1205
|
-
// push all other Services that we want to be registered
|
|
1206
|
-
this._registeredResources.push(this.gridService, this.gridStateService);
|
|
1207
|
-
// when using Grouping/DraggableGrouping/Colspan register its Service
|
|
1208
|
-
if ((this.gridOptions.createPreHeaderPanel && this.gridOptions.createTopHeaderPanel) ||
|
|
1209
|
-
(this.gridOptions.createPreHeaderPanel && !this.gridOptions.enableDraggableGrouping)) {
|
|
1210
|
-
this._registeredResources.push(this.headerGroupingService);
|
|
1211
|
-
}
|
|
1212
|
-
// when using Tree Data View, register its Service
|
|
1213
|
-
if (this.gridOptions.enableTreeData) {
|
|
1214
|
-
this._registeredResources.push(this.treeDataService);
|
|
1215
|
-
}
|
|
1216
|
-
// when user enables translation, we need to translate Headers on first pass & subsequently in the bindDifferentHooks
|
|
1217
|
-
if (this.gridOptions.enableTranslate) {
|
|
1218
|
-
this.extensionService.translateColumnHeaders();
|
|
1219
|
-
}
|
|
1220
|
-
// also initialize (render) the empty warning component
|
|
1221
|
-
this.slickEmptyWarning = new empty_warning_component_1.SlickEmptyWarningComponent();
|
|
1222
|
-
this._registeredResources.push(this.slickEmptyWarning);
|
|
1223
|
-
// bind & initialize all Components/Services that were tagged as enabled
|
|
1224
|
-
// register all services by executing their init method and providing them with the Grid object
|
|
1225
|
-
this.initializeExternalResources(this._registeredResources);
|
|
1226
|
-
}
|
|
1227
|
-
/** Register the RxJS Resource in all necessary services which uses */
|
|
1228
|
-
registerRxJsResource(resource) {
|
|
1229
|
-
this.rxjs = resource;
|
|
1230
|
-
this.backendUtilityService.addRxJsResource(this.rxjs);
|
|
1231
|
-
this.filterFactory.addRxJsResource(this.rxjs);
|
|
1232
|
-
this.filterService.addRxJsResource(this.rxjs);
|
|
1233
|
-
this.sortService.addRxJsResource(this.rxjs);
|
|
1234
|
-
this.paginationService.addRxJsResource(this.rxjs);
|
|
1235
|
-
this.universalContainerService.registerInstance('RxJsFacade', this.rxjs);
|
|
1236
|
-
this.universalContainerService.registerInstance('RxJsResource', this.rxjs);
|
|
1237
|
-
}
|
|
1238
|
-
/**
|
|
1239
|
-
* Takes a flat dataset with parent/child relationship, sort it (via its tree structure) and return the sorted flat array
|
|
1240
|
-
* @returns {Array<Object>} sort flat parent/child dataset
|
|
1241
|
-
*/
|
|
1242
|
-
sortTreeDataset(flatDatasetInput, forceGridRefresh = false) {
|
|
1243
|
-
const prevDatasetLn = this._currentDatasetLength;
|
|
1244
|
-
let sortedDatasetResult;
|
|
1245
|
-
let flatDatasetOutput = [];
|
|
1246
|
-
// if the hierarchical dataset was already initialized then no need to re-convert it, we can use it directly from the shared service ref
|
|
1247
|
-
if (this._isDatasetHierarchicalInitialized && this.datasetHierarchical) {
|
|
1248
|
-
sortedDatasetResult = this.treeDataService.sortHierarchicalDataset(this.datasetHierarchical);
|
|
1249
|
-
flatDatasetOutput = sortedDatasetResult.flat;
|
|
1250
|
-
}
|
|
1251
|
-
else if (Array.isArray(flatDatasetInput) && flatDatasetInput.length > 0) {
|
|
1252
|
-
// we need to first convert the flat dataset to a hierarchical dataset and then sort it
|
|
1253
|
-
// we'll also add props, by mutation, required by the TreeDataService on the flat array like `__hasChildren`, `parentId` and anything else to work properly
|
|
1254
|
-
sortedDatasetResult = this.treeDataService.convertFlatParentChildToTreeDatasetAndSort(flatDatasetInput, this._columnDefinitions || [], this.gridOptions);
|
|
1255
|
-
this.sharedService.hierarchicalDataset = sortedDatasetResult.hierarchical;
|
|
1256
|
-
flatDatasetOutput = sortedDatasetResult.flat;
|
|
1257
|
-
}
|
|
1258
|
-
// if we add/remove item(s) from the dataset, we need to also refresh our tree data filters
|
|
1259
|
-
if (flatDatasetInput.length > 0 && (forceGridRefresh || flatDatasetInput.length !== prevDatasetLn)) {
|
|
1260
|
-
this.filterService.refreshTreeDataFilters(flatDatasetOutput);
|
|
1261
|
-
}
|
|
1262
|
-
return flatDatasetOutput;
|
|
1263
|
-
}
|
|
1264
|
-
/** Prepare and load all SlickGrid editors, if an async editor is found then we'll also execute it. */
|
|
1265
|
-
loadSlickGridEditors(columnDefinitions) {
|
|
1266
|
-
const columns = Array.isArray(columnDefinitions) ? columnDefinitions : [];
|
|
1267
|
-
if (columns.some((col) => `${col.id}`.includes('.'))) {
|
|
1268
|
-
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".');
|
|
1269
|
-
}
|
|
1270
|
-
return columns.map((column) => {
|
|
1271
|
-
// on every Editor that have a "collectionAsync", resolve the data and assign it to the "collection" property
|
|
1272
|
-
if (column.editor?.collectionAsync) {
|
|
1273
|
-
this.loadEditorCollectionAsync(column);
|
|
1274
|
-
}
|
|
1275
|
-
return { ...column, editorClass: column.editor?.model };
|
|
1276
|
-
});
|
|
1277
|
-
}
|
|
1278
|
-
suggestDateParsingWhenHelpful() {
|
|
1279
|
-
if (!this.gridOptions.silenceWarnings &&
|
|
1280
|
-
this.dataView &&
|
|
1281
|
-
this.dataView.getItemCount() > WARN_NO_PREPARSE_DATE_SIZE &&
|
|
1282
|
-
!this.gridOptions.preParseDateColumns &&
|
|
1283
|
-
this.slickGrid?.getColumns().some((c) => (0, common_1.isColumnDateType)(c.type))) {
|
|
1284
|
-
console.warn('[Slickgrid-Universal] For getting better perf, we suggest you enable the `preParseDateColumns` grid option, ' +
|
|
1285
|
-
'for more info visit => https://ghiscoding.gitbook.io/slickgrid-universal/column-functionalities/sorting#pre-parse-date-columns-for-better-perf');
|
|
1286
|
-
}
|
|
1287
|
-
}
|
|
1288
|
-
/**
|
|
1289
|
-
* When the Editor(s) has a "editor.collection" property, we'll load the async collection.
|
|
1290
|
-
* Since this is called after the async call resolves, the pointer will not be the same as the "column" argument passed.
|
|
1291
|
-
*/
|
|
1292
|
-
updateEditorCollection(column, newCollection) {
|
|
1293
|
-
if (this.slickGrid && column.editor) {
|
|
1294
|
-
column.editor.collection = newCollection;
|
|
1295
|
-
column.editor.disabled = false;
|
|
1296
|
-
// get current Editor, remove it from the DOm then re-enable it and re-render it with the new collection.
|
|
1297
|
-
const currentEditor = this.slickGrid.getCellEditor();
|
|
1298
|
-
if (currentEditor?.disable && currentEditor.renderDomElement) {
|
|
1299
|
-
if (typeof currentEditor.destroy === 'function') {
|
|
1300
|
-
currentEditor.destroy();
|
|
1301
|
-
}
|
|
1302
|
-
currentEditor.disable(false);
|
|
1303
|
-
currentEditor.renderDomElement(newCollection);
|
|
1304
|
-
}
|
|
1305
|
-
}
|
|
1306
|
-
}
|
|
1307
|
-
}
|
|
1308
|
-
exports.SlickVanillaGridBundle = SlickVanillaGridBundle;
|
|
1309
|
-
//# sourceMappingURL=slick-vanilla-grid-bundle.js.map
|