@cdmx/wappler_ag_grid 1.9.12 → 1.9.14
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 +39 -0
- package/dmx-ag-grid.js +24 -11
- package/package.json +1 -1
|
@@ -52,6 +52,11 @@
|
|
|
52
52
|
"name": "selectedRows",
|
|
53
53
|
"title": "selectedRows",
|
|
54
54
|
"type": "array"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"name": "columnState",
|
|
58
|
+
"title": "columnState",
|
|
59
|
+
"type": "array"
|
|
55
60
|
}
|
|
56
61
|
],
|
|
57
62
|
"outputType": "object",
|
|
@@ -3376,6 +3381,40 @@
|
|
|
3376
3381
|
}
|
|
3377
3382
|
],
|
|
3378
3383
|
"attributes": [
|
|
3384
|
+
{
|
|
3385
|
+
name: "dmx_ag_grid_column_state_key",
|
|
3386
|
+
attributeStartsWith: "dmx-bind",
|
|
3387
|
+
attribute: "column_state_storage_key",
|
|
3388
|
+
title: "Column State Storage Key",
|
|
3389
|
+
type: "boolean",
|
|
3390
|
+
display: "fieldset",
|
|
3391
|
+
icon: "fa fa-lg fa-chevron-right",
|
|
3392
|
+
groupTitle: "Grid Config",
|
|
3393
|
+
groupIcon: "fa fa-lg fa-cubes",
|
|
3394
|
+
defaultValue: false,
|
|
3395
|
+
show: [
|
|
3396
|
+
"columnStateStorageKey"
|
|
3397
|
+
],
|
|
3398
|
+
noChangeOnHide: true,
|
|
3399
|
+
groupEnabler: true,
|
|
3400
|
+
children: [
|
|
3401
|
+
{
|
|
3402
|
+
name: "columnStateStorageKey",
|
|
3403
|
+
attributeStartsWith: "dmx-bind",
|
|
3404
|
+
attribute: "column_state_storage",
|
|
3405
|
+
isValue: true,
|
|
3406
|
+
dataBindings: true,
|
|
3407
|
+
title: "Key Name",
|
|
3408
|
+
type: "text",
|
|
3409
|
+
help: "Optional: Provide a custom key to store and retrieve column state from Local Storage.",
|
|
3410
|
+
defaultValue: "",
|
|
3411
|
+
initDisplay: "none"
|
|
3412
|
+
}
|
|
3413
|
+
],
|
|
3414
|
+
allowedOn: {
|
|
3415
|
+
dmx-ag-grid: true
|
|
3416
|
+
}
|
|
3417
|
+
},
|
|
3379
3418
|
{
|
|
3380
3419
|
"name": "dmx-ag-grid-value",
|
|
3381
3420
|
"attributeStartsWith": "dmx-bind",
|
package/dmx-ag-grid.js
CHANGED
|
@@ -6,6 +6,7 @@ dmx.Component('ag-grid', {
|
|
|
6
6
|
fields: {},
|
|
7
7
|
fileData: [],
|
|
8
8
|
selectedRows: [],
|
|
9
|
+
columnState: [],
|
|
9
10
|
state: {
|
|
10
11
|
gridReady: !1,
|
|
11
12
|
firstDataRendered: !1,
|
|
@@ -260,7 +261,8 @@ dmx.Component('ag-grid', {
|
|
|
260
261
|
columns_to_count: { type: Array, default: [] },
|
|
261
262
|
columns_to_sum: { type: String, default: null },
|
|
262
263
|
footer_sum_precision: { type: Number, default: null },
|
|
263
|
-
columns_to_count_nonunique: { type: Boolean, default: false }
|
|
264
|
+
columns_to_count_nonunique: { type: Boolean, default: false },
|
|
265
|
+
column_state_storage_key: { type: String, default: null }
|
|
264
266
|
},
|
|
265
267
|
|
|
266
268
|
methods: {
|
|
@@ -312,9 +314,10 @@ dmx.Component('ag-grid', {
|
|
|
312
314
|
resetColumnState: function () {
|
|
313
315
|
dmx.nextTick(function() {
|
|
314
316
|
const idValue = this.$node.querySelector('dmx-ag-grid > div')?.getAttribute('id') ?? 'Grid not found';
|
|
315
|
-
const currentPageUrl = window.location.
|
|
317
|
+
const currentPageUrl = window.location.pathname;
|
|
316
318
|
const uniqueId = `${currentPageUrl}_${idValue}`;
|
|
317
|
-
|
|
319
|
+
const storageKey = options.column_state_storage_key || uniqueId;
|
|
320
|
+
localStorage.removeItem(`dmxState-${storageKey}`);
|
|
318
321
|
let gridInstance = this.refreshGrid();
|
|
319
322
|
this.set('gridInstance', gridInstance);
|
|
320
323
|
}, this);
|
|
@@ -1649,17 +1652,27 @@ dmx.Component('ag-grid', {
|
|
|
1649
1652
|
saveColumnStateToStorage = () => {
|
|
1650
1653
|
const columnState = columnApi.getColumnState();
|
|
1651
1654
|
const pageId = getPageId();
|
|
1652
|
-
|
|
1655
|
+
const storageKey = options.column_state_storage_key || pageId;
|
|
1656
|
+
localStorage.setItem(`dmxState-${storageKey}`, JSON.stringify(columnState));
|
|
1657
|
+
this.set('columnState', columnState);
|
|
1653
1658
|
}
|
|
1659
|
+
|
|
1654
1660
|
function restoreColumnState() {
|
|
1655
1661
|
const pageId = getPageId();
|
|
1656
|
-
const
|
|
1662
|
+
const storageKey = options.column_state_storage_key || pageId;
|
|
1663
|
+
const savedColumnState = localStorage.getItem(`dmxState-${storageKey}`);
|
|
1664
|
+
|
|
1657
1665
|
if (savedColumnState) {
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1666
|
+
try {
|
|
1667
|
+
const parsedState = JSON.parse(savedColumnState);
|
|
1668
|
+
columnApi.applyColumnState({
|
|
1669
|
+
state: parsedState,
|
|
1670
|
+
applyOrder: true,
|
|
1671
|
+
applyVisibility: true,
|
|
1672
|
+
});
|
|
1673
|
+
} catch (err) {
|
|
1674
|
+
console.warn(`Failed to parse column state for key: dmxState-${storageKey}`, err);
|
|
1675
|
+
}
|
|
1663
1676
|
}
|
|
1664
1677
|
}
|
|
1665
1678
|
restoreColumnState();
|
|
@@ -1782,7 +1795,7 @@ dmx.Component('ag-grid', {
|
|
|
1782
1795
|
gridInstance = null;
|
|
1783
1796
|
}
|
|
1784
1797
|
const getPageId = () => {
|
|
1785
|
-
const currentPageUrl = window.location.
|
|
1798
|
+
const currentPageUrl = window.location.pathname;
|
|
1786
1799
|
const optionsId = options.id+'-grid';
|
|
1787
1800
|
const uniqueId = `${currentPageUrl}_${optionsId}`;
|
|
1788
1801
|
return uniqueId;
|