@cdmx/wappler_ag_grid 1.4.7 → 1.4.9

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 +16 -18
  2. package/package.json +1 -1
package/dmx-ag-grid.js CHANGED
@@ -1398,31 +1398,29 @@ dmx.Component('ag-grid', {
1398
1398
  });
1399
1399
  });
1400
1400
  }
1401
-
1402
1401
  if (columnsToCount) {
1403
1402
  columnsToCount.forEach(function (colObj) {
1404
1403
  const col = colObj.field;
1405
- const uniqueValuesToCount = colObj.unique_values.split(',');
1404
+ const uniqueValuesToCount = new Set(colObj.unique_values.split(','));
1406
1405
  result[0][col] = 0;
1407
- let uniqueValues = new Set();
1408
-
1406
+ const uniqueValues = new Set();
1407
+
1409
1408
  rowData.forEach(function (line) {
1410
- if (line.index < rowData.length) {
1411
- const value = line.data[col];
1412
- if (options.columns_to_count_nonunique) {
1413
- uniqueValues.add(value);
1414
- result[0][col]++;
1415
- }
1416
- else if (!isNaN(value) && uniqueValuesToCount.includes(value.toString()) && !uniqueValues.has(value)) {
1417
- uniqueValues.add(value);
1418
- result[0][col]++;
1419
- } else if (typeof value === 'string' && uniqueValuesToCount.includes(value) && !uniqueValues.has(value)) {
1420
- uniqueValues.add(value);
1409
+ const value = line.data[col];
1410
+ if (line.index < rowData.length && value !== undefined && value !== null) {
1411
+ const valueString = value.toString();
1412
+ if (options.columns_to_count_nonunique || uniqueValuesToCount.has(valueString)) {
1421
1413
  result[0][col]++;
1414
+ if (!uniqueValues.has(valueString)) {
1415
+ uniqueValues.add(valueString);
1416
+ }
1422
1417
  }
1423
1418
  }
1424
1419
  });
1425
-
1420
+
1421
+ if (options.columns_to_count_nonunique) {
1422
+ result[0][col] = uniqueValues.size;
1423
+ }
1426
1424
  result[0][col + '_unique_count'] = uniqueValues.size;
1427
1425
  });
1428
1426
  }
@@ -1455,14 +1453,14 @@ dmx.Component('ag-grid', {
1455
1453
  if ((options.columns_to_sum && options.columns_to_sum.split(',').length > 0) || (options.columns_to_count.length > 0)) {
1456
1454
  let columnsToSum = options.columns_to_sum ? options.columns_to_sum.split(',') : [];
1457
1455
  let columnsToCount = options.columns_to_count;
1458
-
1456
+
1459
1457
  gridConfig.onFilterChanged = function (e) {
1460
1458
  totalRow(e.api, columnsToSum, columnsToCount);
1461
1459
  };
1462
1460
  gridConfig.onFirstDataRendered = function (e) {
1463
1461
  totalRow(e.api, columnsToSum, columnsToCount);
1464
1462
  };
1465
- gridConfig.postSortRows = function (e) {
1463
+ gridConfig.postSortRows = function (e) {
1466
1464
  totalRow(e.api, columnsToSum, columnsToCount);
1467
1465
  };
1468
1466
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdmx/wappler_ag_grid",
3
- "version": "1.4.7",
3
+ "version": "1.4.9",
4
4
  "type": "module",
5
5
  "description": "App Connect module for AG Grid Table Generation.",
6
6
  "license": "MIT",