@cdmx/wappler_ag_grid 0.8.7 → 0.8.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.
package/README.md CHANGED
@@ -326,6 +326,14 @@ Specify the tooltip text for Button 10.
326
326
  - To be used if you wish to use a separate Export button instead of using the inbuilt top left-cornered Export button.
327
327
  - Trigger this action to call Export Data to CSV download action.
328
328
 
329
+ **Save Column State**
330
+ - This action allows you to save the current state of the grid's columns, including their visibility and order, to the browser's local storage.
331
+ - It is useful when you want to remember and restore a specific column configuration for the grid.
332
+
333
+ **Reset Column State**
334
+ - This action enables you to reset the grid's column state to default state.
335
+ - It is useful when you want to revert the column configuration to a default configuration.
336
+
329
337
  ## License
330
338
 
331
339
  The AG Grid module is licensed under the MIT License. Please refer to the license file for more details.
@@ -1825,6 +1825,24 @@
1825
1825
  state: 'opened',
1826
1826
  help: 'Export AG Grid Data to CSV',
1827
1827
  properties: []
1828
+ },
1829
+ {
1830
+ addTitle: 'SaveColumnState',
1831
+ title: 'Save Column State',
1832
+ name: 'saveColumnState',
1833
+ icon: 'fa fa-lg fa-save',
1834
+ state: 'opened',
1835
+ help: 'Save Column State to Browser Local Storage',
1836
+ properties: []
1837
+ },
1838
+ {
1839
+ addTitle: 'ResetColumnState',
1840
+ title: 'Reset Column State',
1841
+ name: 'resetColumnState',
1842
+ icon: 'fa fa-lg fa-undo',
1843
+ state: 'opened',
1844
+ help: 'Save Column State to Browser Local Storage',
1845
+ properties: []
1828
1846
  }
1829
1847
  ],
1830
1848
  "children": [],
package/dmx-ag-grid.js CHANGED
@@ -170,6 +170,22 @@ dmx.Component('ag-grid', {
170
170
  console.error('Grid not loaded to perform export');
171
171
  }
172
172
  }, this);
173
+ },
174
+ saveColumnState: function () {
175
+ dmx.nextTick(function() {
176
+ if (typeof saveColumnStateToStorage === 'function') {
177
+ saveColumnStateToStorage();
178
+ } else {
179
+ console.error('Grid not loaded to perform saveColumnState');
180
+ }
181
+ }, this);
182
+ },
183
+ resetColumnState: function () {
184
+ dmx.nextTick(function() {
185
+ localStorage.removeItem('columnState');
186
+ let gridInstance = this.refreshGrid();
187
+ this.set('gridInstance', gridInstance);
188
+ }, this);
173
189
  }
174
190
  },
175
191
 
@@ -1061,6 +1077,24 @@ dmx.Component('ag-grid', {
1061
1077
  gridInstance = null;
1062
1078
  }
1063
1079
  const gridConfig = {
1080
+ onGridReady: function (params) {
1081
+ const columnApi = params.columnApi;
1082
+ saveColumnStateToStorage = () => {
1083
+ const columnState = columnApi.getColumnState();
1084
+ localStorage.setItem('columnState', JSON.stringify(columnState));
1085
+ }
1086
+ function restoreColumnState() {
1087
+ const savedColumnState = JSON.parse(localStorage.getItem('columnState'));
1088
+ if (savedColumnState) {
1089
+ columnApi.applyColumnState({
1090
+ state: savedColumnState,
1091
+ applyOrder: true,
1092
+ applyVisibility: true,
1093
+ });
1094
+ }
1095
+ }
1096
+ restoreColumnState();
1097
+ },
1064
1098
  columnDefs: columnDefs,
1065
1099
  rowData: rowData,
1066
1100
  ...gridOptions
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdmx/wappler_ag_grid",
3
- "version": "0.8.7",
3
+ "version": "0.8.8",
4
4
  "type": "module",
5
5
  "description": "App Connect module for AG Grid Table Generation.",
6
6
  "license": "MIT",