ods-component-lib 1.18.16 → 1.18.18
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.
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { MutableRefObject } from 'react';
|
|
2
2
|
import { IDataGridOptions, IButtonProps, ISelectionProps, IEditingProps, ISummaryProps } from 'devextreme-react/data-grid';
|
|
3
3
|
interface IOdsDataGridProps extends IDataGridOptions {
|
|
4
|
+
dataGridRef: MutableRefObject<any>;
|
|
4
5
|
language: string;
|
|
5
6
|
exportFileName: string;
|
|
6
7
|
filterEnabledShow: boolean;
|
|
@@ -18,7 +19,6 @@ interface IOdsDataGridProps extends IDataGridOptions {
|
|
|
18
19
|
isServerSide: boolean;
|
|
19
20
|
axiosRequest?: IAxiosProps;
|
|
20
21
|
customSummary?: ISummaryRowOptions;
|
|
21
|
-
onCancelEdit?: any;
|
|
22
22
|
}
|
|
23
23
|
interface ISummaryRowOptions {
|
|
24
24
|
summaryLoadedDataLabel?: string;
|
package/dist/index.js
CHANGED
|
@@ -17129,7 +17129,6 @@ var OdsRemoteDataGrid = function OdsRemoteDataGrid(props) {
|
|
|
17129
17129
|
isLoading = _useState2[0],
|
|
17130
17130
|
setIsLoading = _useState2[1];
|
|
17131
17131
|
var fileName = props.exportFileName ? props.exportFileName + moment().format("YYYYMMDD") : "DatagridExportFile" + moment().format("YYYYMMDD");
|
|
17132
|
-
var gridRef = React.useRef(null);
|
|
17133
17132
|
var _useState3 = React.useState(0),
|
|
17134
17133
|
filteredRowCount = _useState3[0];
|
|
17135
17134
|
var _useState4 = React.useState(props.columns),
|
|
@@ -17146,6 +17145,11 @@ var OdsRemoteDataGrid = function OdsRemoteDataGrid(props) {
|
|
|
17146
17145
|
'Authorization': 'Bearer ' + (props.axiosRequest ? props.axiosRequest.token : ""),
|
|
17147
17146
|
"Accept-Language": props.language != "" ? props.language : 'EN'
|
|
17148
17147
|
});
|
|
17148
|
+
React.useEffect(function () {
|
|
17149
|
+
totalPageCount = 1;
|
|
17150
|
+
loadedPageCount = 1;
|
|
17151
|
+
totalRecordCount = 0;
|
|
17152
|
+
}, [props.dataGridRef.current]);
|
|
17149
17153
|
React.useEffect(function () {
|
|
17150
17154
|
var _props$axiosRequest;
|
|
17151
17155
|
if (props.axiosRequest !== undefined && Object.keys((_props$axiosRequest = props.axiosRequest) === null || _props$axiosRequest === void 0 ? void 0 : _props$axiosRequest.requestData).length > 0) {
|
|
@@ -17176,12 +17180,14 @@ var OdsRemoteDataGrid = function OdsRemoteDataGrid(props) {
|
|
|
17176
17180
|
setColumns(newColumns);
|
|
17177
17181
|
}
|
|
17178
17182
|
}, [props.columns]);
|
|
17183
|
+
React.useEffect(function () {
|
|
17184
|
+
if (Array.isArray(props.dataSource) && props.dataSource.length > 0) {
|
|
17185
|
+
setData(props.dataSource);
|
|
17186
|
+
}
|
|
17187
|
+
}, [props.dataSource]);
|
|
17179
17188
|
React.useEffect(function () {
|
|
17180
17189
|
localization.locale(localStorage.getItem("locale"));
|
|
17181
17190
|
localization.loadMessages(JSON.parse(localStorage.getItem("localTranslation")));
|
|
17182
|
-
if (gridRef.current) {
|
|
17183
|
-
gridRef.current.instance.updateDimensions();
|
|
17184
|
-
}
|
|
17185
17191
|
}, []);
|
|
17186
17192
|
var actionButtons = React.useMemo(function () {
|
|
17187
17193
|
if (props.actionButtonGroup) {
|
|
@@ -17205,11 +17211,6 @@ var OdsRemoteDataGrid = function OdsRemoteDataGrid(props) {
|
|
|
17205
17211
|
return [];
|
|
17206
17212
|
}
|
|
17207
17213
|
}, [props.actionButtonGroup]);
|
|
17208
|
-
var handleRef = function handleRef(instance) {
|
|
17209
|
-
if (instance) {
|
|
17210
|
-
gridRef.current = instance;
|
|
17211
|
-
}
|
|
17212
|
-
};
|
|
17213
17214
|
var fetchData = React.useCallback(function () {
|
|
17214
17215
|
try {
|
|
17215
17216
|
if (props.axiosRequest == undefined) return Promise.resolve();
|
|
@@ -17264,14 +17265,17 @@ var OdsRemoteDataGrid = function OdsRemoteDataGrid(props) {
|
|
|
17264
17265
|
if (e.row !== undefined && e.parentType === 'dataRow') {
|
|
17265
17266
|
if (props.isServerSide) {
|
|
17266
17267
|
var disableScrolling = function disableScrolling() {
|
|
17267
|
-
|
|
17268
|
+
props.dataGridRef.current.instance.option('scrolling.mode', 'none');
|
|
17268
17269
|
};
|
|
17269
17270
|
var enableScrolling = function enableScrolling() {
|
|
17270
|
-
|
|
17271
|
+
props.dataGridRef.current.instance.option('scrolling.mode', 'virtual');
|
|
17271
17272
|
};
|
|
17272
17273
|
e.editorOptions.onFocusIn = disableScrolling;
|
|
17273
17274
|
e.editorOptions.onFocusOut = enableScrolling;
|
|
17274
17275
|
}
|
|
17276
|
+
if (props.onEditorPreparing) {
|
|
17277
|
+
props.onEditorPreparing(e);
|
|
17278
|
+
}
|
|
17275
17279
|
}
|
|
17276
17280
|
if (e.editorOptions && e.rowType === 'data' && e.parentType === 'dataRow') {
|
|
17277
17281
|
e.editorOptions.onValueChanged = function (args) {
|
|
@@ -17370,7 +17374,7 @@ var OdsRemoteDataGrid = function OdsRemoteDataGrid(props) {
|
|
|
17370
17374
|
}, []);
|
|
17371
17375
|
var renderTotal = React.useCallback(function () {
|
|
17372
17376
|
var totalloaded = 0;
|
|
17373
|
-
if (data.length < 50) {
|
|
17377
|
+
if (data.length < 50 || !props.isServerSide || loadedPageCount == totalPageCount) {
|
|
17374
17378
|
totalloaded = data.length;
|
|
17375
17379
|
} else {
|
|
17376
17380
|
totalloaded = loadedPageCount * props.pageSize;
|
|
@@ -17378,6 +17382,8 @@ var OdsRemoteDataGrid = function OdsRemoteDataGrid(props) {
|
|
|
17378
17382
|
var result = "";
|
|
17379
17383
|
if (filteredRowCount > 0) {
|
|
17380
17384
|
result = "" + totalloaded + props.customSummary.summaryFilteredDataLabel + (totalRecordCount > 0 ? totalloaded + " " + props.customSummary.summaryLoadedDataLabel + ("- " + totalRecordCount) + props.customSummary.summaryTotalDataLabel : " ");
|
|
17385
|
+
} else if (!props.isServerSide && totalloaded > 0) {
|
|
17386
|
+
result = totalloaded + " " + props.customSummary.summaryLoadedDataLabel + ("- " + totalloaded) + props.customSummary.summaryTotalDataLabel;
|
|
17381
17387
|
} else {
|
|
17382
17388
|
result = totalRecordCount > 0 ? totalloaded + " " + props.customSummary.summaryLoadedDataLabel + ("- " + totalRecordCount) + props.customSummary.summaryTotalDataLabel : "";
|
|
17383
17389
|
}
|
|
@@ -17437,11 +17443,11 @@ var OdsRemoteDataGrid = function OdsRemoteDataGrid(props) {
|
|
|
17437
17443
|
}, [data.length]);
|
|
17438
17444
|
return React__default.createElement(React__default.Fragment, null, React__default.createElement(DataGrid__default, {
|
|
17439
17445
|
keyExpr: props.keyExpr,
|
|
17440
|
-
dataSource:
|
|
17446
|
+
dataSource: data,
|
|
17441
17447
|
showBorders: true,
|
|
17442
17448
|
columnAutoWidth: false,
|
|
17443
17449
|
onEditorPreparing: onEditorPreparing,
|
|
17444
|
-
ref:
|
|
17450
|
+
ref: props.dataGridRef,
|
|
17445
17451
|
onExporting: onExporting,
|
|
17446
17452
|
height: props.height == undefined ? window.innerHeight - 164 : props.height,
|
|
17447
17453
|
allowColumnResizing: true,
|
|
@@ -17466,7 +17472,9 @@ var OdsRemoteDataGrid = function OdsRemoteDataGrid(props) {
|
|
|
17466
17472
|
},
|
|
17467
17473
|
onSelectionChanged: props.onSelectionChanged,
|
|
17468
17474
|
noDataText: props.noDataText,
|
|
17469
|
-
onSaved: props.onSaved
|
|
17475
|
+
onSaved: props.onSaved,
|
|
17476
|
+
onSaving: props.onSaving,
|
|
17477
|
+
onEditCanceling: props.onEditCanceling
|
|
17470
17478
|
}, columns.map(function (col) {
|
|
17471
17479
|
return React__default.createElement(DataGrid.Column, Object.assign({
|
|
17472
17480
|
key: col.dataField
|