@cdmx/wappler_ag_grid 1.9.12 → 1.9.13
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/app_connect/components.hjson +34 -0
- package/dmx-ag-grid.js +19 -9
- package/package.json +1 -1
|
@@ -3376,6 +3376,40 @@
|
|
|
3376
3376
|
}
|
|
3377
3377
|
],
|
|
3378
3378
|
"attributes": [
|
|
3379
|
+
{
|
|
3380
|
+
name: "dmx_ag_grid_column_state_key",
|
|
3381
|
+
attributeStartsWith: "dmx-bind",
|
|
3382
|
+
attribute: "column_state_storage_key",
|
|
3383
|
+
title: "Column State Storage Key",
|
|
3384
|
+
type: "boolean",
|
|
3385
|
+
display: "fieldset",
|
|
3386
|
+
icon: "fa fa-lg fa-chevron-right",
|
|
3387
|
+
groupTitle: "Grid Config",
|
|
3388
|
+
groupIcon: "fa fa-lg fa-cubes",
|
|
3389
|
+
defaultValue: false,
|
|
3390
|
+
show: [
|
|
3391
|
+
"columnStateStorageKey"
|
|
3392
|
+
],
|
|
3393
|
+
noChangeOnHide: true,
|
|
3394
|
+
groupEnabler: true,
|
|
3395
|
+
children: [
|
|
3396
|
+
{
|
|
3397
|
+
name: "columnStateStorageKey",
|
|
3398
|
+
attributeStartsWith: "dmx-bind",
|
|
3399
|
+
attribute: "column_state_storage",
|
|
3400
|
+
isValue: true,
|
|
3401
|
+
dataBindings: true,
|
|
3402
|
+
title: "Key Name",
|
|
3403
|
+
type: "text",
|
|
3404
|
+
help: "Optional: Provide a custom key to store and retrieve column state from Local Storage.",
|
|
3405
|
+
defaultValue: "",
|
|
3406
|
+
initDisplay: "none"
|
|
3407
|
+
}
|
|
3408
|
+
],
|
|
3409
|
+
allowedOn: {
|
|
3410
|
+
dmx-ag-grid: true
|
|
3411
|
+
}
|
|
3412
|
+
},
|
|
3379
3413
|
{
|
|
3380
3414
|
"name": "dmx-ag-grid-value",
|
|
3381
3415
|
"attributeStartsWith": "dmx-bind",
|
package/dmx-ag-grid.js
CHANGED
|
@@ -260,7 +260,8 @@ dmx.Component('ag-grid', {
|
|
|
260
260
|
columns_to_count: { type: Array, default: [] },
|
|
261
261
|
columns_to_sum: { type: String, default: null },
|
|
262
262
|
footer_sum_precision: { type: Number, default: null },
|
|
263
|
-
columns_to_count_nonunique: { type: Boolean, default: false }
|
|
263
|
+
columns_to_count_nonunique: { type: Boolean, default: false },
|
|
264
|
+
column_state_storage_key: { type: String, default: null }
|
|
264
265
|
},
|
|
265
266
|
|
|
266
267
|
methods: {
|
|
@@ -1649,17 +1650,26 @@ dmx.Component('ag-grid', {
|
|
|
1649
1650
|
saveColumnStateToStorage = () => {
|
|
1650
1651
|
const columnState = columnApi.getColumnState();
|
|
1651
1652
|
const pageId = getPageId();
|
|
1652
|
-
|
|
1653
|
+
const storageKey = options.column_state_storage_key || pageId;
|
|
1654
|
+
localStorage.setItem(`columnState_${storageKey}`, JSON.stringify(columnState));
|
|
1653
1655
|
}
|
|
1656
|
+
|
|
1654
1657
|
function restoreColumnState() {
|
|
1655
1658
|
const pageId = getPageId();
|
|
1656
|
-
const
|
|
1659
|
+
const storageKey = options.column_state_storage_key || pageId;
|
|
1660
|
+
const savedColumnState = localStorage.getItem(`columnState_${storageKey}`);
|
|
1661
|
+
|
|
1657
1662
|
if (savedColumnState) {
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
+
try {
|
|
1664
|
+
const parsedState = JSON.parse(savedColumnState);
|
|
1665
|
+
columnApi.applyColumnState({
|
|
1666
|
+
state: parsedState,
|
|
1667
|
+
applyOrder: true,
|
|
1668
|
+
applyVisibility: true,
|
|
1669
|
+
});
|
|
1670
|
+
} catch (err) {
|
|
1671
|
+
console.warn(`Failed to parse column state for key: columnState_${storageKey}`, err);
|
|
1672
|
+
}
|
|
1663
1673
|
}
|
|
1664
1674
|
}
|
|
1665
1675
|
restoreColumnState();
|
|
@@ -1782,7 +1792,7 @@ dmx.Component('ag-grid', {
|
|
|
1782
1792
|
gridInstance = null;
|
|
1783
1793
|
}
|
|
1784
1794
|
const getPageId = () => {
|
|
1785
|
-
const currentPageUrl = window.location.
|
|
1795
|
+
const currentPageUrl = window.location.pathname;
|
|
1786
1796
|
const optionsId = options.id+'-grid';
|
|
1787
1797
|
const uniqueId = `${currentPageUrl}_${optionsId}`;
|
|
1788
1798
|
return uniqueId;
|