@visns-studio/visns-components 2.4.7 → 2.4.8
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.
|
@@ -98,6 +98,7 @@ const DataGrid = ({
|
|
|
98
98
|
gridHeight,
|
|
99
99
|
settings,
|
|
100
100
|
setFilterData,
|
|
101
|
+
setConfig,
|
|
101
102
|
style,
|
|
102
103
|
}) => {
|
|
103
104
|
const navigate = useNavigate();
|
|
@@ -267,6 +268,23 @@ const DataGrid = ({
|
|
|
267
268
|
setDataReload(randomNumber);
|
|
268
269
|
};
|
|
269
270
|
|
|
271
|
+
const handleSort = (value) => {
|
|
272
|
+
setConfig((prevState) => {
|
|
273
|
+
const { id, dir } = value || {}; // Destructure id and dir from value (if provided)
|
|
274
|
+
const sortBy = id || null;
|
|
275
|
+
const sort = dir === 1 ? 'asc' : dir === -1 ? 'desc' : null;
|
|
276
|
+
|
|
277
|
+
return {
|
|
278
|
+
...prevState,
|
|
279
|
+
ajaxSetting: {
|
|
280
|
+
...prevState.ajaxSetting,
|
|
281
|
+
sortBy,
|
|
282
|
+
sort,
|
|
283
|
+
},
|
|
284
|
+
};
|
|
285
|
+
});
|
|
286
|
+
};
|
|
287
|
+
|
|
270
288
|
const onRowClick = useCallback(
|
|
271
289
|
(rowProps, event) => {
|
|
272
290
|
const cellElement = event.target.closest(
|
|
@@ -1401,7 +1419,6 @@ const DataGrid = ({
|
|
|
1401
1419
|
columns={gridColumns}
|
|
1402
1420
|
dataSource={data}
|
|
1403
1421
|
filterValue={filterValue}
|
|
1404
|
-
defaultSortInfo={sortInfo}
|
|
1405
1422
|
enableColumnAutosize={false}
|
|
1406
1423
|
enableColumnFilterContextMenu={false}
|
|
1407
1424
|
enableSelection={false}
|
|
@@ -1414,11 +1431,20 @@ const DataGrid = ({
|
|
|
1414
1431
|
minRowHeight={40}
|
|
1415
1432
|
onFilterValueChange={setFilterValue}
|
|
1416
1433
|
onLimitChange={setLimit}
|
|
1434
|
+
onSortInfoChange={handleSort}
|
|
1417
1435
|
onRenderRow={onRenderRow}
|
|
1418
1436
|
pagination
|
|
1419
1437
|
renderColumnContextMenu={renderColumnContextMenu}
|
|
1420
1438
|
rowHeight={null}
|
|
1421
1439
|
showZebraRows={true}
|
|
1440
|
+
sortInfo={
|
|
1441
|
+
ajaxSetting.sortBy && ajaxSetting.sort
|
|
1442
|
+
? {
|
|
1443
|
+
name: ajaxSetting.sortBy,
|
|
1444
|
+
dir: ajaxSetting.sort === 'asc' ? 1 : -1,
|
|
1445
|
+
}
|
|
1446
|
+
: null
|
|
1447
|
+
}
|
|
1422
1448
|
style={gridStyle}
|
|
1423
1449
|
/>
|
|
1424
1450
|
<Popup
|
package/package.json
CHANGED