@cdmx/wappler_ag_grid 0.8.4 → 0.8.5

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.
@@ -1153,6 +1153,7 @@
1153
1153
  "display": "fieldset",
1154
1154
  "show": [
1155
1155
  "columnsToCount",
1156
+ "columnValueMatchCount",
1156
1157
  "columnsToSum"
1157
1158
  ],
1158
1159
  "noChangeOnHide": true,
@@ -1166,6 +1167,13 @@
1166
1167
  "type": "text",
1167
1168
  "initDisplay": "none"
1168
1169
  },
1170
+ {
1171
+ "name": "columnValueMatchCount",
1172
+ "attribute": "column_value_match_count",
1173
+ "title": "Unique Value To Count",
1174
+ "type": "text",
1175
+ "initDisplay": "none"
1176
+ },
1169
1177
  {
1170
1178
  "name": "columnsToSum",
1171
1179
  "attribute": "columns_to_sum",
package/dmx-ag-grid.js CHANGED
@@ -142,6 +142,7 @@ dmx.Component('ag-grid', {
142
142
  compact_view_item_height: { type: Number, default: 20 },
143
143
  group_config: { type: Array, default: [] },
144
144
  columns_to_count: { type: String, default: null },
145
+ column_value_match_count: { type: String, default: null },
145
146
  columns_to_sum: { type: String, default: null }
146
147
  },
147
148
 
@@ -1002,7 +1003,7 @@ dmx.Component('ag-grid', {
1002
1003
  actionsRenderer: actionsRenderer
1003
1004
  }
1004
1005
  };
1005
- const totalRow = function (api, columnsToSum, columnsToCount) {
1006
+ const totalRow = function (api, columnsToSum, columnsToCount, columnValueMatchCount) {
1006
1007
  if (!columnsToSum && !columnsToCount) {
1007
1008
  return;
1008
1009
  }
@@ -1025,16 +1026,38 @@ dmx.Component('ag-grid', {
1025
1026
  }
1026
1027
 
1027
1028
  if (columnsToCount) {
1029
+ if (columnValueMatchCount) {
1030
+ // Count unique entries for a specific column
1031
+ columnsToCount.forEach(function (col) {
1032
+ result[0][col] = 0;
1033
+ rowData.forEach(function (line) {
1034
+ if (line.index < rowData.length) {
1035
+ const value = line.data[col];
1036
+ if (value == columnValueMatchCount) {
1037
+ result[0][col]++;
1038
+ }
1039
+ }
1040
+ });
1041
+ });
1042
+ }
1043
+ else {
1028
1044
  // Initialize and calculate count columns
1029
1045
  columnsToCount.forEach(function (col) {
1030
1046
  result[0][col] = 0;
1047
+ let uniqueValues = new Set();
1031
1048
  rowData.forEach(function (line) {
1032
1049
  if (line.index < rowData.length) {
1033
- result[0][col]++;
1050
+ const value = line.data[col];
1051
+ if (!uniqueValues.has(value)) {
1052
+ uniqueValues.add(value);
1053
+ result[0][col]++;
1054
+ }
1034
1055
  }
1035
1056
  });
1057
+ result[0][col + '_unique_count'] = uniqueValues.size;
1036
1058
  });
1037
1059
  }
1060
+ }
1038
1061
  api.setPinnedBottomRowData(result);
1039
1062
  }
1040
1063
 
@@ -1059,15 +1082,16 @@ dmx.Component('ag-grid', {
1059
1082
  if ((options.columns_to_sum && options.columns_to_sum.split(',').length > 0) || (options.columns_to_count && options.columns_to_count.split(',').length > 0)) {
1060
1083
  let columnsToSum = options.columns_to_sum ? options.columns_to_sum.split(',') : [];
1061
1084
  let columnsToCount = options.columns_to_count ? options.columns_to_count.split(',') : [];
1085
+ let columnValueMatchCount = options.column_value_match_count
1062
1086
 
1063
1087
  gridConfig.onFilterChanged = function (e) {
1064
- totalRow(e.api, columnsToSum, columnsToCount);
1088
+ totalRow(e.api, columnsToSum, columnsToCount, columnValueMatchCount);
1065
1089
  };
1066
1090
  gridConfig.onFirstDataRendered = function (e) {
1067
- totalRow(e.api, columnsToSum, columnsToCount);
1091
+ totalRow(e.api, columnsToSum, columnsToCount, columnValueMatchCount);
1068
1092
  };
1069
1093
  gridConfig.postSortRows = function (e) {
1070
- totalRow(e.api, columnsToSum, columnsToCount);
1094
+ totalRow(e.api, columnsToSum, columnsToCount,columnValueMatchCount);
1071
1095
  };
1072
1096
  }
1073
1097
  // Create ag-Grid instance
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.5",
4
4
  "type": "module",
5
5
  "description": "App Connect module for AG Grid Table Generation.",
6
6
  "license": "MIT",