slickgrid-react 1.0.0-beta.1 → 2.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/.eslintrc +2 -2
- package/.hintrc +11 -0
- package/.release-it.json +25 -0
- package/CHANGELOG.md +31 -0
- package/LICENSE +1 -1
- package/README.md +65 -38
- package/dist/amd/{custom-elements → components}/slickgrid-react.d.ts +68 -98
- package/dist/amd/{custom-elements → components}/slickgrid-react.js +380 -314
- package/dist/amd/components/slickgrid-react.js.map +1 -0
- package/dist/amd/{custom-elements → components}/slickgridEventAggregator.d.ts +0 -0
- package/dist/amd/{custom-elements → components}/slickgridEventAggregator.js +0 -0
- package/dist/amd/components/slickgridEventAggregator.js.map +1 -0
- package/dist/amd/components/slickgridReactProps.d.ts +288 -0
- package/dist/amd/{models/rowDetailView.interface.js → components/slickgridReactProps.js} +1 -1
- package/dist/amd/components/slickgridReactProps.js.map +1 -0
- package/dist/amd/constants.js +1 -0
- package/dist/amd/constants.js.map +1 -1
- package/dist/amd/global-grid-options.js +1 -11
- package/dist/amd/global-grid-options.js.map +1 -1
- package/dist/amd/index.d.ts +4 -7
- package/dist/amd/index.js +8 -4
- package/dist/amd/index.js.map +1 -1
- package/dist/amd/models/gridOption.interface.d.ts +0 -3
- package/dist/amd/models/index.d.ts +0 -3
- package/dist/amd/models/index.js +6 -5
- package/dist/amd/models/index.js.map +1 -1
- package/dist/amd/models/reactGridInstance.interface.d.ts +3 -3
- package/dist/amd/services/index.js +5 -1
- package/dist/amd/services/index.js.map +1 -1
- package/dist/amd/services/reactUtil.service.js +1 -1
- package/dist/amd/services/reactUtil.service.js.map +1 -1
- package/dist/amd/services/translater.service.d.ts +0 -1
- package/dist/amd/services/translater.service.js +2 -11
- package/dist/amd/services/translater.service.js.map +1 -1
- package/dist/amd/services/utilities.js +1 -2
- package/dist/amd/services/utilities.js.map +1 -1
- package/dist/{esm/custom-elements → cjs/components}/slickgrid-react.d.ts +68 -98
- package/dist/{commonjs/custom-elements → cjs/components}/slickgrid-react.js +383 -321
- package/dist/cjs/components/slickgrid-react.js.map +1 -0
- package/dist/{commonjs/custom-elements → cjs/components}/slickgridEventAggregator.d.ts +0 -0
- package/dist/{commonjs/custom-elements → cjs/components}/slickgridEventAggregator.js +0 -0
- package/dist/cjs/components/slickgridEventAggregator.js.map +1 -0
- package/dist/cjs/components/slickgridReactProps.d.ts +288 -0
- package/dist/{commonjs/models/rowDetailView.interface.js → cjs/components/slickgridReactProps.js} +1 -1
- package/dist/cjs/components/slickgridReactProps.js.map +1 -0
- package/dist/{commonjs → cjs}/constants.d.ts +0 -0
- package/dist/{commonjs → cjs}/constants.js +1 -0
- package/dist/{commonjs → cjs}/constants.js.map +1 -1
- package/dist/{commonjs → cjs}/global-grid-options.d.ts +0 -0
- package/dist/{commonjs → cjs}/global-grid-options.js +1 -11
- package/dist/{commonjs → cjs}/global-grid-options.js.map +1 -1
- package/dist/cjs/index.d.ts +8 -0
- package/dist/{commonjs → cjs}/index.js +9 -8
- package/dist/cjs/index.js.map +1 -0
- package/dist/{native-modules → cjs}/models/gridOption.interface.d.ts +0 -3
- package/dist/{commonjs → cjs}/models/gridOption.interface.js +0 -0
- package/dist/{commonjs → cjs}/models/gridOption.interface.js.map +0 -0
- package/dist/{native-modules → cjs}/models/index.d.ts +0 -3
- package/dist/{commonjs → cjs}/models/index.js +5 -4
- package/dist/{commonjs → cjs}/models/index.js.map +1 -1
- package/dist/{commonjs → cjs}/models/reactComponentOutput.interface.d.ts +0 -0
- package/dist/{commonjs → cjs}/models/reactComponentOutput.interface.js +0 -0
- package/dist/{commonjs → cjs}/models/reactComponentOutput.interface.js.map +0 -0
- package/dist/{native-modules → cjs}/models/reactGridInstance.interface.d.ts +3 -3
- package/dist/{commonjs → cjs}/models/reactGridInstance.interface.js +0 -0
- package/dist/{commonjs → cjs}/models/reactGridInstance.interface.js.map +0 -0
- package/dist/{commonjs → cjs}/models/slickGrid.interface.d.ts +0 -0
- package/dist/{commonjs → cjs}/models/slickGrid.interface.js +0 -0
- package/dist/{commonjs → cjs}/models/slickGrid.interface.js.map +0 -0
- package/dist/{commonjs → cjs}/services/container.service.d.ts +0 -0
- package/dist/{commonjs → cjs}/services/container.service.js +0 -0
- package/dist/{commonjs → cjs}/services/container.service.js.map +0 -0
- package/dist/{commonjs → cjs}/services/index.d.ts +0 -0
- package/dist/{commonjs → cjs}/services/index.js +5 -1
- package/dist/{commonjs → cjs}/services/index.js.map +1 -1
- package/dist/{commonjs → cjs}/services/reactUtil.service.d.ts +0 -0
- package/dist/{commonjs → cjs}/services/reactUtil.service.js +1 -1
- package/dist/cjs/services/reactUtil.service.js.map +1 -0
- package/dist/{commonjs → cjs}/services/singletons.d.ts +0 -0
- package/dist/{commonjs → cjs}/services/singletons.js +0 -0
- package/dist/{commonjs → cjs}/services/singletons.js.map +0 -0
- package/dist/{native-modules → cjs}/services/translater.service.d.ts +0 -1
- package/dist/{commonjs → cjs}/services/translater.service.js +1 -11
- package/dist/cjs/services/translater.service.js.map +1 -0
- package/dist/{commonjs → cjs}/services/utilities.d.ts +0 -0
- package/dist/{commonjs → cjs}/services/utilities.js +1 -2
- package/dist/cjs/services/utilities.js.map +1 -0
- package/dist/{commonjs → cjs}/slickgrid-config.d.ts +0 -0
- package/dist/{commonjs → cjs}/slickgrid-config.js +0 -0
- package/dist/{commonjs → cjs}/slickgrid-config.js.map +0 -0
- package/dist/{commonjs/custom-elements → esm/components}/slickgrid-react.d.ts +68 -98
- package/dist/esm/{custom-elements → components}/slickgrid-react.js +360 -323
- package/dist/esm/components/slickgrid-react.js.map +1 -0
- package/dist/esm/{custom-elements → components}/slickgridEventAggregator.d.ts +0 -0
- package/dist/esm/{custom-elements → components}/slickgridEventAggregator.js +0 -0
- package/dist/esm/components/slickgridEventAggregator.js.map +1 -0
- package/dist/esm/components/slickgridReactProps.d.ts +288 -0
- package/dist/esm/components/slickgridReactProps.js +2 -0
- package/dist/esm/components/slickgridReactProps.js.map +1 -0
- package/dist/esm/constants.js +1 -0
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/global-grid-options.js +1 -11
- package/dist/esm/global-grid-options.js.map +1 -1
- package/dist/esm/index.d.ts +4 -7
- package/dist/esm/index.js +3 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/models/gridOption.interface.d.ts +0 -3
- package/dist/esm/models/index.d.ts +0 -3
- package/dist/esm/models/index.js +0 -3
- package/dist/esm/models/index.js.map +1 -1
- package/dist/esm/models/reactGridInstance.interface.d.ts +3 -3
- package/dist/esm/services/reactUtil.service.js +1 -1
- package/dist/esm/services/reactUtil.service.js.map +1 -1
- package/dist/esm/services/translater.service.d.ts +0 -1
- package/dist/esm/services/translater.service.js +1 -11
- package/dist/esm/services/translater.service.js.map +1 -1
- package/dist/esm/services/utilities.js +1 -2
- package/dist/esm/services/utilities.js.map +1 -1
- package/package.json +103 -126
- package/dist/amd/custom-elements/slickgrid-react.js.map +0 -1
- package/dist/amd/custom-elements/slickgridEventAggregator.js.map +0 -1
- package/dist/amd/extensions/index.d.ts +0 -1
- package/dist/amd/extensions/index.js +0 -16
- package/dist/amd/extensions/index.js.map +0 -1
- package/dist/amd/extensions/rowDetailViewExtension.d.ts +0 -70
- package/dist/amd/extensions/rowDetailViewExtension.js +0 -362
- package/dist/amd/extensions/rowDetailViewExtension.js.map +0 -1
- package/dist/amd/models/rowDetailView.interface.d.ts +0 -24
- package/dist/amd/models/rowDetailView.interface.js.map +0 -1
- package/dist/amd/models/viewModelBindableData.interface.d.ts +0 -10
- package/dist/amd/models/viewModelBindableData.interface.js +0 -5
- package/dist/amd/models/viewModelBindableData.interface.js.map +0 -1
- package/dist/amd/models/viewModelBindableInputData.interface.d.ts +0 -9
- package/dist/amd/models/viewModelBindableInputData.interface.js +0 -5
- package/dist/amd/models/viewModelBindableInputData.interface.js.map +0 -1
- package/dist/amd/value-converters/asgDateFormat.d.ts +0 -3
- package/dist/amd/value-converters/asgDateFormat.js +0 -16
- package/dist/amd/value-converters/asgDateFormat.js.map +0 -1
- package/dist/amd/value-converters/asgNumber.d.ts +0 -3
- package/dist/amd/value-converters/asgNumber.js +0 -13
- package/dist/amd/value-converters/asgNumber.js.map +0 -1
- package/dist/commonjs/custom-elements/slickgrid-react.js.map +0 -1
- package/dist/commonjs/custom-elements/slickgridEventAggregator.js.map +0 -1
- package/dist/commonjs/extensions/index.d.ts +0 -1
- package/dist/commonjs/extensions/index.js +0 -14
- package/dist/commonjs/extensions/index.js.map +0 -1
- package/dist/commonjs/extensions/rowDetailViewExtension.d.ts +0 -70
- package/dist/commonjs/extensions/rowDetailViewExtension.js +0 -363
- package/dist/commonjs/extensions/rowDetailViewExtension.js.map +0 -1
- package/dist/commonjs/index.d.ts +0 -11
- package/dist/commonjs/index.js.map +0 -1
- package/dist/commonjs/models/gridOption.interface.d.ts +0 -9
- package/dist/commonjs/models/index.d.ts +0 -7
- package/dist/commonjs/models/reactGridInstance.interface.d.ts +0 -36
- package/dist/commonjs/models/rowDetailView.interface.d.ts +0 -24
- package/dist/commonjs/models/rowDetailView.interface.js.map +0 -1
- package/dist/commonjs/models/viewModelBindableData.interface.d.ts +0 -10
- package/dist/commonjs/models/viewModelBindableData.interface.js +0 -3
- package/dist/commonjs/models/viewModelBindableData.interface.js.map +0 -1
- package/dist/commonjs/models/viewModelBindableInputData.interface.d.ts +0 -9
- package/dist/commonjs/models/viewModelBindableInputData.interface.js +0 -3
- package/dist/commonjs/models/viewModelBindableInputData.interface.js.map +0 -1
- package/dist/commonjs/services/reactUtil.service.js.map +0 -1
- package/dist/commonjs/services/translater.service.d.ts +0 -26
- package/dist/commonjs/services/translater.service.js.map +0 -1
- package/dist/commonjs/services/utilities.js.map +0 -1
- package/dist/commonjs/value-converters/asgDateFormat.d.ts +0 -3
- package/dist/commonjs/value-converters/asgDateFormat.js +0 -14
- package/dist/commonjs/value-converters/asgDateFormat.js.map +0 -1
- package/dist/commonjs/value-converters/asgNumber.d.ts +0 -3
- package/dist/commonjs/value-converters/asgNumber.js +0 -11
- package/dist/commonjs/value-converters/asgNumber.js.map +0 -1
- package/dist/esm/custom-elements/slickgrid-react.js.map +0 -1
- package/dist/esm/custom-elements/slickgridEventAggregator.js.map +0 -1
- package/dist/esm/extensions/index.d.ts +0 -1
- package/dist/esm/extensions/index.js +0 -2
- package/dist/esm/extensions/index.js.map +0 -1
- package/dist/esm/extensions/rowDetailViewExtension.d.ts +0 -70
- package/dist/esm/extensions/rowDetailViewExtension.js +0 -337
- package/dist/esm/extensions/rowDetailViewExtension.js.map +0 -1
- package/dist/esm/models/rowDetailView.interface.d.ts +0 -24
- package/dist/esm/models/rowDetailView.interface.js +0 -2
- package/dist/esm/models/rowDetailView.interface.js.map +0 -1
- package/dist/esm/models/viewModelBindableData.interface.d.ts +0 -10
- package/dist/esm/models/viewModelBindableData.interface.js +0 -2
- package/dist/esm/models/viewModelBindableData.interface.js.map +0 -1
- package/dist/esm/models/viewModelBindableInputData.interface.d.ts +0 -9
- package/dist/esm/models/viewModelBindableInputData.interface.js +0 -2
- package/dist/esm/models/viewModelBindableInputData.interface.js.map +0 -1
- package/dist/esm/value-converters/asgDateFormat.d.ts +0 -3
- package/dist/esm/value-converters/asgDateFormat.js +0 -7
- package/dist/esm/value-converters/asgDateFormat.js.map +0 -1
- package/dist/esm/value-converters/asgNumber.d.ts +0 -3
- package/dist/esm/value-converters/asgNumber.js +0 -7
- package/dist/esm/value-converters/asgNumber.js.map +0 -1
- package/dist/i18n/en/aurelia-slickgrid.json +0 -97
- package/dist/i18n/fr/aurelia-slickgrid.json +0 -98
- package/dist/native-modules/constants.d.ts +0 -23
- package/dist/native-modules/constants.js +0 -86
- package/dist/native-modules/constants.js.map +0 -1
- package/dist/native-modules/custom-elements/slickgrid-react.d.ts +0 -236
- package/dist/native-modules/custom-elements/slickgrid-react.js +0 -1257
- package/dist/native-modules/custom-elements/slickgrid-react.js.map +0 -1
- package/dist/native-modules/custom-elements/slickgridEventAggregator.d.ts +0 -10
- package/dist/native-modules/custom-elements/slickgridEventAggregator.js +0 -8
- package/dist/native-modules/custom-elements/slickgridEventAggregator.js.map +0 -1
- package/dist/native-modules/extensions/index.d.ts +0 -1
- package/dist/native-modules/extensions/index.js +0 -2
- package/dist/native-modules/extensions/index.js.map +0 -1
- package/dist/native-modules/extensions/rowDetailViewExtension.d.ts +0 -70
- package/dist/native-modules/extensions/rowDetailViewExtension.js +0 -337
- package/dist/native-modules/extensions/rowDetailViewExtension.js.map +0 -1
- package/dist/native-modules/global-grid-options.d.ts +0 -5
- package/dist/native-modules/global-grid-options.js +0 -270
- package/dist/native-modules/global-grid-options.js.map +0 -1
- package/dist/native-modules/index.d.ts +0 -11
- package/dist/native-modules/index.js +0 -12
- package/dist/native-modules/index.js.map +0 -1
- package/dist/native-modules/models/gridOption.interface.js +0 -2
- package/dist/native-modules/models/gridOption.interface.js.map +0 -1
- package/dist/native-modules/models/index.js +0 -8
- package/dist/native-modules/models/index.js.map +0 -1
- package/dist/native-modules/models/reactComponentOutput.interface.d.ts +0 -6
- package/dist/native-modules/models/reactComponentOutput.interface.js +0 -2
- package/dist/native-modules/models/reactComponentOutput.interface.js.map +0 -1
- package/dist/native-modules/models/reactGridInstance.interface.js +0 -2
- package/dist/native-modules/models/reactGridInstance.interface.js.map +0 -1
- package/dist/native-modules/models/rowDetailView.interface.d.ts +0 -24
- package/dist/native-modules/models/rowDetailView.interface.js +0 -2
- package/dist/native-modules/models/rowDetailView.interface.js.map +0 -1
- package/dist/native-modules/models/slickGrid.interface.d.ts +0 -6
- package/dist/native-modules/models/slickGrid.interface.js +0 -2
- package/dist/native-modules/models/slickGrid.interface.js.map +0 -1
- package/dist/native-modules/models/viewModelBindableData.interface.d.ts +0 -10
- package/dist/native-modules/models/viewModelBindableData.interface.js +0 -2
- package/dist/native-modules/models/viewModelBindableData.interface.js.map +0 -1
- package/dist/native-modules/models/viewModelBindableInputData.interface.d.ts +0 -9
- package/dist/native-modules/models/viewModelBindableInputData.interface.js +0 -2
- package/dist/native-modules/models/viewModelBindableInputData.interface.js.map +0 -1
- package/dist/native-modules/services/container.service.d.ts +0 -6
- package/dist/native-modules/services/container.service.js +0 -12
- package/dist/native-modules/services/container.service.js.map +0 -1
- package/dist/native-modules/services/index.d.ts +0 -4
- package/dist/native-modules/services/index.js +0 -5
- package/dist/native-modules/services/index.js.map +0 -1
- package/dist/native-modules/services/reactUtil.service.d.ts +0 -5
- package/dist/native-modules/services/reactUtil.service.js +0 -21
- package/dist/native-modules/services/reactUtil.service.js.map +0 -1
- package/dist/native-modules/services/singletons.d.ts +0 -6
- package/dist/native-modules/services/singletons.js +0 -7
- package/dist/native-modules/services/singletons.js.map +0 -1
- package/dist/native-modules/services/translater.service.js +0 -44
- package/dist/native-modules/services/translater.service.js.map +0 -1
- package/dist/native-modules/services/utilities.d.ts +0 -7
- package/dist/native-modules/services/utilities.js +0 -18
- package/dist/native-modules/services/utilities.js.map +0 -1
- package/dist/native-modules/slickgrid-config.d.ts +0 -5
- package/dist/native-modules/slickgrid-config.js +0 -7
- package/dist/native-modules/slickgrid-config.js.map +0 -1
- package/dist/native-modules/value-converters/asgDateFormat.d.ts +0 -3
- package/dist/native-modules/value-converters/asgDateFormat.js +0 -7
- package/dist/native-modules/value-converters/asgDateFormat.js.map +0 -1
- package/dist/native-modules/value-converters/asgNumber.d.ts +0 -3
- package/dist/native-modules/value-converters/asgNumber.js +0 -7
- package/dist/native-modules/value-converters/asgNumber.js.map +0 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
|
+
var _a;
|
|
1
2
|
// import 3rd party vendor libs
|
|
2
|
-
|
|
3
|
-
import '
|
|
4
|
-
import 'slickgrid/lib/jquery.mousewheel';
|
|
5
|
-
import 'slickgrid/slick.core';
|
|
6
|
-
import 'slickgrid/slick.dataview';
|
|
7
|
-
import 'slickgrid/slick.grid';
|
|
8
|
-
import 'slickgrid/slick.groupitemmetadataprovider';
|
|
3
|
+
import * as $ from 'jquery';
|
|
4
|
+
import i18next from 'i18next';
|
|
9
5
|
import React from 'react';
|
|
6
|
+
import 'slickgrid/dist/slick.core.min';
|
|
7
|
+
import 'slickgrid/dist/slick.interactions.min';
|
|
8
|
+
import 'slickgrid/dist/slick.grid.min';
|
|
9
|
+
import 'slickgrid/dist/slick.dataview.min';
|
|
10
|
+
import * as Sortable_ from 'sortablejs';
|
|
11
|
+
const Sortable = ((_a = Sortable_ === null || Sortable_ === void 0 ? void 0 : Sortable_['default']) !== null && _a !== void 0 ? _a : Sortable_); // patch for rollup
|
|
10
12
|
import { GridStateType,
|
|
11
13
|
// services
|
|
12
|
-
BackendUtilityService, CollectionService, EventNamingStyle, ExtensionService, FilterFactory, FilterService, GridEventService, GridService, GridStateService, GroupingAndColspanService, PaginationService, ResizerService, SharedService, SlickgridConfig, SortService, TreeDataService,
|
|
13
|
-
// extensions
|
|
14
|
-
AutoTooltipExtension, CheckboxSelectorExtension, CellExternalCopyManagerExtension, CellMenuExtension, ColumnPickerExtension, ContextMenuExtension, DraggableGroupingExtension, ExtensionUtility, GridMenuExtension, GroupItemMetaProviderExtension, HeaderMenuExtension, HeaderButtonExtension, RowSelectionExtension, RowMoveManagerExtension,
|
|
14
|
+
BackendUtilityService, CollectionService, EventNamingStyle, ExtensionService, ExtensionUtility, FilterFactory, FilterService, GridEventService, GridService, GridStateService, GroupingAndColspanService, PaginationService, ResizerService, SharedService, SlickGroupItemMetadataProvider, SlickgridConfig, SortService, TreeDataService,
|
|
15
15
|
// utilities
|
|
16
16
|
autoAddEditorFormatterToColumnsWithEditor, emptyElement, } from '@slickgrid-universal/common';
|
|
17
17
|
import { EventPubSubService } from '@slickgrid-universal/event-pub-sub';
|
|
@@ -22,16 +22,110 @@ import { dequal } from 'dequal/lite';
|
|
|
22
22
|
import { Constants } from '../constants';
|
|
23
23
|
import { GlobalGridOptions } from '../global-grid-options';
|
|
24
24
|
import { ReactUtilService, disposeAllSubscriptions, TranslaterService, } from '../services/index';
|
|
25
|
-
import {
|
|
26
|
-
|
|
25
|
+
import { GlobalContainerService } from '../services/singletons';
|
|
26
|
+
// add Sortable to the window object so that SlickGrid lib can use globally
|
|
27
|
+
window.Sortable = Sortable;
|
|
27
28
|
class CustomEventPubSubService extends EventPubSubService {
|
|
28
29
|
set elementSource(value) {
|
|
29
30
|
this._elementSource = value;
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
|
-
export class
|
|
33
|
+
export class ReactSlickgrid extends React.Component {
|
|
34
|
+
setStateValue(key, value, callback) {
|
|
35
|
+
if (this.state && this.state[key] === value) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (!this._mounted) {
|
|
39
|
+
this.state = this.state || {};
|
|
40
|
+
this.state[key] = value;
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
this.setState(() => {
|
|
44
|
+
const result = {};
|
|
45
|
+
result[key] = value;
|
|
46
|
+
return result;
|
|
47
|
+
}, callback);
|
|
48
|
+
}
|
|
49
|
+
get gridOptions() {
|
|
50
|
+
return this._gridOptions || {};
|
|
51
|
+
}
|
|
52
|
+
set gridOptions(options) {
|
|
53
|
+
var _a, _b, _c;
|
|
54
|
+
let mergedOptions;
|
|
55
|
+
// if we already have grid options, when grid was already initialized, we'll merge with those options
|
|
56
|
+
// else we'll merge with global grid options
|
|
57
|
+
if ((_a = this.grid) === null || _a === void 0 ? void 0 : _a.getOptions) {
|
|
58
|
+
mergedOptions = $.extend(true, {}, this.grid.getOptions(), options);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
mergedOptions = this.mergeGridOptions(options);
|
|
62
|
+
}
|
|
63
|
+
if (((_b = this.sharedService) === null || _b === void 0 ? void 0 : _b.gridOptions) && ((_c = this.grid) === null || _c === void 0 ? void 0 : _c.setOptions)) {
|
|
64
|
+
this.sharedService.gridOptions = mergedOptions;
|
|
65
|
+
this.grid.setOptions(mergedOptions, false, true); // make sure to supressColumnCheck (3rd arg) to avoid problem with changeColumnsArrangement() and custom grid view
|
|
66
|
+
this.grid.reRenderColumns(true); // then call a re-render since we did supressColumnCheck on previous setOptions
|
|
67
|
+
}
|
|
68
|
+
this._gridOptions = mergedOptions;
|
|
69
|
+
}
|
|
70
|
+
get paginationService() {
|
|
71
|
+
var _a;
|
|
72
|
+
return (_a = this.state) === null || _a === void 0 ? void 0 : _a.paginationService;
|
|
73
|
+
}
|
|
74
|
+
set paginationService(value) {
|
|
75
|
+
this.setStateValue('paginationService', value);
|
|
76
|
+
}
|
|
77
|
+
get dataset() {
|
|
78
|
+
var _a;
|
|
79
|
+
return ((_a = this.dataView) === null || _a === void 0 ? void 0 : _a.getItems()) || [];
|
|
80
|
+
}
|
|
81
|
+
set dataset(newDataset) {
|
|
82
|
+
var _a, _b;
|
|
83
|
+
const prevDatasetLn = this._currentDatasetLength;
|
|
84
|
+
const isDatasetEqual = dequal(newDataset, this.dataset || []);
|
|
85
|
+
const isDeepCopyDataOnPageLoadEnabled = !!((_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.enableDeepCopyDatasetOnPageLoad);
|
|
86
|
+
let data = isDeepCopyDataOnPageLoadEnabled ? $.extend(true, [], newDataset) : newDataset;
|
|
87
|
+
// when Tree Data is enabled and we don't yet have the hierarchical dataset filled, we can force a convert+sort of the array
|
|
88
|
+
if (this.grid && ((_b = this.gridOptions) === null || _b === void 0 ? void 0 : _b.enableTreeData) && Array.isArray(newDataset) && (newDataset.length > 0 || newDataset.length !== prevDatasetLn || !isDatasetEqual)) {
|
|
89
|
+
this._isDatasetHierarchicalInitialized = false;
|
|
90
|
+
data = this.sortTreeDataset(newDataset, !isDatasetEqual); // if dataset changed, then force a refresh anyway
|
|
91
|
+
}
|
|
92
|
+
this.refreshGridData(data || []);
|
|
93
|
+
this._currentDatasetLength = (newDataset || []).length;
|
|
94
|
+
// expand/autofit columns on first page load
|
|
95
|
+
// we can assume that if the prevDataset was empty then we are on first load
|
|
96
|
+
if (this.grid && this.gridOptions.autoFitColumnsOnFirstLoad && prevDatasetLn === 0) {
|
|
97
|
+
this.grid.autosizeColumns();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
get datasetHierarchical() {
|
|
101
|
+
return this.sharedService.hierarchicalDataset;
|
|
102
|
+
}
|
|
103
|
+
set datasetHierarchical(newHierarchicalDataset) {
|
|
104
|
+
var _a, _b, _c, _d, _f, _g;
|
|
105
|
+
const isDatasetEqual = dequal(newHierarchicalDataset, (_b = (_a = this.sharedService) === null || _a === void 0 ? void 0 : _a.hierarchicalDataset) !== null && _b !== void 0 ? _b : []);
|
|
106
|
+
const prevFlatDatasetLn = this._currentDatasetLength;
|
|
107
|
+
this.sharedService.hierarchicalDataset = newHierarchicalDataset;
|
|
108
|
+
if (newHierarchicalDataset && this.props.columnDefinitions && ((_c = this.filterService) === null || _c === void 0 ? void 0 : _c.clearFilters)) {
|
|
109
|
+
this.filterService.clearFilters();
|
|
110
|
+
}
|
|
111
|
+
// 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
|
|
112
|
+
if (this.dataView && newHierarchicalDataset && this.grid && ((_d = this.sortService) === null || _d === void 0 ? void 0 : _d.processTreeDataInitialSort)) {
|
|
113
|
+
this.dataView.setItems([], (_g = (_f = this._gridOptions) === null || _f === void 0 ? void 0 : _f.datasetIdPropertyName) !== null && _g !== void 0 ? _g : 'id');
|
|
114
|
+
this.sortService.processTreeDataInitialSort();
|
|
115
|
+
// 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
|
|
116
|
+
// however we need 1 cpu cycle before having the DataView refreshed, so we need to wrap this check in a setTimeout
|
|
117
|
+
setTimeout(() => {
|
|
118
|
+
var _a, _b;
|
|
119
|
+
const flatDatasetLn = (_b = (_a = this.dataView) === null || _a === void 0 ? void 0 : _a.getItemCount()) !== null && _b !== void 0 ? _b : 0;
|
|
120
|
+
if (flatDatasetLn > 0 && (flatDatasetLn !== prevFlatDatasetLn || !isDatasetEqual)) {
|
|
121
|
+
this.filterService.refreshTreeDataFilters();
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
this._isDatasetHierarchicalInitialized = true;
|
|
126
|
+
}
|
|
33
127
|
constructor(props) {
|
|
34
|
-
var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6;
|
|
128
|
+
var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7;
|
|
35
129
|
super(props);
|
|
36
130
|
this.props = props;
|
|
37
131
|
this._mounted = false;
|
|
@@ -45,46 +139,36 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
45
139
|
this._isPaginationInitialized = false;
|
|
46
140
|
this._isLocalGrid = true;
|
|
47
141
|
this._registeredResources = [];
|
|
142
|
+
this.showPagination = false;
|
|
48
143
|
this.serviceList = [];
|
|
49
144
|
this.subscriptions = [];
|
|
50
145
|
this.totalItems = 0;
|
|
51
146
|
this.instances = null;
|
|
52
|
-
this.elm = React.createRef();
|
|
53
147
|
const slickgridConfig = new SlickgridConfig();
|
|
148
|
+
this._eventHandler = new Slick.EventHandler();
|
|
54
149
|
this.showPagination = false;
|
|
150
|
+
// check if the user wants to hide the header row from the start
|
|
151
|
+
// we only want to do this check once in the constructor
|
|
152
|
+
this._hideHeaderRowAfterPageLoad = (((_a = props.gridOptions) === null || _a === void 0 ? void 0 : _a.showHeaderRow) === false);
|
|
153
|
+
this._gridOptions = this.mergeGridOptions(props.gridOptions || {});
|
|
55
154
|
// initialize and assign all Service Dependencies
|
|
56
|
-
this._eventPubSubService = (
|
|
155
|
+
this._eventPubSubService = (_c = (_b = this.props.externalServices) === null || _b === void 0 ? void 0 : _b.eventPubSubService) !== null && _c !== void 0 ? _c : new CustomEventPubSubService();
|
|
57
156
|
this._eventPubSubService.eventNamingStyle = EventNamingStyle.camelCase;
|
|
58
|
-
this.backendUtilityService = (
|
|
59
|
-
this.gridEventService = (
|
|
60
|
-
this.sharedService = (
|
|
61
|
-
this.collectionService = (
|
|
62
|
-
this.extensionUtility = (
|
|
157
|
+
this.backendUtilityService = (_f = (_d = this.props.externalServices) === null || _d === void 0 ? void 0 : _d.backendUtilityService) !== null && _f !== void 0 ? _f : new BackendUtilityService();
|
|
158
|
+
this.gridEventService = (_h = (_g = this.props.externalServices) === null || _g === void 0 ? void 0 : _g.gridEventService) !== null && _h !== void 0 ? _h : new GridEventService();
|
|
159
|
+
this.sharedService = (_k = (_j = this.props.externalServices) === null || _j === void 0 ? void 0 : _j.sharedService) !== null && _k !== void 0 ? _k : new SharedService();
|
|
160
|
+
this.collectionService = (_m = (_l = this.props.externalServices) === null || _l === void 0 ? void 0 : _l.collectionService) !== null && _m !== void 0 ? _m : new CollectionService(this.props.translaterService);
|
|
161
|
+
this.extensionUtility = (_p = (_o = this.props.externalServices) === null || _o === void 0 ? void 0 : _o.extensionUtility) !== null && _p !== void 0 ? _p : new ExtensionUtility(this.sharedService, this.backendUtilityService, this.props.translaterService);
|
|
63
162
|
this.filterFactory = new FilterFactory(slickgridConfig, this.props.translaterService, this.collectionService);
|
|
64
|
-
this.filterService = (
|
|
65
|
-
this.resizerService = (
|
|
66
|
-
this.sortService = (
|
|
67
|
-
this.treeDataService = (
|
|
68
|
-
this.paginationService = (
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const contextMenuExtension = new ContextMenuExtension(this.extensionUtility, this._eventPubSubService, this.sharedService, this.treeDataService, this.props.translaterService);
|
|
74
|
-
const columnPickerExtension = new ColumnPickerExtension(this.extensionUtility, this.sharedService);
|
|
75
|
-
const checkboxExtension = new CheckboxSelectorExtension(this.sharedService);
|
|
76
|
-
const draggableGroupingExtension = new DraggableGroupingExtension(this.extensionUtility, this._eventPubSubService, this.sharedService);
|
|
77
|
-
const gridMenuExtension = new GridMenuExtension(this.extensionUtility, this.filterService, this._eventPubSubService, this.sharedService, this.sortService, this.backendUtilityService, this.props.translaterService);
|
|
78
|
-
const groupItemMetaProviderExtension = new GroupItemMetaProviderExtension(this.sharedService);
|
|
79
|
-
const headerButtonExtension = new HeaderButtonExtension(this.extensionUtility, this.sharedService);
|
|
80
|
-
const headerMenuExtension = new HeaderMenuExtension(this.extensionUtility, this.filterService, this._eventPubSubService, this.sharedService, this.sortService, this.props.translaterService);
|
|
81
|
-
const rowDetailViewExtension = new RowDetailViewExtension(this._eventPubSubService, this.props.reactUtilService, this.sharedService);
|
|
82
|
-
const rowMoveManagerExtension = new RowMoveManagerExtension(this.sharedService);
|
|
83
|
-
const rowSelectionExtension = new RowSelectionExtension(this.sharedService);
|
|
84
|
-
this.extensionService = (_0 = (_z = this.props.externalServices) === null || _z === void 0 ? void 0 : _z.extensionService) !== null && _0 !== void 0 ? _0 : new ExtensionService(autoTooltipExtension, cellExternalCopyManagerExtension, cellMenuExtension, checkboxExtension, columnPickerExtension, contextMenuExtension, draggableGroupingExtension, gridMenuExtension, groupItemMetaProviderExtension, headerButtonExtension, headerMenuExtension, rowDetailViewExtension, rowMoveManagerExtension, rowSelectionExtension, this.sharedService, this.props.translaterService);
|
|
85
|
-
this.gridStateService = (_2 = (_1 = this.props.externalServices) === null || _1 === void 0 ? void 0 : _1.gridStateService) !== null && _2 !== void 0 ? _2 : new GridStateService(this.extensionService, this.filterService, this._eventPubSubService, this.sharedService, this.sortService, this.treeDataService);
|
|
86
|
-
this.gridService = (_4 = (_3 = this.props.externalServices) === null || _3 === void 0 ? void 0 : _3.gridService) !== null && _4 !== void 0 ? _4 : new GridService(this.gridStateService, this.filterService, this._eventPubSubService, this.paginationService, this.sharedService, this.sortService, this.treeDataService);
|
|
87
|
-
this.groupingService = (_6 = (_5 = this.props.externalServices) === null || _5 === void 0 ? void 0 : _5.groupingAndColspanService) !== null && _6 !== void 0 ? _6 : new GroupingAndColspanService(this.extensionUtility, this.extensionService, this._eventPubSubService);
|
|
163
|
+
this.filterService = (_r = (_q = this.props.externalServices) === null || _q === void 0 ? void 0 : _q.filterService) !== null && _r !== void 0 ? _r : new FilterService(this.filterFactory, this._eventPubSubService, this.sharedService, this.backendUtilityService);
|
|
164
|
+
this.resizerService = (_t = (_s = this.props.externalServices) === null || _s === void 0 ? void 0 : _s.resizerService) !== null && _t !== void 0 ? _t : new ResizerService(this._eventPubSubService);
|
|
165
|
+
this.sortService = (_v = (_u = this.props.externalServices) === null || _u === void 0 ? void 0 : _u.sortService) !== null && _v !== void 0 ? _v : new SortService(this.sharedService, this._eventPubSubService, this.backendUtilityService);
|
|
166
|
+
this.treeDataService = (_x = (_w = this.props.externalServices) === null || _w === void 0 ? void 0 : _w.treeDataService) !== null && _x !== void 0 ? _x : new TreeDataService(this._eventPubSubService, this.sharedService, this.sortService);
|
|
167
|
+
this.paginationService = (_z = (_y = this.props.externalServices) === null || _y === void 0 ? void 0 : _y.paginationService) !== null && _z !== void 0 ? _z : new PaginationService(this._eventPubSubService, this.sharedService, this.backendUtilityService);
|
|
168
|
+
this.extensionService = (_1 = (_0 = this.props.externalServices) === null || _0 === void 0 ? void 0 : _0.extensionService) !== null && _1 !== void 0 ? _1 : new ExtensionService(this.extensionUtility, this.filterService, this._eventPubSubService, this.sharedService, this.sortService, this.treeDataService, this.props.translaterService);
|
|
169
|
+
this.gridStateService = (_3 = (_2 = this.props.externalServices) === null || _2 === void 0 ? void 0 : _2.gridStateService) !== null && _3 !== void 0 ? _3 : new GridStateService(this.extensionService, this.filterService, this._eventPubSubService, this.sharedService, this.sortService, this.treeDataService);
|
|
170
|
+
this.gridService = (_5 = (_4 = this.props.externalServices) === null || _4 === void 0 ? void 0 : _4.gridService) !== null && _5 !== void 0 ? _5 : new GridService(this.gridStateService, this.filterService, this._eventPubSubService, this.paginationService, this.sharedService, this.sortService, this.treeDataService);
|
|
171
|
+
this.groupingService = (_7 = (_6 = this.props.externalServices) === null || _6 === void 0 ? void 0 : _6.groupingAndColspanService) !== null && _7 !== void 0 ? _7 : new GroupingAndColspanService(this.extensionUtility, this._eventPubSubService);
|
|
88
172
|
this.serviceList = [
|
|
89
173
|
this.extensionService,
|
|
90
174
|
this.filterService,
|
|
@@ -97,7 +181,12 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
97
181
|
this.sortService,
|
|
98
182
|
this.treeDataService,
|
|
99
183
|
];
|
|
184
|
+
if (this.props.datasetHierarchical) {
|
|
185
|
+
this.sharedService.hierarchicalDataset = this.props.datasetHierarchical || [];
|
|
186
|
+
}
|
|
100
187
|
// register all Service instances in the container
|
|
188
|
+
this.props.containerService.registerInstance('PubSubService', this._eventPubSubService);
|
|
189
|
+
this.props.containerService.registerInstance('EventPubSubService', this._eventPubSubService);
|
|
101
190
|
this.props.containerService.registerInstance('ExtensionUtility', this.extensionUtility);
|
|
102
191
|
this.props.containerService.registerInstance('FilterService', this.filterService);
|
|
103
192
|
this.props.containerService.registerInstance('CollectionService', this.collectionService);
|
|
@@ -110,47 +199,8 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
110
199
|
this.props.containerService.registerInstance('ResizerService', this.resizerService);
|
|
111
200
|
this.props.containerService.registerInstance('SharedService', this.sharedService);
|
|
112
201
|
this.props.containerService.registerInstance('SortService', this.sortService);
|
|
113
|
-
this.props.containerService.registerInstance('EventPubSubService', this._eventPubSubService);
|
|
114
|
-
this.props.containerService.registerInstance('PubSubService', this._eventPubSubService);
|
|
115
202
|
this.props.containerService.registerInstance('TranslaterService', this.props.translaterService);
|
|
116
203
|
this.props.containerService.registerInstance('TreeDataService', this.treeDataService);
|
|
117
|
-
this._gridOptions = this.mergeGridOptions(this.props.gridOptions);
|
|
118
|
-
}
|
|
119
|
-
setStateValue(key, value) {
|
|
120
|
-
if (this.state && this.state[key] === value) {
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
if (!this._mounted) {
|
|
124
|
-
this.state = this.state || {};
|
|
125
|
-
this.state[key] = value;
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
this.setState(() => {
|
|
129
|
-
const result = {};
|
|
130
|
-
result[key] = value;
|
|
131
|
-
return result;
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
get _gridOptions() {
|
|
135
|
-
var _a;
|
|
136
|
-
return (_a = this.state) === null || _a === void 0 ? void 0 : _a._gridOptions;
|
|
137
|
-
}
|
|
138
|
-
set _gridOptions(value) {
|
|
139
|
-
this.setStateValue('_gridOptions', value);
|
|
140
|
-
}
|
|
141
|
-
get showPagination() {
|
|
142
|
-
var _a;
|
|
143
|
-
return (_a = this.state) === null || _a === void 0 ? void 0 : _a.showPagination;
|
|
144
|
-
}
|
|
145
|
-
set showPagination(value) {
|
|
146
|
-
this.setStateValue('showPagination', value);
|
|
147
|
-
}
|
|
148
|
-
get paginationService() {
|
|
149
|
-
var _a;
|
|
150
|
-
return (_a = this.state) === null || _a === void 0 ? void 0 : _a.paginationService;
|
|
151
|
-
}
|
|
152
|
-
set paginationService(value) {
|
|
153
|
-
this.setStateValue('paginationService', value);
|
|
154
204
|
}
|
|
155
205
|
get eventHandler() {
|
|
156
206
|
return this._eventHandler;
|
|
@@ -161,20 +211,39 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
161
211
|
set isDatasetInitialized(isInitialized) {
|
|
162
212
|
this._isDatasetInitialized = isInitialized;
|
|
163
213
|
}
|
|
214
|
+
set isDatasetHierarchicalInitialized(isInitialized) {
|
|
215
|
+
this._isDatasetHierarchicalInitialized = isInitialized;
|
|
216
|
+
}
|
|
164
217
|
get registeredResources() {
|
|
165
218
|
return this._registeredResources;
|
|
166
219
|
}
|
|
167
220
|
componentDidMount() {
|
|
168
|
-
var _a;
|
|
221
|
+
var _a, _b;
|
|
169
222
|
this._mounted = true;
|
|
170
|
-
if (this.
|
|
171
|
-
this._eventPubSubService.elementSource = this.
|
|
223
|
+
if (this._elm && this._eventPubSubService instanceof CustomEventPubSubService) {
|
|
224
|
+
this._eventPubSubService.elementSource = this._elm;
|
|
225
|
+
// React doesn't play well with Custom Events & also the render is called after the constructor which brings a second problem
|
|
226
|
+
// to fix both issues, we need to do the following:
|
|
227
|
+
// loop through all component and subscribe to all props that startsWith "on", assuming they are custom event
|
|
228
|
+
// and call their listener with event is dispatching
|
|
229
|
+
for (const prop in this.props) {
|
|
230
|
+
if (prop.startsWith('on')) {
|
|
231
|
+
this.subscriptions.push(this._eventPubSubService.subscribe(prop, (data) => {
|
|
232
|
+
const callback = this.props[prop];
|
|
233
|
+
const gridEventName = this._eventPubSubService.getEventNameByNamingConvention(prop, '');
|
|
234
|
+
typeof callback === 'function' && callback.call(null, new CustomEvent(gridEventName, { detail: data }));
|
|
235
|
+
}));
|
|
236
|
+
}
|
|
237
|
+
}
|
|
172
238
|
}
|
|
173
|
-
this._eventHandler = new Slick.EventHandler();
|
|
174
239
|
this.initialization(this._eventHandler);
|
|
175
240
|
this._isGridInitialized = true;
|
|
241
|
+
if (!this._isPaginationInitialized && !this.props.datasetHierarchical && ((_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.enablePagination) && this._isLocalGrid) {
|
|
242
|
+
this.showPagination = true;
|
|
243
|
+
this.loadLocalGridPagination(this.dataset);
|
|
244
|
+
}
|
|
176
245
|
// recheck the empty warning message after grid is shown so that it works in every use case
|
|
177
|
-
if ((
|
|
246
|
+
if ((_b = this._gridOptions) === null || _b === void 0 ? void 0 : _b.enableEmptyDataWarningMessage) {
|
|
178
247
|
const dataset = this.props.dataset || [];
|
|
179
248
|
if (Array.isArray(dataset)) {
|
|
180
249
|
const finalTotalCount = dataset.length;
|
|
@@ -184,6 +253,9 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
184
253
|
}
|
|
185
254
|
initialization(eventHandler) {
|
|
186
255
|
var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
256
|
+
if (!this._gridOptions || !this._columnDefinitions) {
|
|
257
|
+
throw new Error('Using `<ReactSlickgrid>` requires columnDefinitions and gridOptions, it seems that you might have forgot to provide them since at least of them is undefined.');
|
|
258
|
+
}
|
|
187
259
|
this._gridOptions.translater = this.props.translaterService;
|
|
188
260
|
this._eventHandler = eventHandler;
|
|
189
261
|
// when detecting a frozen grid, we'll automatically enable the mousewheel scroll handler so that we can scroll from both left/right frozen containers
|
|
@@ -195,6 +267,7 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
195
267
|
// make sure the dataset is initialized (if not it will throw an error that it cannot getLength of null)
|
|
196
268
|
this._dataset = this._dataset || this.props.dataset || [];
|
|
197
269
|
this._currentDatasetLength = this._dataset.length;
|
|
270
|
+
this._gridOptions = this.mergeGridOptions(this._gridOptions);
|
|
198
271
|
this._paginationOptions = (_c = this._gridOptions) === null || _c === void 0 ? void 0 : _c.pagination;
|
|
199
272
|
this.locales = (_f = (_d = this._gridOptions) === null || _d === void 0 ? void 0 : _d.locales) !== null && _f !== void 0 ? _f : Constants.locales;
|
|
200
273
|
this.backendServiceApi = (_g = this._gridOptions) === null || _g === void 0 ? void 0 : _g.backendServiceApi;
|
|
@@ -204,12 +277,12 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
204
277
|
const dataviewInlineFilters = this._gridOptions.dataView && this._gridOptions.dataView.inlineFilters || false;
|
|
205
278
|
let dataViewOptions = { inlineFilters: dataviewInlineFilters };
|
|
206
279
|
if (this._gridOptions.draggableGrouping || this._gridOptions.enableGrouping) {
|
|
207
|
-
this.groupItemMetadataProvider = new
|
|
280
|
+
this.groupItemMetadataProvider = new SlickGroupItemMetadataProvider();
|
|
208
281
|
this.sharedService.groupItemMetadataProvider = this.groupItemMetadataProvider;
|
|
209
282
|
dataViewOptions = { ...dataViewOptions, groupItemMetadataProvider: this.groupItemMetadataProvider };
|
|
210
283
|
}
|
|
211
|
-
this.
|
|
212
|
-
this._eventPubSubService.publish(`onDataviewCreated`, this.
|
|
284
|
+
this.dataView = new Slick.Data.DataView(dataViewOptions);
|
|
285
|
+
this._eventPubSubService.publish(`onDataviewCreated`, this.dataView);
|
|
213
286
|
}
|
|
214
287
|
// get any possible Services that user want to register which don't require SlickGrid to be instantiated
|
|
215
288
|
// RxJS Resource is in this lot because it has to be registered before anything else and doesn't require SlickGrid to be initialized
|
|
@@ -226,17 +299,20 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
226
299
|
// save reference for all columns before they optionally become hidden/visible
|
|
227
300
|
this.sharedService.allColumns = this._columnDefinitions;
|
|
228
301
|
this.sharedService.visibleColumns = this._columnDefinitions;
|
|
302
|
+
// after subscribing to potential columns changed, we are ready to create these optional extensions
|
|
303
|
+
// when we did find some to create (RowMove, RowDetail, RowSelections), it will automatically modify column definitions (by previous subscribe)
|
|
229
304
|
this.extensionService.createExtensionsBeforeGridCreation(this._columnDefinitions, this._gridOptions);
|
|
230
305
|
// if user entered some Pinning/Frozen "presets", we need to apply them in the grid options
|
|
231
|
-
if ((_h = this.
|
|
232
|
-
this.
|
|
306
|
+
if ((_h = this.gridOptions.presets) === null || _h === void 0 ? void 0 : _h.pinning) {
|
|
307
|
+
this.gridOptions = { ...this.gridOptions, ...this.gridOptions.presets.pinning };
|
|
233
308
|
}
|
|
234
309
|
// build SlickGrid Grid, also user might optionally pass a custom dataview (e.g. remote model)
|
|
235
|
-
this.grid = new Slick.Grid(`#${this.props.gridId}`, this.props.customDataView || this.
|
|
236
|
-
this.sharedService.dataView = this.
|
|
310
|
+
this.grid = new Slick.Grid(`#${this.props.gridId}`, this.props.customDataView || this.dataView, this._columnDefinitions, this._gridOptions);
|
|
311
|
+
this.sharedService.dataView = this.dataView;
|
|
237
312
|
this.sharedService.slickGrid = this.grid;
|
|
313
|
+
this.sharedService.gridContainerElement = this._elm;
|
|
238
314
|
this.extensionService.bindDifferentExtensions();
|
|
239
|
-
this.bindDifferentHooks(this.grid, this._gridOptions, this.
|
|
315
|
+
this.bindDifferentHooks(this.grid, this._gridOptions, this.dataView);
|
|
240
316
|
// 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
|
|
241
317
|
const frozenColumnIndex = (_k = (_j = this._gridOptions) === null || _j === void 0 ? void 0 : _j.frozenColumn) !== null && _k !== void 0 ? _k : -1;
|
|
242
318
|
if (frozenColumnIndex >= 0 && frozenColumnIndex <= this._columnDefinitions.length && this._columnDefinitions.length > 0) {
|
|
@@ -248,7 +324,7 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
248
324
|
this.grid.init();
|
|
249
325
|
// initialized the resizer service only after SlickGrid is initialized
|
|
250
326
|
// 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)
|
|
251
|
-
const gridContainerElm =
|
|
327
|
+
const gridContainerElm = this._elm;
|
|
252
328
|
if (gridContainerElm) {
|
|
253
329
|
this.resizerService.init(this.grid, gridContainerElm);
|
|
254
330
|
}
|
|
@@ -257,15 +333,14 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
257
333
|
this.slickFooter = new SlickFooterComponent(this.grid, this._gridOptions.customFooterOptions, this._eventPubSubService, this.props.translaterService);
|
|
258
334
|
this.slickFooter.renderFooter(gridContainerElm);
|
|
259
335
|
}
|
|
260
|
-
if (!this.props.customDataView && this.
|
|
261
|
-
const initialDataset = ((
|
|
336
|
+
if (!this.props.customDataView && this.dataView) {
|
|
337
|
+
const initialDataset = ((_o = this._gridOptions) === null || _o === void 0 ? void 0 : _o.enableTreeData) ? this.sortTreeDataset(this.props.dataset) : this.props.dataset;
|
|
262
338
|
if (Array.isArray(initialDataset)) {
|
|
263
|
-
this.
|
|
339
|
+
this.dataView.setItems(initialDataset, (_p = this._gridOptions.datasetIdPropertyName) !== null && _p !== void 0 ? _p : 'id');
|
|
264
340
|
}
|
|
265
341
|
// if you don't want the items that are not visible (due to being filtered out or being on a different page)
|
|
266
342
|
// to stay selected, pass 'false' to the second arg
|
|
267
|
-
|
|
268
|
-
if (selectionModel && ((_s = this._gridOptions) === null || _s === void 0 ? void 0 : _s.dataView) && this._gridOptions.dataView.hasOwnProperty('syncGridSelection')) {
|
|
343
|
+
if (((_q = this.grid) === null || _q === void 0 ? void 0 : _q.getSelectionModel()) && ((_r = this._gridOptions) === null || _r === void 0 ? void 0 : _r.dataView) && this._gridOptions.dataView.hasOwnProperty('syncGridSelection')) {
|
|
269
344
|
// if we are using a Backend Service, we will do an extra flag check, the reason is because it might have some unintended behaviors
|
|
270
345
|
// with the BackendServiceApi because technically the data in the page changes the DataView on every page change.
|
|
271
346
|
let preservedRowSelectionWithBackend = false;
|
|
@@ -279,10 +354,10 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
279
354
|
// when using BackendServiceApi, we'll be using the "syncGridSelectionWithBackendService" flag BUT "syncGridSelection" must also be set to True
|
|
280
355
|
preservedRowSelection = syncGridSelection && preservedRowSelectionWithBackend;
|
|
281
356
|
}
|
|
282
|
-
this.
|
|
357
|
+
this.dataView.syncGridSelection(this.grid, preservedRowSelection);
|
|
283
358
|
}
|
|
284
359
|
else if (typeof syncGridSelection === 'object') {
|
|
285
|
-
this.
|
|
360
|
+
this.dataView.syncGridSelection(this.grid, syncGridSelection.preserveHidden, syncGridSelection.preserveHiddenOnSelectionChange);
|
|
286
361
|
}
|
|
287
362
|
}
|
|
288
363
|
if (this._dataset.length > 0) {
|
|
@@ -309,20 +384,20 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
309
384
|
this.bindResizeHook(this.grid, this._gridOptions);
|
|
310
385
|
// bind the Backend Service API callback functions only after the grid is initialized
|
|
311
386
|
// because the preProcess() and onInit() might get triggered
|
|
312
|
-
if ((
|
|
387
|
+
if ((_s = this._gridOptions) === null || _s === void 0 ? void 0 : _s.backendServiceApi) {
|
|
313
388
|
this.bindBackendCallbackFunctions(this._gridOptions);
|
|
314
389
|
}
|
|
315
390
|
// create the React Grid Instance with reference to all Services
|
|
316
391
|
const reactElementInstance = {
|
|
317
|
-
element: this.
|
|
318
|
-
eventPubSubService: this._eventPubSubService,
|
|
392
|
+
element: this._elm,
|
|
319
393
|
// Slick Grid & DataView objects
|
|
320
|
-
dataView: this.
|
|
394
|
+
dataView: this.dataView,
|
|
321
395
|
slickGrid: this.grid,
|
|
322
396
|
// public methods
|
|
323
397
|
dispose: this.dispose.bind(this),
|
|
324
398
|
// return all available Services (non-singleton)
|
|
325
|
-
backendService: (
|
|
399
|
+
backendService: (_u = (_t = this._gridOptions) === null || _t === void 0 ? void 0 : _t.backendServiceApi) === null || _u === void 0 ? void 0 : _u.service,
|
|
400
|
+
eventPubSubService: this._eventPubSubService,
|
|
326
401
|
filterService: this.filterService,
|
|
327
402
|
gridEventService: this.gridEventService,
|
|
328
403
|
gridStateService: this.gridStateService,
|
|
@@ -335,15 +410,17 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
335
410
|
treeDataService: this.treeDataService,
|
|
336
411
|
};
|
|
337
412
|
// addons (SlickGrid extra plugins/controls)
|
|
338
|
-
this.extensions = this.extensionService
|
|
413
|
+
this.extensions = (_v = this.extensionService) === null || _v === void 0 ? void 0 : _v.extensionList;
|
|
339
414
|
// all instances (SlickGrid, DataView & all Services)
|
|
340
415
|
this.instances = reactElementInstance;
|
|
416
|
+
this.setStateValue('instances', reactElementInstance);
|
|
341
417
|
this._eventPubSubService.publish(`onReactGridCreated`, reactElementInstance);
|
|
342
418
|
}
|
|
343
419
|
componentWillUnmount(shouldEmptyDomElementContainer = false) {
|
|
344
420
|
var _a, _b, _c, _d, _f;
|
|
345
421
|
this._eventPubSubService.publish(`onBeforeGridDestroy`, this.grid);
|
|
346
422
|
(_a = this._eventHandler) === null || _a === void 0 ? void 0 : _a.unsubscribeAll();
|
|
423
|
+
i18next.off('languageChanged');
|
|
347
424
|
// we could optionally also empty the content of the grid container DOM element
|
|
348
425
|
if (shouldEmptyDomElementContainer) {
|
|
349
426
|
this.emptyGridContainerElm();
|
|
@@ -351,7 +428,7 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
351
428
|
this._eventPubSubService.publish(`onAfterGridDestroyed`, true);
|
|
352
429
|
// dispose of all Services
|
|
353
430
|
this.serviceList.forEach((service) => {
|
|
354
|
-
if (service
|
|
431
|
+
if (service === null || service === void 0 ? void 0 : service.dispose) {
|
|
355
432
|
service.dispose();
|
|
356
433
|
}
|
|
357
434
|
});
|
|
@@ -370,12 +447,12 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
370
447
|
(_b = this.slickEmptyWarning) === null || _b === void 0 ? void 0 : _b.dispose();
|
|
371
448
|
(_c = this.slickFooter) === null || _c === void 0 ? void 0 : _c.dispose();
|
|
372
449
|
(_d = this.slickPagination) === null || _d === void 0 ? void 0 : _d.dispose();
|
|
373
|
-
if (this.
|
|
374
|
-
if (this.
|
|
375
|
-
this.
|
|
450
|
+
if (this.dataView) {
|
|
451
|
+
if (this.dataView.setItems) {
|
|
452
|
+
this.dataView.setItems([]);
|
|
376
453
|
}
|
|
377
|
-
if (this.
|
|
378
|
-
this.
|
|
454
|
+
if (this.dataView.destroy) {
|
|
455
|
+
this.dataView.destroy();
|
|
379
456
|
}
|
|
380
457
|
}
|
|
381
458
|
if ((_f = this.grid) === null || _f === void 0 ? void 0 : _f.destroy) {
|
|
@@ -389,16 +466,13 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
389
466
|
}
|
|
390
467
|
this.backendServiceApi = undefined;
|
|
391
468
|
}
|
|
392
|
-
/*
|
|
393
469
|
for (const prop of Object.keys(this.props.columnDefinitions)) {
|
|
394
|
-
|
|
470
|
+
this.props.columnDefinitions[prop] = null;
|
|
395
471
|
}
|
|
396
|
-
*/
|
|
397
472
|
for (const prop of Object.keys(this.sharedService)) {
|
|
398
473
|
this.sharedService[prop] = null;
|
|
399
474
|
}
|
|
400
475
|
this._dataset = null;
|
|
401
|
-
// this.props.datasetHierarchical = null;
|
|
402
476
|
this._columnDefinitions = [];
|
|
403
477
|
}
|
|
404
478
|
emptyGridContainerElm() {
|
|
@@ -420,10 +494,10 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
420
494
|
this.columnDefinitionsChanged();
|
|
421
495
|
}
|
|
422
496
|
if (this.props.dataset !== prevProps.dataset) {
|
|
423
|
-
this.
|
|
497
|
+
this.dataset = this.props.dataset || prevProps.dataset;
|
|
424
498
|
}
|
|
425
499
|
if (this.props.datasetHierarchical && this.props.datasetHierarchical !== prevProps.datasetHierarchical) {
|
|
426
|
-
this.
|
|
500
|
+
this.datasetHierarchical = this.props.datasetHierarchical;
|
|
427
501
|
}
|
|
428
502
|
}
|
|
429
503
|
columnDefinitionsChanged() {
|
|
@@ -450,62 +524,20 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
450
524
|
var _a;
|
|
451
525
|
// make sure the target is the active editor so we do not
|
|
452
526
|
// commit prematurely
|
|
453
|
-
if (activeNode
|
|
527
|
+
if ((activeNode === null || activeNode === void 0 ? void 0 : activeNode.contains(target)) && this.grid.getEditorLock().isActive() && !((_a = target === null || target === void 0 ? void 0 : target.classList) === null || _a === void 0 ? void 0 : _a.contains('autocomplete'))) {
|
|
454
528
|
this.grid.getEditorLock().commitCurrentEdit();
|
|
455
529
|
}
|
|
456
530
|
});
|
|
457
531
|
}
|
|
458
532
|
}
|
|
459
|
-
datasetChanged(newDataset, oldValue) {
|
|
460
|
-
var _a;
|
|
461
|
-
const prevDatasetLn = this._currentDatasetLength;
|
|
462
|
-
const isDatasetEqual = dequal(newDataset, this._dataset || []);
|
|
463
|
-
let data = newDataset;
|
|
464
|
-
// when Tree Data is enabled and we don't yet have the hierarchical dataset filled, we can force a convert+sort of the array
|
|
465
|
-
if (this.grid && ((_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.enableTreeData) && Array.isArray(newDataset) && (newDataset.length > 0 || newDataset.length !== prevDatasetLn || !isDatasetEqual)) {
|
|
466
|
-
this._isDatasetHierarchicalInitialized = false;
|
|
467
|
-
data = this.sortTreeDataset(newDataset, !isDatasetEqual); // if dataset changed, then force a refresh anyway
|
|
468
|
-
}
|
|
469
|
-
this._dataset = data;
|
|
470
|
-
this.refreshGridData(data || []);
|
|
471
|
-
this._currentDatasetLength = (newDataset || []).length;
|
|
472
|
-
// expand/autofit columns on first page load
|
|
473
|
-
// we can assume that if the oldValue was empty then we are on first load
|
|
474
|
-
if (this._gridOptions.autoFitColumnsOnFirstLoad && (!oldValue || oldValue.length < 1)) {
|
|
475
|
-
this.grid.autosizeColumns();
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
datasetHierarchicalChanged(newHierarchicalDataset) {
|
|
479
|
-
var _a, _b, _c, _d;
|
|
480
|
-
const isDatasetEqual = dequal(newHierarchicalDataset, (_b = (_a = this.sharedService) === null || _a === void 0 ? void 0 : _a.hierarchicalDataset) !== null && _b !== void 0 ? _b : []);
|
|
481
|
-
const prevFlatDatasetLn = this._currentDatasetLength;
|
|
482
|
-
this.sharedService.hierarchicalDataset = newHierarchicalDataset;
|
|
483
|
-
if (newHierarchicalDataset && this.props.columnDefinitions && ((_c = this.filterService) === null || _c === void 0 ? void 0 : _c.clearFilters)) {
|
|
484
|
-
this.filterService.clearFilters();
|
|
485
|
-
}
|
|
486
|
-
// 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
|
|
487
|
-
if (newHierarchicalDataset && this.grid && ((_d = this.sortService) === null || _d === void 0 ? void 0 : _d.processTreeDataInitialSort)) {
|
|
488
|
-
this.dataview.setItems([], this._gridOptions.datasetIdPropertyName);
|
|
489
|
-
this.sortService.processTreeDataInitialSort();
|
|
490
|
-
// 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
|
|
491
|
-
// however we need 1 cpu cycle before having the DataView refreshed, so we need to wrap this check in a setTimeout
|
|
492
|
-
setTimeout(() => {
|
|
493
|
-
const flatDatasetLn = this.dataview.getItemCount();
|
|
494
|
-
if (flatDatasetLn > 0 && (flatDatasetLn !== prevFlatDatasetLn || !isDatasetEqual)) {
|
|
495
|
-
this.filterService.refreshTreeDataFilters();
|
|
496
|
-
}
|
|
497
|
-
});
|
|
498
|
-
}
|
|
499
|
-
this._isDatasetHierarchicalInitialized = true;
|
|
500
|
-
}
|
|
501
533
|
/**
|
|
502
534
|
* Define our internal Post Process callback, it will execute internally after we get back result from the Process backend call
|
|
503
535
|
* For now, this is GraphQL Service ONLY feature and it will basically
|
|
504
536
|
* refresh the Dataset & Pagination without having the user to create his own PostProcess every time
|
|
505
537
|
*/
|
|
506
538
|
createBackendApiInternalPostProcessCallback(gridOptions) {
|
|
507
|
-
const backendApi = gridOptions
|
|
508
|
-
if (backendApi
|
|
539
|
+
const backendApi = gridOptions === null || gridOptions === void 0 ? void 0 : gridOptions.backendServiceApi;
|
|
540
|
+
if (backendApi === null || backendApi === void 0 ? void 0 : backendApi.service) {
|
|
509
541
|
const backendApiService = backendApi.service;
|
|
510
542
|
// internalPostProcess only works (for now) with a GraphQL Service, so make sure it is of that type
|
|
511
543
|
if (typeof backendApiService.getDatasetName === 'function') {
|
|
@@ -521,56 +553,58 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
521
553
|
}
|
|
522
554
|
}
|
|
523
555
|
bindDifferentHooks(grid, gridOptions, dataView) {
|
|
524
|
-
var _a, _b;
|
|
556
|
+
var _a, _b, _c;
|
|
525
557
|
// translate some of them on first load, then on each language change
|
|
526
558
|
if (gridOptions.enableTranslate) {
|
|
559
|
+
this.extensionService.translateAllExtensions();
|
|
527
560
|
this.translateColumnHeaderTitleKeys();
|
|
528
561
|
this.translateColumnGroupKeys();
|
|
529
562
|
}
|
|
530
563
|
// on locale change, we have to manually translate the Headers, GridMenu
|
|
531
|
-
|
|
564
|
+
i18next.on('languageChanged', () => {
|
|
532
565
|
// publish event of the same name that Slickgrid-Universal uses on a language change event
|
|
533
566
|
this._eventPubSubService.publish('onLanguageChange');
|
|
534
567
|
if (gridOptions.enableTranslate) {
|
|
535
|
-
this.extensionService.
|
|
536
|
-
this.extensionService.translateColumnHeaders();
|
|
537
|
-
this.extensionService.translateColumnPicker();
|
|
538
|
-
this.extensionService.translateContextMenu();
|
|
539
|
-
this.extensionService.translateGridMenu();
|
|
540
|
-
this.extensionService.translateHeaderMenu();
|
|
568
|
+
this.extensionService.translateAllExtensions();
|
|
541
569
|
this.translateColumnHeaderTitleKeys();
|
|
542
570
|
this.translateColumnGroupKeys();
|
|
543
571
|
if (gridOptions.createPreHeaderPanel && !gridOptions.enableDraggableGrouping) {
|
|
544
572
|
this.groupingService.translateGroupingAndColSpan();
|
|
545
573
|
}
|
|
546
574
|
}
|
|
547
|
-
})
|
|
575
|
+
});
|
|
548
576
|
// if user set an onInit Backend, we'll run it right away (and if so, we also need to run preProcess, internalPostProcess & postProcess)
|
|
549
577
|
if (gridOptions.backendServiceApi) {
|
|
550
578
|
const backendApi = gridOptions.backendServiceApi;
|
|
551
|
-
if (backendApi
|
|
579
|
+
if ((_a = backendApi === null || backendApi === void 0 ? void 0 : backendApi.service) === null || _a === void 0 ? void 0 : _a.init) {
|
|
552
580
|
backendApi.service.init(backendApi.options, gridOptions.pagination, this.grid, this.sharedService);
|
|
553
581
|
}
|
|
554
582
|
}
|
|
555
583
|
if (dataView && grid) {
|
|
556
|
-
const slickgridEventPrefix = (
|
|
584
|
+
const slickgridEventPrefix = (_c = (_b = this._gridOptions) === null || _b === void 0 ? void 0 : _b.defaultSlickgridEventPrefix) !== null && _c !== void 0 ? _c : '';
|
|
557
585
|
// expose all Slick Grid Events through dispatch
|
|
558
586
|
for (const prop in grid) {
|
|
559
587
|
if (grid.hasOwnProperty(prop) && prop.startsWith('on')) {
|
|
560
|
-
const gridEventHandler = grid[prop];
|
|
561
588
|
const gridEventName = this._eventPubSubService.getEventNameByNamingConvention(prop, slickgridEventPrefix);
|
|
562
|
-
this._eventHandler.subscribe(
|
|
563
|
-
|
|
589
|
+
this._eventHandler.subscribe(grid[prop], (event, args) => {
|
|
590
|
+
if (this.props.hasOwnProperty(prop)) {
|
|
591
|
+
const callback = this.props[prop];
|
|
592
|
+
return typeof callback === 'function' && callback(new CustomEvent(gridEventName, { detail: { eventData: event, args } }));
|
|
593
|
+
}
|
|
594
|
+
return true;
|
|
564
595
|
});
|
|
565
596
|
}
|
|
566
597
|
}
|
|
567
598
|
// expose all Slick DataView Events through dispatch
|
|
568
599
|
for (const prop in dataView) {
|
|
569
600
|
if (dataView.hasOwnProperty(prop) && prop.startsWith('on')) {
|
|
570
|
-
|
|
571
|
-
this._eventHandler.subscribe(dataViewEventHandler, (event, args) => {
|
|
601
|
+
this._eventHandler.subscribe(dataView[prop], (event, args) => {
|
|
572
602
|
const dataViewEventName = this._eventPubSubService.getEventNameByNamingConvention(prop, slickgridEventPrefix);
|
|
573
|
-
|
|
603
|
+
if (this.props.hasOwnProperty(prop)) {
|
|
604
|
+
const callback = this.props[prop];
|
|
605
|
+
return typeof callback === 'function' && callback(new CustomEvent(dataViewEventName, { detail: { eventData: event, args } }));
|
|
606
|
+
}
|
|
607
|
+
return true;
|
|
574
608
|
});
|
|
575
609
|
}
|
|
576
610
|
}
|
|
@@ -600,37 +634,38 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
600
634
|
this.filterService.bindLocalOnFilter(grid);
|
|
601
635
|
}
|
|
602
636
|
}
|
|
637
|
+
// when column are reordered, we need to update the visibleColumn array
|
|
638
|
+
this._eventHandler.subscribe(grid.onColumnsReordered, (_e, args) => {
|
|
639
|
+
this.sharedService.hasColumnsReordered = true;
|
|
640
|
+
this.sharedService.visibleColumns = args.impactedColumns;
|
|
641
|
+
});
|
|
603
642
|
// load any presets if any (after dataset is initialized)
|
|
604
643
|
this.loadColumnPresetsWhenDatasetInitialized();
|
|
605
644
|
this.loadFilterPresetsWhenDatasetInitialized();
|
|
606
645
|
// When data changes in the DataView, we need to refresh the metrics and/or display a warning if the dataset is empty
|
|
607
|
-
|
|
608
|
-
this._eventHandler.subscribe(onRowCountChangedHandler, () => {
|
|
646
|
+
this._eventHandler.subscribe(dataView.onRowCountChanged, () => {
|
|
609
647
|
grid.invalidate();
|
|
610
|
-
this.handleOnItemCountChanged(dataView.getFilteredItemCount() || 0, dataView.getItemCount());
|
|
648
|
+
this.handleOnItemCountChanged(dataView.getFilteredItemCount() || 0, dataView.getItemCount() || 0);
|
|
611
649
|
});
|
|
612
|
-
|
|
613
|
-
this._eventHandler.subscribe(onSetItemsCalledHandler, (_e, args) => {
|
|
650
|
+
this._eventHandler.subscribe(dataView.onSetItemsCalled, (_e, args) => {
|
|
614
651
|
var _a;
|
|
615
|
-
grid.invalidate();
|
|
616
652
|
this.handleOnItemCountChanged(dataView.getFilteredItemCount() || 0, args.itemCount);
|
|
617
653
|
// when user has resize by content enabled, we'll force a full width calculation since we change our entire dataset
|
|
618
|
-
if (args.itemCount > 0 && (this.
|
|
654
|
+
if (args.itemCount > 0 && (this.gridOptions.autosizeColumnsByCellContentOnFirstLoad || this.gridOptions.enableAutoResizeColumnsByCellContent)) {
|
|
619
655
|
this.resizerService.resizeColumnsByCellContent(!((_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.resizeByContentOnlyOnFirstLoad));
|
|
620
656
|
}
|
|
621
657
|
});
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
if (gridOptions && gridOptions.enableFiltering && !gridOptions.enableRowDetailView) {
|
|
658
|
+
if ((gridOptions === null || gridOptions === void 0 ? void 0 : gridOptions.enableFiltering) && !gridOptions.enableRowDetailView) {
|
|
659
|
+
this._eventHandler.subscribe(dataView.onRowsChanged, (_e, args) => {
|
|
660
|
+
// filtering data with local dataset will not always show correctly unless we call this updateRow/render
|
|
661
|
+
// also don't use "invalidateRows" since it destroys the entire row and as bad user experience when updating a row
|
|
662
|
+
// see commit: https://github.com/ghiscoding/aurelia-slickgrid/commit/8c503a4d45fba11cbd8d8cc467fae8d177cc4f60
|
|
628
663
|
if ((args === null || args === void 0 ? void 0 : args.rows) && Array.isArray(args.rows)) {
|
|
629
664
|
args.rows.forEach((row) => grid.updateRow(row));
|
|
630
665
|
grid.render();
|
|
631
666
|
}
|
|
632
|
-
}
|
|
633
|
-
}
|
|
667
|
+
});
|
|
668
|
+
}
|
|
634
669
|
}
|
|
635
670
|
}
|
|
636
671
|
// did the user add a colspan callback? If so, hook it into the DataView getItemMetadata
|
|
@@ -645,15 +680,15 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
645
680
|
}
|
|
646
681
|
}
|
|
647
682
|
bindBackendCallbackFunctions(gridOptions) {
|
|
648
|
-
var _a, _b, _c, _d;
|
|
683
|
+
var _a, _b, _c, _d, _f;
|
|
649
684
|
const backendApi = gridOptions.backendServiceApi;
|
|
650
|
-
const backendApiService = backendApi
|
|
651
|
-
const serviceOptions = backendApiService
|
|
685
|
+
const backendApiService = backendApi === null || backendApi === void 0 ? void 0 : backendApi.service;
|
|
686
|
+
const serviceOptions = (backendApiService === null || backendApiService === void 0 ? void 0 : backendApiService.options) || {};
|
|
652
687
|
const isExecuteCommandOnInit = (!serviceOptions) ? false : ((serviceOptions && serviceOptions.hasOwnProperty('executeProcessCommandOnInit')) ? serviceOptions['executeProcessCommandOnInit'] : true);
|
|
653
688
|
if (backendApiService) {
|
|
654
689
|
// update backend filters (if need be) BEFORE the query runs (via the onInit command a few lines below)
|
|
655
690
|
// if user entered some any "presets", we need to reflect them all in the grid
|
|
656
|
-
if (gridOptions
|
|
691
|
+
if (gridOptions === null || gridOptions === void 0 ? void 0 : gridOptions.presets) {
|
|
657
692
|
// Filters "presets"
|
|
658
693
|
if (backendApiService.updateFilters && Array.isArray(gridOptions.presets.filters) && gridOptions.presets.filters.length > 0) {
|
|
659
694
|
backendApiService.updateFilters(gridOptions.presets.filters, true);
|
|
@@ -661,7 +696,7 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
661
696
|
// Sorters "presets"
|
|
662
697
|
if (backendApiService.updateSorters && Array.isArray(gridOptions.presets.sorters) && gridOptions.presets.sorters.length > 0) {
|
|
663
698
|
// when using multi-column sort, we can have multiple but on single sort then only grab the first sort provided
|
|
664
|
-
const sortColumns = this._gridOptions.multiColumnSort ? gridOptions.presets.sorters : gridOptions.presets.sorters.slice(0, 1);
|
|
699
|
+
const sortColumns = ((_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.multiColumnSort) ? gridOptions.presets.sorters : gridOptions.presets.sorters.slice(0, 1);
|
|
665
700
|
backendApiService.updateSorters(undefined, sortColumns);
|
|
666
701
|
}
|
|
667
702
|
// Pagination "presets"
|
|
@@ -679,7 +714,7 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
679
714
|
// execute onInit command when necessary
|
|
680
715
|
if (backendApi && backendApiService && (backendApi.onInit || isExecuteCommandOnInit)) {
|
|
681
716
|
const query = (typeof backendApiService.buildQuery === 'function') ? backendApiService.buildQuery() : '';
|
|
682
|
-
const process = isExecuteCommandOnInit ? ((
|
|
717
|
+
const process = isExecuteCommandOnInit ? ((_c = (_b = backendApi.process) === null || _b === void 0 ? void 0 : _b.call(backendApi, query)) !== null && _c !== void 0 ? _c : null) : ((_f = (_d = backendApi.onInit) === null || _d === void 0 ? void 0 : _d.call(backendApi, query)) !== null && _f !== void 0 ? _f : null);
|
|
683
718
|
// wrap this inside a setTimeout to avoid timing issue since the gridOptions needs to be ready before running this onInit
|
|
684
719
|
setTimeout(() => {
|
|
685
720
|
var _a, _b, _c, _d;
|
|
@@ -726,11 +761,12 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
726
761
|
}
|
|
727
762
|
}
|
|
728
763
|
executeAfterDataviewCreated(_grid, gridOptions) {
|
|
764
|
+
var _a;
|
|
729
765
|
// if user entered some Sort "presets", we need to reflect them all in the DOM
|
|
730
766
|
if (gridOptions.enableSorting) {
|
|
731
767
|
if (gridOptions.presets && Array.isArray(gridOptions.presets.sorters)) {
|
|
732
768
|
// when using multi-column sort, we can have multiple but on single sort then only grab the first sort provided
|
|
733
|
-
const sortColumns = this._gridOptions.multiColumnSort ? gridOptions.presets.sorters : gridOptions.presets.sorters.slice(0, 1);
|
|
769
|
+
const sortColumns = ((_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.multiColumnSort) ? gridOptions.presets.sorters : gridOptions.presets.sorters.slice(0, 1);
|
|
734
770
|
this.sortService.loadGridSorters(sortColumns);
|
|
735
771
|
}
|
|
736
772
|
}
|
|
@@ -742,7 +778,7 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
742
778
|
paginationChanged(pagination) {
|
|
743
779
|
var _a, _b;
|
|
744
780
|
const isSyncGridSelectionEnabled = (_b = (_a = this.gridStateService) === null || _a === void 0 ? void 0 : _a.needToPreserveRowSelection()) !== null && _b !== void 0 ? _b : false;
|
|
745
|
-
if (!isSyncGridSelectionEnabled && (this.
|
|
781
|
+
if (this.grid && !isSyncGridSelectionEnabled && (this.gridOptions.enableRowSelection || this.gridOptions.enableCheckboxSelector)) {
|
|
746
782
|
this.grid.setSelectedRows([]);
|
|
747
783
|
}
|
|
748
784
|
const { pageNumber, pageSize } = pagination;
|
|
@@ -764,67 +800,71 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
764
800
|
else {
|
|
765
801
|
this._paginationOptions = newPaginationOptions;
|
|
766
802
|
}
|
|
767
|
-
this._gridOptions
|
|
768
|
-
|
|
803
|
+
if (this._gridOptions) {
|
|
804
|
+
this._gridOptions.pagination = this._paginationOptions;
|
|
805
|
+
this.paginationService.updateTotalItems((_a = newPaginationOptions === null || newPaginationOptions === void 0 ? void 0 : newPaginationOptions.totalItems) !== null && _a !== void 0 ? _a : 0, true);
|
|
806
|
+
}
|
|
769
807
|
}
|
|
770
808
|
/**
|
|
771
809
|
* When dataset changes, we need to refresh the entire grid UI & possibly resize it as well
|
|
772
810
|
* @param dataset
|
|
773
811
|
*/
|
|
774
812
|
refreshGridData(dataset, totalCount) {
|
|
775
|
-
var _a, _b, _c, _d, _f, _g, _h;
|
|
813
|
+
var _a, _b, _c, _d, _f, _g, _h, _j;
|
|
776
814
|
// local grid, check if we need to show the Pagination
|
|
777
815
|
// if so then also check if there's any presets and finally initialize the PaginationService
|
|
778
816
|
// 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
|
|
779
|
-
if (
|
|
780
|
-
this.
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
if (((_b = this._gridOptions) === null || _b === void 0 ? void 0 : _b.enableEmptyDataWarningMessage) && Array.isArray(dataset)) {
|
|
784
|
-
const finalTotalCount = totalCount || dataset.length;
|
|
785
|
-
this.displayEmptyDataWarning(finalTotalCount < 1);
|
|
786
|
-
}
|
|
787
|
-
if (Array.isArray(dataset) && this.grid && ((_c = this.dataview) === null || _c === void 0 ? void 0 : _c.setItems)) {
|
|
788
|
-
this.dataview.setItems(dataset, this._gridOptions.datasetIdPropertyName);
|
|
789
|
-
if (!this._gridOptions.backendServiceApi && !this._gridOptions.enableTreeData) {
|
|
790
|
-
this.dataview.reSort();
|
|
817
|
+
if (this.grid && this._gridOptions) {
|
|
818
|
+
if (((_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.enablePagination) && this._isLocalGrid) {
|
|
819
|
+
this.showPagination = true;
|
|
820
|
+
this.loadLocalGridPagination(dataset);
|
|
791
821
|
}
|
|
792
|
-
if (
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
822
|
+
if (((_b = this._gridOptions) === null || _b === void 0 ? void 0 : _b.enableEmptyDataWarningMessage) && Array.isArray(dataset)) {
|
|
823
|
+
const finalTotalCount = totalCount || dataset.length;
|
|
824
|
+
this.displayEmptyDataWarning(finalTotalCount < 1);
|
|
825
|
+
}
|
|
826
|
+
if (Array.isArray(dataset) && this.grid && ((_c = this.dataView) === null || _c === void 0 ? void 0 : _c.setItems)) {
|
|
827
|
+
this.dataView.setItems(dataset, (_d = this._gridOptions.datasetIdPropertyName) !== null && _d !== void 0 ? _d : 'id');
|
|
828
|
+
if (!this._gridOptions.backendServiceApi && !this._gridOptions.enableTreeData) {
|
|
829
|
+
this.dataView.reSort();
|
|
830
|
+
}
|
|
831
|
+
if (dataset.length > 0) {
|
|
832
|
+
if (!this._isDatasetInitialized) {
|
|
833
|
+
this.loadFilterPresetsWhenDatasetInitialized();
|
|
834
|
+
if (this._gridOptions.enableCheckboxSelector) {
|
|
835
|
+
this.loadRowSelectionPresetWhenExists();
|
|
836
|
+
}
|
|
797
837
|
}
|
|
838
|
+
this._isDatasetInitialized = true;
|
|
798
839
|
}
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
if (dataset) {
|
|
802
|
-
this.grid.invalidate();
|
|
803
|
-
}
|
|
804
|
-
// 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
|
|
805
|
-
this.showPagination = (this._gridOptions && (this._gridOptions.enablePagination || (this._gridOptions.backendServiceApi && this._gridOptions.enablePagination === undefined))) ? true : false;
|
|
806
|
-
if (this._paginationOptions && ((_d = this._gridOptions) === null || _d === void 0 ? void 0 : _d.pagination) && ((_f = this._gridOptions) === null || _f === void 0 ? void 0 : _f.backendServiceApi)) {
|
|
807
|
-
const paginationOptions = this.setPaginationOptionsWhenPresetDefined(this._gridOptions, this._paginationOptions);
|
|
808
|
-
// when we have a totalCount use it, else we'll take it from the pagination object
|
|
809
|
-
// only update the total items if it's different to avoid refreshing the UI
|
|
810
|
-
const totalRecords = (totalCount !== undefined) ? totalCount : ((_h = (_g = this._gridOptions) === null || _g === void 0 ? void 0 : _g.pagination) === null || _h === void 0 ? void 0 : _h.totalItems);
|
|
811
|
-
if (totalRecords !== undefined && totalRecords !== this.totalItems) {
|
|
812
|
-
this.totalItems = +totalRecords;
|
|
840
|
+
if (dataset) {
|
|
841
|
+
this.grid.invalidate();
|
|
813
842
|
}
|
|
814
|
-
//
|
|
815
|
-
|
|
816
|
-
|
|
843
|
+
// 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
|
|
844
|
+
this.showPagination = (this._gridOptions && (this._gridOptions.enablePagination || (this._gridOptions.backendServiceApi && this._gridOptions.enablePagination === undefined))) ? true : false;
|
|
845
|
+
if (this._paginationOptions && ((_f = this._gridOptions) === null || _f === void 0 ? void 0 : _f.pagination) && ((_g = this._gridOptions) === null || _g === void 0 ? void 0 : _g.backendServiceApi)) {
|
|
846
|
+
const paginationOptions = this.setPaginationOptionsWhenPresetDefined(this._gridOptions, this._paginationOptions);
|
|
847
|
+
// when we have a totalCount use it, else we'll take it from the pagination object
|
|
848
|
+
// only update the total items if it's different to avoid refreshing the UI
|
|
849
|
+
const totalRecords = (totalCount !== undefined) ? totalCount : ((_j = (_h = this._gridOptions) === null || _h === void 0 ? void 0 : _h.pagination) === null || _j === void 0 ? void 0 : _j.totalItems);
|
|
850
|
+
if (totalRecords !== undefined && totalRecords !== this.totalItems) {
|
|
851
|
+
this.totalItems = +totalRecords;
|
|
852
|
+
}
|
|
853
|
+
// initialize the Pagination Service with new pagination options (which might have presets)
|
|
854
|
+
if (!this._isPaginationInitialized) {
|
|
855
|
+
this.initializePaginationService(paginationOptions);
|
|
856
|
+
}
|
|
857
|
+
else {
|
|
858
|
+
// update the pagination service with the new total
|
|
859
|
+
this.paginationService.updateTotalItems(this.totalItems);
|
|
860
|
+
}
|
|
817
861
|
}
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
this.
|
|
862
|
+
// resize the grid inside a slight timeout, in case other DOM element changed prior to the resize (like a filter/pagination changed)
|
|
863
|
+
if (this.grid && this._gridOptions.enableAutoResize) {
|
|
864
|
+
const delay = this._gridOptions.autoResize && this._gridOptions.autoResize.delay;
|
|
865
|
+
this.resizerService.resizeGrid(delay || 10);
|
|
821
866
|
}
|
|
822
867
|
}
|
|
823
|
-
// resize the grid inside a slight timeout, in case other DOM element changed prior to the resize (like a filter/pagination changed)
|
|
824
|
-
if (this.grid && this._gridOptions.enableAutoResize) {
|
|
825
|
-
const delay = this._gridOptions.autoResize && this._gridOptions.autoResize.delay;
|
|
826
|
-
this.resizerService.resizeGrid(delay || 10);
|
|
827
|
-
}
|
|
828
868
|
}
|
|
829
869
|
}
|
|
830
870
|
/**
|
|
@@ -843,7 +883,8 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
843
883
|
* if there are then load them in the paginationOptions object
|
|
844
884
|
*/
|
|
845
885
|
setPaginationOptionsWhenPresetDefined(gridOptions, paginationOptions) {
|
|
846
|
-
|
|
886
|
+
var _a;
|
|
887
|
+
if (((_a = gridOptions.presets) === null || _a === void 0 ? void 0 : _a.pagination) && gridOptions.pagination) {
|
|
847
888
|
paginationOptions.pageSize = gridOptions.presets.pagination.pageSize;
|
|
848
889
|
paginationOptions.pageNumber = gridOptions.presets.pagination.pageNumber;
|
|
849
890
|
}
|
|
@@ -856,7 +897,7 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
856
897
|
*/
|
|
857
898
|
updateColumnDefinitionsList(newColumnDefinitions) {
|
|
858
899
|
var _a, _b, _c;
|
|
859
|
-
if (newColumnDefinitions) {
|
|
900
|
+
if (this.grid && this._gridOptions && Array.isArray(newColumnDefinitions)) {
|
|
860
901
|
// map/swap the internal library Editor to the SlickGrid Editor factory
|
|
861
902
|
newColumnDefinitions = this.swapInternalEditorToSlickGridFactoryEditor(newColumnDefinitions);
|
|
862
903
|
// if the user wants to automatically add a Custom Editor Formatter, we need to call the auto add function again
|
|
@@ -878,7 +919,7 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
878
919
|
}
|
|
879
920
|
}
|
|
880
921
|
//
|
|
881
|
-
//
|
|
922
|
+
// protected functions
|
|
882
923
|
// ------------------
|
|
883
924
|
/**
|
|
884
925
|
* Loop through all column definitions and copy the original optional `width` properties optionally provided by the user.
|
|
@@ -912,18 +953,18 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
912
953
|
}
|
|
913
954
|
/** Initialize the Pagination Service once */
|
|
914
955
|
initializePaginationService(paginationOptions) {
|
|
915
|
-
if (this.
|
|
956
|
+
if (this.grid && this.gridOptions) {
|
|
916
957
|
this.paginationData = {
|
|
917
|
-
gridOptions: this.
|
|
958
|
+
gridOptions: this.gridOptions,
|
|
918
959
|
paginationService: this.paginationService,
|
|
919
960
|
};
|
|
920
961
|
this.paginationService.totalItems = this.totalItems;
|
|
921
962
|
this.paginationService.init(this.grid, paginationOptions, this.backendServiceApi);
|
|
922
|
-
this.subscriptions.push(this._eventPubSubService.subscribe('onPaginationChanged', (paginationChanges) => this.
|
|
963
|
+
this.subscriptions.push(this._eventPubSubService.subscribe('onPaginationChanged', paginationChanges => this.paginationChanged(paginationChanges)), this._eventPubSubService.subscribe('onPaginationOptionsChanged', paginationChanges => this.paginationOptionsChanged(paginationChanges)), this._eventPubSubService.subscribe('onPaginationVisibilityChanged', (visibility) => {
|
|
923
964
|
var _a, _b, _c;
|
|
924
965
|
this.showPagination = (_a = visibility === null || visibility === void 0 ? void 0 : visibility.visible) !== null && _a !== void 0 ? _a : false;
|
|
925
|
-
if ((_b = this.
|
|
926
|
-
(_c = this.backendUtilityService) === null || _c === void 0 ? void 0 : _c.refreshBackendDataset(this.
|
|
966
|
+
if ((_b = this.gridOptions) === null || _b === void 0 ? void 0 : _b.backendServiceApi) {
|
|
967
|
+
(_c = this.backendUtilityService) === null || _c === void 0 ? void 0 : _c.refreshBackendDataset(this.gridOptions);
|
|
927
968
|
}
|
|
928
969
|
this.renderPagination(this.showPagination);
|
|
929
970
|
}));
|
|
@@ -932,6 +973,26 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
932
973
|
this._isPaginationInitialized = true;
|
|
933
974
|
}
|
|
934
975
|
}
|
|
976
|
+
/**
|
|
977
|
+
* Render (or dispose) the Pagination Component, user can optionally provide False (to not show it) which will in term dispose of the Pagination,
|
|
978
|
+
* 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)
|
|
979
|
+
* @param {Boolean} showPagination - show (new render) or not (dispose) the Pagination
|
|
980
|
+
* @param {Boolean} shouldDisposePaginationService - when disposing the Pagination, do we also want to dispose of the Pagination Service? (defaults to True)
|
|
981
|
+
*/
|
|
982
|
+
renderPagination(showPagination = true) {
|
|
983
|
+
var _a;
|
|
984
|
+
if (((_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.enablePagination) && !this._isPaginationInitialized && showPagination) {
|
|
985
|
+
this.slickPagination = new SlickPaginationComponent(this.paginationService, this._eventPubSubService, this.sharedService, this.props.translaterService);
|
|
986
|
+
this.slickPagination.renderPagination(this._elm);
|
|
987
|
+
this._isPaginationInitialized = true;
|
|
988
|
+
}
|
|
989
|
+
else if (!showPagination) {
|
|
990
|
+
if (this.slickPagination) {
|
|
991
|
+
this.slickPagination.dispose();
|
|
992
|
+
}
|
|
993
|
+
this._isPaginationInitialized = false;
|
|
994
|
+
}
|
|
995
|
+
}
|
|
935
996
|
/** Load the Editor Collection asynchronously and replace the "collection" property when Promise resolves */
|
|
936
997
|
loadEditorCollectionAsync(column) {
|
|
937
998
|
var _a;
|
|
@@ -954,8 +1015,8 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
954
1015
|
response.json().then(data => this.updateEditorCollection(column, data));
|
|
955
1016
|
}
|
|
956
1017
|
}
|
|
957
|
-
else if (response
|
|
958
|
-
this.updateEditorCollection(column, response
|
|
1018
|
+
else if (response === null || response === void 0 ? void 0 : response.content) {
|
|
1019
|
+
this.updateEditorCollection(column, response.content); // from http-client
|
|
959
1020
|
}
|
|
960
1021
|
});
|
|
961
1022
|
}
|
|
@@ -969,11 +1030,11 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
969
1030
|
/** Load any possible Columns Grid Presets */
|
|
970
1031
|
loadColumnPresetsWhenDatasetInitialized() {
|
|
971
1032
|
// if user entered some Columns "presets", we need to reflect them all in the grid
|
|
972
|
-
if (this.
|
|
973
|
-
const gridColumns = this.gridStateService.getAssociatedGridColumns(this.grid, this.
|
|
1033
|
+
if (this.grid && this.gridOptions.presets && Array.isArray(this.gridOptions.presets.columns) && this.gridOptions.presets.columns.length > 0) {
|
|
1034
|
+
const gridColumns = this.gridStateService.getAssociatedGridColumns(this.grid, this.gridOptions.presets.columns);
|
|
974
1035
|
if (gridColumns && Array.isArray(gridColumns) && gridColumns.length > 0) {
|
|
975
1036
|
// make sure that the checkbox selector is also visible if it is enabled
|
|
976
|
-
if (this.
|
|
1037
|
+
if (this.gridOptions.enableCheckboxSelector) {
|
|
977
1038
|
const checkboxColumn = (Array.isArray(this._columnDefinitions) && this._columnDefinitions.length > 0) ? this._columnDefinitions[0] : null;
|
|
978
1039
|
if (checkboxColumn && checkboxColumn.id === '_checkbox_selector' && gridColumns[0].id !== '_checkbox_selector') {
|
|
979
1040
|
gridColumns.unshift(checkboxColumn);
|
|
@@ -990,10 +1051,11 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
990
1051
|
}
|
|
991
1052
|
/** Load any possible Filters Grid Presets */
|
|
992
1053
|
loadFilterPresetsWhenDatasetInitialized() {
|
|
1054
|
+
var _a, _b, _c;
|
|
993
1055
|
if (this._gridOptions && !this.props.customDataView) {
|
|
994
1056
|
// if user entered some Filter "presets", we need to reflect them all in the DOM
|
|
995
|
-
if (this._gridOptions.presets && Array.isArray(this._gridOptions.presets.filters)) {
|
|
996
|
-
this.filterService.populateColumnFilterSearchTermPresets(this._gridOptions.presets.filters);
|
|
1057
|
+
if (this._gridOptions.presets && (Array.isArray(this._gridOptions.presets.filters) || Array.isArray((_b = (_a = this._gridOptions.presets) === null || _a === void 0 ? void 0 : _a.treeData) === null || _b === void 0 ? void 0 : _b.toggledItems))) {
|
|
1058
|
+
this.filterService.populateColumnFilterSearchTermPresets(((_c = this._gridOptions.presets) === null || _c === void 0 ? void 0 : _c.filters) || []);
|
|
997
1059
|
}
|
|
998
1060
|
}
|
|
999
1061
|
}
|
|
@@ -1006,8 +1068,8 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
1006
1068
|
var _a;
|
|
1007
1069
|
if (this._gridOptions && this._paginationOptions) {
|
|
1008
1070
|
this.totalItems = Array.isArray(dataset) ? dataset.length : 0;
|
|
1009
|
-
if (this._paginationOptions && ((_a = this.
|
|
1010
|
-
const slickPagingInfo = this.
|
|
1071
|
+
if (this._paginationOptions && ((_a = this.dataView) === null || _a === void 0 ? void 0 : _a.getPagingInfo)) {
|
|
1072
|
+
const slickPagingInfo = this.dataView.getPagingInfo();
|
|
1011
1073
|
if ((slickPagingInfo === null || slickPagingInfo === void 0 ? void 0 : slickPagingInfo.hasOwnProperty('totalRows')) && this._paginationOptions.totalItems !== slickPagingInfo.totalRows) {
|
|
1012
1074
|
this.totalItems = slickPagingInfo.totalRows || 0;
|
|
1013
1075
|
}
|
|
@@ -1019,26 +1081,25 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
1019
1081
|
}
|
|
1020
1082
|
/** Load any Row Selections into the DataView that were presets by the user */
|
|
1021
1083
|
loadRowSelectionPresetWhenExists() {
|
|
1022
|
-
var _a, _b
|
|
1084
|
+
var _a, _b;
|
|
1023
1085
|
// if user entered some Row Selections "presets"
|
|
1024
1086
|
const presets = (_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.presets;
|
|
1025
|
-
const selectionModel = (_c = (_b = this.grid) === null || _b === void 0 ? void 0 : _b.getSelectionModel) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
1026
1087
|
const enableRowSelection = this._gridOptions && (this._gridOptions.enableCheckboxSelector || this._gridOptions.enableRowSelection);
|
|
1027
|
-
if (enableRowSelection &&
|
|
1088
|
+
if (enableRowSelection && ((_b = this.grid) === null || _b === void 0 ? void 0 : _b.getSelectionModel()) && (presets === null || presets === void 0 ? void 0 : presets.rowSelection) && (Array.isArray(presets.rowSelection.gridRowIndexes) || Array.isArray(presets.rowSelection.dataContextIds))) {
|
|
1028
1089
|
let dataContextIds = presets.rowSelection.dataContextIds;
|
|
1029
1090
|
let gridRowIndexes = presets.rowSelection.gridRowIndexes;
|
|
1030
1091
|
// maps the IDs to the Grid Rows and vice versa, the "dataContextIds" has precedence over the other
|
|
1031
1092
|
if (Array.isArray(dataContextIds) && dataContextIds.length > 0) {
|
|
1032
|
-
gridRowIndexes = this.
|
|
1093
|
+
gridRowIndexes = this.dataView.mapIdsToRows(dataContextIds) || [];
|
|
1033
1094
|
}
|
|
1034
1095
|
else if (Array.isArray(gridRowIndexes) && gridRowIndexes.length > 0) {
|
|
1035
|
-
dataContextIds = this.
|
|
1096
|
+
dataContextIds = this.dataView.mapRowsToIds(gridRowIndexes) || [];
|
|
1036
1097
|
}
|
|
1037
1098
|
this.gridStateService.selectedRowDataContextIds = dataContextIds;
|
|
1038
1099
|
// change the selected rows except UNLESS it's a Local Grid with Pagination
|
|
1039
1100
|
// local Pagination uses the DataView and that also trigger a change/refresh
|
|
1040
1101
|
// and we don't want to trigger 2 Grid State changes just 1
|
|
1041
|
-
if ((this._isLocalGrid && !this.
|
|
1102
|
+
if ((this._isLocalGrid && !this.gridOptions.enablePagination) || !this._isLocalGrid) {
|
|
1042
1103
|
setTimeout(() => {
|
|
1043
1104
|
if (this.grid && Array.isArray(gridRowIndexes)) {
|
|
1044
1105
|
this.grid.setSelectedRows(gridRowIndexes);
|
|
@@ -1052,6 +1113,10 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
1052
1113
|
const options = $.extend(true, {}, GlobalGridOptions, gridOptions);
|
|
1053
1114
|
options.gridId = this.props.gridId;
|
|
1054
1115
|
options.gridContainerId = `slickGridContainer-${this.props.gridId}`;
|
|
1116
|
+
// also make sure to show the header row if user have enabled filtering
|
|
1117
|
+
if (options.enableFiltering && !options.showHeaderRow) {
|
|
1118
|
+
options.showHeaderRow = options.enableFiltering;
|
|
1119
|
+
}
|
|
1055
1120
|
// if we have a backendServiceApi and the enablePagination is undefined, we'll assume that we do want to see it, else get that defined value
|
|
1056
1121
|
options.enablePagination = ((gridOptions.backendServiceApi && gridOptions.enablePagination === undefined) ? true : gridOptions.enablePagination) || false;
|
|
1057
1122
|
// using jQuery extend to do a deep clone has an unwanted side on objects and pageSizes but ES6 spread has other worst side effects
|
|
@@ -1060,26 +1125,19 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
1060
1125
|
if ((options === null || options === void 0 ? void 0 : options.pagination) && (gridOptions.enablePagination || gridOptions.backendServiceApi) && gridOptions.pagination && Array.isArray(gridOptions.pagination.pageSizes)) {
|
|
1061
1126
|
options.pagination.pageSizes = gridOptions.pagination.pageSizes;
|
|
1062
1127
|
}
|
|
1063
|
-
// also make sure to show the header row if user have enabled filtering
|
|
1064
|
-
this._hideHeaderRowAfterPageLoad = (options.showHeaderRow === false);
|
|
1065
|
-
if (options.enableFiltering && !options.showHeaderRow) {
|
|
1066
|
-
options.showHeaderRow = options.enableFiltering;
|
|
1067
|
-
}
|
|
1068
1128
|
// when we use Pagination on Local Grid, it doesn't seem to work without enableFiltering
|
|
1069
1129
|
// so we'll enable the filtering but we'll keep the header row hidden
|
|
1070
|
-
if (
|
|
1130
|
+
if (this.sharedService && !options.enableFiltering && options.enablePagination && this._isLocalGrid) {
|
|
1071
1131
|
options.enableFiltering = true;
|
|
1072
1132
|
options.showHeaderRow = false;
|
|
1073
1133
|
this._hideHeaderRowAfterPageLoad = true;
|
|
1074
|
-
|
|
1075
|
-
this.sharedService.hideHeaderRowAfterPageLoad = true;
|
|
1076
|
-
}
|
|
1134
|
+
this.sharedService.hideHeaderRowAfterPageLoad = true;
|
|
1077
1135
|
}
|
|
1078
1136
|
return options;
|
|
1079
1137
|
}
|
|
1080
1138
|
/** Pre-Register any Resource that don't require SlickGrid to be instantiated (for example RxJS Resource) */
|
|
1081
1139
|
preRegisterResources() {
|
|
1082
|
-
this._registeredResources = this.
|
|
1140
|
+
this._registeredResources = this.gridOptions.registerExternalResources || [];
|
|
1083
1141
|
// bind & initialize all Components/Services that were tagged as enabled
|
|
1084
1142
|
// register all services by executing their init method and providing them with the Grid object
|
|
1085
1143
|
if (Array.isArray(this._registeredResources)) {
|
|
@@ -1098,15 +1156,15 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
1098
1156
|
// push all other Services that we want to be registered
|
|
1099
1157
|
this._registeredResources.push(this.gridService, this.gridStateService);
|
|
1100
1158
|
// when using Grouping/DraggableGrouping/Colspan register its Service
|
|
1101
|
-
if (this.
|
|
1159
|
+
if (this.gridOptions.createPreHeaderPanel && !this.gridOptions.enableDraggableGrouping) {
|
|
1102
1160
|
this._registeredResources.push(this.groupingService);
|
|
1103
1161
|
}
|
|
1104
1162
|
// when using Tree Data View, register its Service
|
|
1105
|
-
if (this.
|
|
1163
|
+
if (this.gridOptions.enableTreeData) {
|
|
1106
1164
|
this._registeredResources.push(this.treeDataService);
|
|
1107
1165
|
}
|
|
1108
1166
|
// when user enables translation, we need to translate Headers on first pass & subsequently in the bindDifferentHooks
|
|
1109
|
-
if (this.
|
|
1167
|
+
if (this.gridOptions.enableTranslate) {
|
|
1110
1168
|
this.extensionService.translateColumnHeaders();
|
|
1111
1169
|
}
|
|
1112
1170
|
// also initialize (render) the empty warning component
|
|
@@ -1116,7 +1174,7 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
1116
1174
|
// register all services by executing their init method and providing them with the Grid object
|
|
1117
1175
|
if (Array.isArray(this._registeredResources)) {
|
|
1118
1176
|
for (const resource of this._registeredResources) {
|
|
1119
|
-
if (typeof resource.init === 'function') {
|
|
1177
|
+
if (this.grid && typeof resource.init === 'function') {
|
|
1120
1178
|
resource.init(this.grid, this.props.containerService);
|
|
1121
1179
|
}
|
|
1122
1180
|
}
|
|
@@ -1132,26 +1190,6 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
1132
1190
|
this.paginationService.addRxJsResource(this.rxjs);
|
|
1133
1191
|
this.props.containerService.registerInstance('RxJsResource', this.rxjs);
|
|
1134
1192
|
}
|
|
1135
|
-
/**
|
|
1136
|
-
* Render (or dispose) the Pagination Component, user can optionally provide False (to not show it) which will in term dispose of the Pagination,
|
|
1137
|
-
* 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)
|
|
1138
|
-
* @param {Boolean} showPagination - show (new render) or not (dispose) the Pagination
|
|
1139
|
-
* @param {Boolean} shouldDisposePaginationService - when disposing the Pagination, do we also want to dispose of the Pagination Service? (defaults to True)
|
|
1140
|
-
*/
|
|
1141
|
-
renderPagination(showPagination = true) {
|
|
1142
|
-
var _a;
|
|
1143
|
-
if (((_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.enablePagination) && !this._isPaginationInitialized && showPagination) {
|
|
1144
|
-
this.slickPagination = new SlickPaginationComponent(this.paginationService, this._eventPubSubService, this.sharedService, this.props.translaterService);
|
|
1145
|
-
this.slickPagination.renderPagination(this.elm.current);
|
|
1146
|
-
this._isPaginationInitialized = true;
|
|
1147
|
-
}
|
|
1148
|
-
else if (!showPagination) {
|
|
1149
|
-
if (this.slickPagination) {
|
|
1150
|
-
this.slickPagination.dispose();
|
|
1151
|
-
}
|
|
1152
|
-
this._isPaginationInitialized = false;
|
|
1153
|
-
}
|
|
1154
|
-
}
|
|
1155
1193
|
/**
|
|
1156
1194
|
* Takes a flat dataset with parent/child relationship, sort it (via its tree structure) and return the sorted flat array
|
|
1157
1195
|
* @param {Array<Object>} flatDatasetInput - flat dataset input
|
|
@@ -1164,8 +1202,8 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
1164
1202
|
let sortedDatasetResult;
|
|
1165
1203
|
let flatDatasetOutput = [];
|
|
1166
1204
|
// if the hierarchical dataset was already initialized then no need to re-convert it, we can use it directly from the shared service ref
|
|
1167
|
-
if (this._isDatasetHierarchicalInitialized && this.
|
|
1168
|
-
sortedDatasetResult = this.treeDataService.sortHierarchicalDataset(this.
|
|
1205
|
+
if (this._isDatasetHierarchicalInitialized && this.datasetHierarchical) {
|
|
1206
|
+
sortedDatasetResult = this.treeDataService.sortHierarchicalDataset(this.datasetHierarchical);
|
|
1169
1207
|
flatDatasetOutput = sortedDatasetResult.flat;
|
|
1170
1208
|
}
|
|
1171
1209
|
else if (Array.isArray(flatDatasetInput) && flatDatasetInput.length > 0) {
|
|
@@ -1178,7 +1216,7 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
1178
1216
|
else {
|
|
1179
1217
|
// else we assume that the user provided an array that is already sorted (user's responsability)
|
|
1180
1218
|
// and so we can simply convert the array to a tree structure and we're done, no need to sort
|
|
1181
|
-
this.sharedService.hierarchicalDataset = this.treeDataService.convertFlatParentChildToTreeDataset(flatDatasetInput, this.
|
|
1219
|
+
this.sharedService.hierarchicalDataset = this.treeDataService.convertFlatParentChildToTreeDataset(flatDatasetInput, this.gridOptions);
|
|
1182
1220
|
flatDatasetOutput = flatDatasetInput || [];
|
|
1183
1221
|
}
|
|
1184
1222
|
}
|
|
@@ -1199,13 +1237,14 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
1199
1237
|
console.error('[Slickgrid-React] 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".');
|
|
1200
1238
|
}
|
|
1201
1239
|
return columnDefinitions.map((column) => {
|
|
1240
|
+
var _a, _b;
|
|
1202
1241
|
// on every Editor which have a "collection" or a "collectionAsync"
|
|
1203
|
-
if (column.editor
|
|
1242
|
+
if ((_a = column.editor) === null || _a === void 0 ? void 0 : _a.collectionAsync) {
|
|
1204
1243
|
this.loadEditorCollectionAsync(column);
|
|
1205
1244
|
}
|
|
1206
1245
|
return {
|
|
1207
1246
|
...column,
|
|
1208
|
-
editor: column.editor
|
|
1247
|
+
editor: (_b = column.editor) === null || _b === void 0 ? void 0 : _b.model,
|
|
1209
1248
|
internalColumnEditor: { ...column.editor }
|
|
1210
1249
|
};
|
|
1211
1250
|
});
|
|
@@ -1227,9 +1266,8 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
1227
1266
|
column.editor.collection = newCollection;
|
|
1228
1267
|
column.editor.disabled = false;
|
|
1229
1268
|
// find the new column reference pointer & re-assign the new editor to the internalColumnEditor
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
const columnRef = columns.find((col) => col.id === column.id);
|
|
1269
|
+
if (Array.isArray(this._columnDefinitions)) {
|
|
1270
|
+
const columnRef = this._columnDefinitions.find((col) => col.id === column.id);
|
|
1233
1271
|
if (columnRef) {
|
|
1234
1272
|
columnRef.internalColumnEditor = column.editor;
|
|
1235
1273
|
}
|
|
@@ -1243,15 +1281,14 @@ export class ReactSlickgridCustomElement extends React.Component {
|
|
|
1243
1281
|
}
|
|
1244
1282
|
}
|
|
1245
1283
|
render() {
|
|
1246
|
-
return (React.createElement("div", { id: `slickGridContainer-${this.props.gridId}`, className: "grid-pane
|
|
1247
|
-
React.createElement("
|
|
1284
|
+
return (React.createElement("div", { id: `slickGridContainer-${this.props.gridId}`, className: "grid-pane", ref: elm => this._elm = elm },
|
|
1285
|
+
this.props.header && React.createElement("div", { className: "header" }, this.props.header),
|
|
1248
1286
|
React.createElement("div", { id: `${this.props.gridId}`, className: "slickgrid-container", style: { width: '100%' }, onBlur: $event => this.commitEdit($event.target) }),
|
|
1249
|
-
React.createElement("
|
|
1287
|
+
this.props.footer && React.createElement("div", { className: "footer" }, this.props.footer)));
|
|
1250
1288
|
}
|
|
1251
1289
|
}
|
|
1252
|
-
|
|
1290
|
+
ReactSlickgrid.defaultProps = {
|
|
1253
1291
|
reactUtilService: new ReactUtilService(),
|
|
1254
|
-
globalEa: GlobalEventPubSubService,
|
|
1255
1292
|
containerService: GlobalContainerService,
|
|
1256
1293
|
translaterService: new TranslaterService(),
|
|
1257
1294
|
dataset: [],
|