@cdmx/wappler_ag_grid 1.5.2 → 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.
- package/app_connect/components.hjson +12 -1
- package/dmx-ag-grid.js +23 -16
- package/package.json +1 -1
|
@@ -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
|
-
|
|
250
|
-
|
|
251
|
-
|
|
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
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
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
|
-
|
|
278
|
-
gridInstance.refreshCells();
|
|
284
|
+
gridInstance.applyTransaction(transaction);
|
|
285
|
+
// gridInstance.refreshCells();
|
|
279
286
|
} else {
|
|
280
|
-
|
|
287
|
+
return;
|
|
281
288
|
}
|
|
282
289
|
},
|
|
283
290
|
parseFileData: async function (fieldId) {
|