@cdmx/wappler_ag_grid 0.8.4 → 0.8.6

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.
@@ -1159,12 +1159,35 @@
1159
1159
  "groupEnabler": true,
1160
1160
  "help": "Define the Columns to Count and Sum in the Footer row"
1161
1161
  "children": [
1162
- {
1163
- "name": "columnsToCount",
1164
- "attribute": "columns_to_count",
1165
- "title": "Columns To Count",
1166
- "type": "text",
1167
- "initDisplay": "none"
1162
+ {
1163
+ "name": "columnsToCount",
1164
+ "attribute": "columns_to_count",
1165
+ "title": "Columns to Count",
1166
+ "type": "grid",
1167
+ "jsonFormat": true,
1168
+ "encloseBT": true,
1169
+ "jsonBT": true,
1170
+ "initDisplay": "none",
1171
+ "columns": [
1172
+ {
1173
+ "field": "field",
1174
+ "caption": "Field",
1175
+ "editable": {
1176
+ "type": "text"
1177
+ }
1178
+ },
1179
+ {
1180
+ field: "unique_values",
1181
+ caption: "Unique Values",
1182
+ editable: {
1183
+ type: "text"
1184
+ }
1185
+ }
1186
+ ],
1187
+ "newRecord": {
1188
+ "field": "",
1189
+ "unique_values": ""
1190
+ }
1168
1191
  },
1169
1192
  {
1170
1193
  "name": "columnsToSum",
package/dmx-ag-grid.js CHANGED
@@ -141,7 +141,7 @@ dmx.Component('ag-grid', {
141
141
  compact_view_grid_size: { type: Number, default: 3 },
142
142
  compact_view_item_height: { type: Number, default: 20 },
143
143
  group_config: { type: Array, default: [] },
144
- columns_to_count: { type: String, default: null },
144
+ columns_to_count: { type: Array, default: [] },
145
145
  columns_to_sum: { type: String, default: null }
146
146
  },
147
147
 
@@ -1025,14 +1025,24 @@ dmx.Component('ag-grid', {
1025
1025
  }
1026
1026
 
1027
1027
  if (columnsToCount) {
1028
- // Initialize and calculate count columns
1029
- columnsToCount.forEach(function (col) {
1028
+ columnsToCount.forEach(function (colObj) {
1029
+ const col = colObj.field;
1030
+ const uniqueValuesToCount = colObj.unique_values.split(',');
1031
+
1030
1032
  result[0][col] = 0;
1033
+ let uniqueValues = new Set();
1034
+
1031
1035
  rowData.forEach(function (line) {
1032
1036
  if (line.index < rowData.length) {
1033
- result[0][col]++;
1037
+ const value = line.data[col];
1038
+ if (uniqueValuesToCount.includes(value) && !uniqueValues.has(value)) {
1039
+ uniqueValues.add(value);
1040
+ result[0][col]++;
1041
+ }
1034
1042
  }
1035
1043
  });
1044
+
1045
+ result[0][col + '_unique_count'] = uniqueValues.size;
1036
1046
  });
1037
1047
  }
1038
1048
  api.setPinnedBottomRowData(result);
@@ -1056,9 +1066,9 @@ dmx.Component('ag-grid', {
1056
1066
  ...gridOptions
1057
1067
  };
1058
1068
  // Conditionally add event listeners based on whether columnsToSum or columnsToCount are defined
1059
- if ((options.columns_to_sum && options.columns_to_sum.split(',').length > 0) || (options.columns_to_count && options.columns_to_count.split(',').length > 0)) {
1069
+ if ((options.columns_to_sum && options.columns_to_sum.split(',').length > 0) || (options.columns_to_count.length > 0)) {
1060
1070
  let columnsToSum = options.columns_to_sum ? options.columns_to_sum.split(',') : [];
1061
- let columnsToCount = options.columns_to_count ? options.columns_to_count.split(',') : [];
1071
+ let columnsToCount = options.columns_to_count;
1062
1072
 
1063
1073
  gridConfig.onFilterChanged = function (e) {
1064
1074
  totalRow(e.api, columnsToSum, columnsToCount);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdmx/wappler_ag_grid",
3
- "version": "0.8.4",
3
+ "version": "0.8.6",
4
4
  "type": "module",
5
5
  "description": "App Connect module for AG Grid Table Generation.",
6
6
  "license": "MIT",