@cdmx/wappler_ag_grid 1.5.1 → 1.5.3

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.
@@ -2216,7 +2216,18 @@
2216
2216
  icon : 'fa fa-lg fa-sync',
2217
2217
  state : 'opened',
2218
2218
  help: 'Reload the AG Grid',
2219
- properties : []
2219
+ properties: [
2220
+ {
2221
+ group: 'Properties',
2222
+ variables: [
2223
+ {
2224
+ name: '1', optionName: '1', title: 'Load Grid', type: 'boolean',
2225
+ dataBindings: true, defaultValue: false, required: true,
2226
+ help: 'Load Gird if no data is available.'
2227
+ }
2228
+ ]
2229
+ }
2230
+ ]
2220
2231
  },
2221
2232
  {
2222
2233
  addTitle: 'Export',
package/dmx-ag-grid.js CHANGED
@@ -191,9 +191,9 @@ dmx.Component('ag-grid', {
191
191
  this.set('columnDefs', columnDefs);
192
192
  this.refreshGrid();
193
193
  },
194
- reloadGrid: function () {
194
+ reloadGrid: function (loadGridInstance) {
195
195
  dmx.nextTick(function() {
196
- this.transactionUpdate();
196
+ this.transactionUpdate(loadGridInstance);
197
197
  }, this);
198
198
  },
199
199
  loadGrid: function () {
@@ -244,11 +244,19 @@ dmx.Component('ag-grid', {
244
244
  }
245
245
  },
246
246
 
247
- transactionUpdate: function () {
247
+ transactionUpdate: async function (loadGridInstance) {
248
248
  // const oldRowData = this.get('oldData');
249
- const gridInstance = this.get('gridInstance');
250
- //const oldRowData = gridInstance.getModel().rowsToDisplay.map(row => row.data);
251
- // Retrieve old row data from the grid instance directly
249
+ var gridInstance = this.get('gridInstance');
250
+ if (!gridInstance) {
251
+ if (loadGridInstance) {
252
+ gridInstance = await this.refreshGrid();
253
+ await this.set('gridInstance', gridInstance);
254
+ }
255
+ else {
256
+ console.error('AG Grid instance not loaded.');
257
+ return;
258
+ }
259
+ }
252
260
  const oldRowData = [];
253
261
  gridInstance.forEachNode(node => {
254
262
  if (node.data) {
@@ -259,13 +267,12 @@ dmx.Component('ag-grid', {
259
267
  let transaction;
260
268
 
261
269
  if (oldRowData && oldRowData.length > 0) {
262
- const addedRows = newRowData.filter(newRow => !oldRowData.some(oldRow => newRow.id === oldRow.id));
263
- const removedRows = oldRowData.filter(oldRow => !newRowData.some(newRow => oldRow.id === newRow.id));
264
- const updatedRows = newRowData.filter(newRow => {
265
- const oldRow = oldRowData.find(old => old.id === newRow.id);
266
- return oldRow && JSON.stringify(oldRow) !== JSON.stringify(newRow);
267
- });
268
-
270
+ const addedRows = newRowData.filter(newRow => !oldRowData.some(oldRow => newRow.id === oldRow.id));
271
+ const removedRows = oldRowData.filter(oldRow => !newRowData.some(newRow => oldRow.id === newRow.id));
272
+ const updatedRows = newRowData.filter(newRow => {
273
+ const oldRow = oldRowData.find(old => old.id === newRow.id);
274
+ return oldRow && JSON.stringify(oldRow) !== JSON.stringify(newRow);
275
+ });
269
276
  // Apply transactional updates to AG Grid
270
277
  transaction = {
271
278
  add: addedRows,
@@ -274,10 +281,10 @@ dmx.Component('ag-grid', {
274
281
  };
275
282
  }
276
283
  if (gridInstance && transaction) {
277
- gridInstance.applyTransaction(transaction);
278
- gridInstance.refreshCells();
284
+ gridInstance.applyTransaction(transaction);
285
+ // gridInstance.refreshCells();
279
286
  } else {
280
- console.error('AG Grid instance or transaction not found.');
287
+ return;
281
288
  }
282
289
  },
283
290
  parseFileData: async function (fieldId) {
@@ -368,6 +375,8 @@ dmx.Component('ag-grid', {
368
375
  const cnames = this.props.cnames
369
376
  const cwidths = this.props.cwidths
370
377
  const ctypes = this.props.ctypes
378
+ let gridInstance = this.get('gridInstance') ? this.get('gridInstance') : null;
379
+ let pagination_page_size = gridInstance ? gridInstance.paginationGetPageSize() : this.props.pagination_page_size
371
380
  const enableRowClickEvent = this.props.row_click_event && !this.props.enable_actions && !this.props.row_checkbox_event;
372
381
  const enableRowDoubleClickEvent = this.props.row_double_click_event && !this.props.enable_actions && !this.props.row_checkbox_event;
373
382
  const enableCellClickEvent = this.props.row_click_event && (this.props.enable_actions || this.props.row_checkbox_event);
@@ -376,7 +385,6 @@ dmx.Component('ag-grid', {
376
385
  let columnDefs = [];
377
386
  let groupedColumnDefs = [];
378
387
  let exportToCSV = this.props.export_to_csv;
379
- let gridInstance = null;
380
388
  let cellRenderer;
381
389
  const gridThemeClass = options.dark_mode ? `${options.grid_theme}-dark` : options.grid_theme;
382
390
  this.$node.innerHTML = `<div id=${options.id}-grid class="${gridThemeClass}"></div>`;
@@ -1300,7 +1308,7 @@ dmx.Component('ag-grid', {
1300
1308
  suppressRowDeselection: this.props.suppress_row_deselection,
1301
1309
  pagination: this.props.pagination,
1302
1310
  paginationAutoPageSize: this.props.pagination_auto_page_size,
1303
- paginationPageSize: this.props.pagination_page_size,
1311
+ paginationPageSize: pagination_page_size,
1304
1312
  paginationPageSizeSelector: options.pagination_page_size_selector,
1305
1313
  rowHeight: this.props.row_height,
1306
1314
  headerHeight: this.props.header_height,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdmx/wappler_ag_grid",
3
- "version": "1.5.1",
3
+ "version": "1.5.3",
4
4
  "type": "module",
5
5
  "description": "App Connect module for AG Grid Table Generation.",
6
6
  "license": "MIT",