@cdmx/wappler_ag_grid 1.3.0 → 1.3.2

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.
Files changed (2) hide show
  1. package/dmx-ag-grid.js +42 -38
  2. package/package.json +1 -1
package/dmx-ag-grid.js CHANGED
@@ -242,7 +242,14 @@ dmx.Component('ag-grid', {
242
242
  transactionUpdate: function () {
243
243
  // const oldRowData = this.get('oldData');
244
244
  const gridInstance = this.get('gridInstance');
245
- 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
+ });
246
253
  const newRowData = this.props.data;
247
254
  let transaction;
248
255
 
@@ -261,8 +268,7 @@ dmx.Component('ag-grid', {
261
268
  update: updatedRows,
262
269
  };
263
270
  }
264
-
265
- if (gridInstance && gridInstance.gridOptions && transaction) {
271
+ if (gridInstance && transaction) {
266
272
  gridInstance.applyTransaction(transaction);
267
273
  gridInstance.refreshCells();
268
274
  } else {
@@ -742,7 +748,7 @@ dmx.Component('ag-grid', {
742
748
  hasText = true;
743
749
  } else if (!isNaN(Number(value)) && !(typeof value === "string")) {
744
750
  hasNumber = true;
745
- } else if (moment(value, moment.ISO_8601, true).isValid()) {
751
+ } else if ((new Date(value)).getTime() > 0) {
746
752
  hasDate = true;
747
753
  } else {
748
754
  hasText = true;
@@ -1281,7 +1287,38 @@ dmx.Component('ag-grid', {
1281
1287
  suppressPropertyNamesCheck: this.props.suppress_property_names_check,
1282
1288
  suppressRowDeselection: this.props.suppress_row_deselection,
1283
1289
  columnHoverHighlight: this.props.column_hover_highlight,
1284
- 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();
1285
1322
  this.set("state", { gridReady: true });
1286
1323
  },
1287
1324
  onFirstDataRendered: () => {
@@ -1371,39 +1408,6 @@ dmx.Component('ag-grid', {
1371
1408
  return uniqueId;
1372
1409
  };
1373
1410
  const gridConfig = {
1374
- onGridReady: function (params) {
1375
- const columnApi = params.columnApi;
1376
- hideColumn = (fieldToHide) => {
1377
- columnApi.setColumnsVisible([fieldToHide], false);
1378
- }
1379
- pinColumnToLeft = (fieldToPin) => {
1380
- const columnState = columnApi.getColumnState();
1381
- const columnIndex = columnState.findIndex(column => column.colId === fieldToPin);
1382
- if (columnIndex !== -1) {
1383
- for (let i = 0; i <= columnIndex; i++) {
1384
- columnState[i].pinned = 'left';
1385
- }
1386
- columnApi.applyColumnState({ state: columnState });
1387
- }
1388
- }
1389
- saveColumnStateToStorage = () => {
1390
- const columnState = columnApi.getColumnState();
1391
- const pageId = getPageId();
1392
- localStorage.setItem(`columnState_${pageId}`, JSON.stringify(columnState));
1393
- }
1394
- function restoreColumnState() {
1395
- const pageId = getPageId();
1396
- const savedColumnState = JSON.parse(localStorage.getItem(`columnState_${pageId}`));
1397
- if (savedColumnState) {
1398
- columnApi.applyColumnState({
1399
- state: savedColumnState,
1400
- applyOrder: true,
1401
- applyVisibility: true,
1402
- });
1403
- }
1404
- }
1405
- restoreColumnState();
1406
- },
1407
1411
  columnDefs: columnDefs,
1408
1412
  rowData: rowData,
1409
1413
  ...gridOptions
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdmx/wappler_ag_grid",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "type": "module",
5
5
  "description": "App Connect module for AG Grid Table Generation.",
6
6
  "license": "MIT",