@cdmx/wappler_ag_grid 1.2.9 → 1.3.1

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.
@@ -369,15 +369,6 @@
369
369
  "initDisplay": "none",
370
370
  "defaultValue": 80,
371
371
  "help": "Specify topbar offset, Default: 80"
372
- },
373
- {
374
- "name": "fixedHorizontalScrollWidth",
375
- "attribute": "dmx-bind:fixed_horizontal_scroll_width",
376
- "title": "Fixed Horizontal Scroll Width",
377
- "type": "number",
378
- "initDisplay": "none",
379
- "defaultValue": 80,
380
- "help": "Fixed horizontal scroll width percentage (Default: 80%)"
381
372
  }
382
373
  ]
383
374
  },
package/dmx-ag-grid.js CHANGED
@@ -76,7 +76,6 @@ dmx.Component('ag-grid', {
76
76
  fixed_header_offset: { type: Number, default: 100 },
77
77
  fixed_top_offset: { type: Number, default: 80 },
78
78
  fixed_horizontal_scroll: { type: Boolean, default: false },
79
- fixed_horizontal_scroll_width: { type: Number, default: 80 },
80
79
  fixed_footer: { type: Boolean, default: false },
81
80
  fixed_footer_bottom_padding: { type: Number, default: 10 },
82
81
  timezone: {type: String, default: '' },
@@ -243,7 +242,14 @@ dmx.Component('ag-grid', {
243
242
  transactionUpdate: function () {
244
243
  // const oldRowData = this.get('oldData');
245
244
  const gridInstance = this.get('gridInstance');
246
- const oldRowData = gridInstance.getModel().rowsToDisplay.map(row => row.data);
245
+ //const oldRowData = gridInstance.getModel().rowsToDisplay.map(row => row.data);
246
+ // Retrieve old row data from the grid instance directly
247
+ const oldRowData = [];
248
+ gridInstance.forEachNode(node => {
249
+ if (node.data) {
250
+ oldRowData.push(node.data);
251
+ }
252
+ });
247
253
  const newRowData = this.props.data;
248
254
  let transaction;
249
255
 
@@ -262,8 +268,7 @@ dmx.Component('ag-grid', {
262
268
  update: updatedRows,
263
269
  };
264
270
  }
265
-
266
- if (gridInstance && gridInstance.gridOptions && transaction) {
271
+ if (gridInstance && transaction) {
267
272
  gridInstance.applyTransaction(transaction);
268
273
  gridInstance.refreshCells();
269
274
  } else {
@@ -1282,7 +1287,38 @@ dmx.Component('ag-grid', {
1282
1287
  suppressPropertyNamesCheck: this.props.suppress_property_names_check,
1283
1288
  suppressRowDeselection: this.props.suppress_row_deselection,
1284
1289
  columnHoverHighlight: this.props.column_hover_highlight,
1285
- onGridReady: () => {
1290
+ onGridReady: (params) => {
1291
+ const columnApi = params.columnApi.api;
1292
+ hideColumn = (fieldToHide) => {
1293
+ columnApi.setColumnsVisible([fieldToHide], false);
1294
+ }
1295
+ pinColumnToLeft = (fieldToPin) => {
1296
+ const columnState = columnApi.getColumnState();
1297
+ const columnIndex = columnState.findIndex(column => column.colId === fieldToPin);
1298
+ if (columnIndex !== -1) {
1299
+ for (let i = 0; i <= columnIndex; i++) {
1300
+ columnState[i].pinned = 'left';
1301
+ }
1302
+ columnApi.applyColumnState({ state: columnState });
1303
+ }
1304
+ }
1305
+ saveColumnStateToStorage = () => {
1306
+ const columnState = columnApi.getColumnState();
1307
+ const pageId = getPageId();
1308
+ localStorage.setItem(`columnState_${pageId}`, JSON.stringify(columnState));
1309
+ }
1310
+ function restoreColumnState() {
1311
+ const pageId = getPageId();
1312
+ const savedColumnState = JSON.parse(localStorage.getItem(`columnState_${pageId}`));
1313
+ if (savedColumnState) {
1314
+ columnApi.applyColumnState({
1315
+ state: savedColumnState,
1316
+ applyOrder: true,
1317
+ applyVisibility: true,
1318
+ });
1319
+ }
1320
+ }
1321
+ restoreColumnState();
1286
1322
  this.set("state", { gridReady: true });
1287
1323
  },
1288
1324
  onFirstDataRendered: () => {
@@ -1372,39 +1408,6 @@ dmx.Component('ag-grid', {
1372
1408
  return uniqueId;
1373
1409
  };
1374
1410
  const gridConfig = {
1375
- onGridReady: function (params) {
1376
- const columnApi = params.columnApi;
1377
- hideColumn = (fieldToHide) => {
1378
- columnApi.setColumnsVisible([fieldToHide], false);
1379
- }
1380
- pinColumnToLeft = (fieldToPin) => {
1381
- const columnState = columnApi.getColumnState();
1382
- const columnIndex = columnState.findIndex(column => column.colId === fieldToPin);
1383
- if (columnIndex !== -1) {
1384
- for (let i = 0; i <= columnIndex; i++) {
1385
- columnState[i].pinned = 'left';
1386
- }
1387
- columnApi.applyColumnState({ state: columnState });
1388
- }
1389
- }
1390
- saveColumnStateToStorage = () => {
1391
- const columnState = columnApi.getColumnState();
1392
- const pageId = getPageId();
1393
- localStorage.setItem(`columnState_${pageId}`, JSON.stringify(columnState));
1394
- }
1395
- function restoreColumnState() {
1396
- const pageId = getPageId();
1397
- const savedColumnState = JSON.parse(localStorage.getItem(`columnState_${pageId}`));
1398
- if (savedColumnState) {
1399
- columnApi.applyColumnState({
1400
- state: savedColumnState,
1401
- applyOrder: true,
1402
- applyVisibility: true,
1403
- });
1404
- }
1405
- }
1406
- restoreColumnState();
1407
- },
1408
1411
  columnDefs: columnDefs,
1409
1412
  rowData: rowData,
1410
1413
  ...gridOptions
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdmx/wappler_ag_grid",
3
- "version": "1.2.9",
3
+ "version": "1.3.1",
4
4
  "type": "module",
5
5
  "description": "App Connect module for AG Grid Table Generation.",
6
6
  "license": "MIT",