@cdmx/wappler_ag_grid 0.8.3 → 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.
- package/README.md +10 -0
- package/app_connect/components.hjson +44 -0
- package/dmx-ag-grid.js +78 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -186,6 +186,16 @@ These configurations help you create organized and logical groupings of columns
|
|
|
186
186
|
|
|
187
187
|
---
|
|
188
188
|
|
|
189
|
+
### Total Row Footer
|
|
190
|
+
|
|
191
|
+
The "Total Row Footer" feature allows you to define and display a footer row in a grid or table that shows the totals and counts of specified columns. This can be helpful for summarizing data in your grid and providing users with a quick overview of important statistics.
|
|
192
|
+
|
|
193
|
+
Configuration includes:
|
|
194
|
+
- **Columns To Count**: Specify the columns you want to count in the footer row. Separate column names with commas.
|
|
195
|
+
- **Columns To Sum**: Specify the columns you want to calculate the sum of in the footer row. Separate column names with commas.
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
189
199
|
# Configure Actions Column
|
|
190
200
|
The Configure Actions Column feature allows you to configure actions for the buttons in the Actions Column.
|
|
191
201
|
|
|
@@ -1141,6 +1141,50 @@
|
|
|
1141
1141
|
}
|
|
1142
1142
|
]
|
|
1143
1143
|
},
|
|
1144
|
+
{
|
|
1145
|
+
"group": "📒 Total Row Footer",
|
|
1146
|
+
"variables": [
|
|
1147
|
+
{
|
|
1148
|
+
"name": "totalRowFooter",
|
|
1149
|
+
"title": "Total Row Footer",
|
|
1150
|
+
"attribute": "total_row_footer",
|
|
1151
|
+
"type": "boolean",
|
|
1152
|
+
"defaultValue": false,
|
|
1153
|
+
"display": "fieldset",
|
|
1154
|
+
"show": [
|
|
1155
|
+
"columnsToCount",
|
|
1156
|
+
"columnValueMatchCount",
|
|
1157
|
+
"columnsToSum"
|
|
1158
|
+
],
|
|
1159
|
+
"noChangeOnHide": true,
|
|
1160
|
+
"groupEnabler": true,
|
|
1161
|
+
"help": "Define the Columns to Count and Sum in the Footer row"
|
|
1162
|
+
"children": [
|
|
1163
|
+
{
|
|
1164
|
+
"name": "columnsToCount",
|
|
1165
|
+
"attribute": "columns_to_count",
|
|
1166
|
+
"title": "Columns To Count",
|
|
1167
|
+
"type": "text",
|
|
1168
|
+
"initDisplay": "none"
|
|
1169
|
+
},
|
|
1170
|
+
{
|
|
1171
|
+
"name": "columnValueMatchCount",
|
|
1172
|
+
"attribute": "column_value_match_count",
|
|
1173
|
+
"title": "Unique Value To Count",
|
|
1174
|
+
"type": "text",
|
|
1175
|
+
"initDisplay": "none"
|
|
1176
|
+
},
|
|
1177
|
+
{
|
|
1178
|
+
"name": "columnsToSum",
|
|
1179
|
+
"attribute": "columns_to_sum",
|
|
1180
|
+
"title": "Columns To Sum",
|
|
1181
|
+
"type": "text",
|
|
1182
|
+
"initDisplay": "none"
|
|
1183
|
+
}
|
|
1184
|
+
]
|
|
1185
|
+
}
|
|
1186
|
+
]
|
|
1187
|
+
},
|
|
1144
1188
|
{
|
|
1145
1189
|
"group": "📒 Configure Actions Column",
|
|
1146
1190
|
"variables": [
|
package/dmx-ag-grid.js
CHANGED
|
@@ -140,7 +140,10 @@ dmx.Component('ag-grid', {
|
|
|
140
140
|
compact_view: { type: Boolean, default: false },
|
|
141
141
|
compact_view_grid_size: { type: Number, default: 3 },
|
|
142
142
|
compact_view_item_height: { type: Number, default: 20 },
|
|
143
|
-
group_config: { type: Array, default: [] }
|
|
143
|
+
group_config: { type: Array, default: [] },
|
|
144
|
+
columns_to_count: { type: String, default: null },
|
|
145
|
+
column_value_match_count: { type: String, default: null },
|
|
146
|
+
columns_to_sum: { type: String, default: null }
|
|
144
147
|
},
|
|
145
148
|
|
|
146
149
|
methods: {
|
|
@@ -1000,6 +1003,64 @@ dmx.Component('ag-grid', {
|
|
|
1000
1003
|
actionsRenderer: actionsRenderer
|
|
1001
1004
|
}
|
|
1002
1005
|
};
|
|
1006
|
+
const totalRow = function (api, columnsToSum, columnsToCount, columnValueMatchCount) {
|
|
1007
|
+
if (!columnsToSum && !columnsToCount) {
|
|
1008
|
+
return;
|
|
1009
|
+
}
|
|
1010
|
+
let rowData = [];
|
|
1011
|
+
api.forEachNodeAfterFilter(node => {
|
|
1012
|
+
rowData.push({ "data": node.data, "index": node.childIndex });
|
|
1013
|
+
});
|
|
1014
|
+
let result = [{}];
|
|
1015
|
+
|
|
1016
|
+
if (columnsToSum) {
|
|
1017
|
+
// Initialize and calculate sum columns
|
|
1018
|
+
columnsToSum.forEach(function (col) {
|
|
1019
|
+
result[0][col] = 0;
|
|
1020
|
+
rowData.forEach(function (line) {
|
|
1021
|
+
if (line.index < rowData.length) {
|
|
1022
|
+
result[0][col] += parseFloat(line.data[col]) || line.data[col];
|
|
1023
|
+
}
|
|
1024
|
+
});
|
|
1025
|
+
});
|
|
1026
|
+
}
|
|
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 {
|
|
1044
|
+
// Initialize and calculate count columns
|
|
1045
|
+
columnsToCount.forEach(function (col) {
|
|
1046
|
+
result[0][col] = 0;
|
|
1047
|
+
let uniqueValues = new Set();
|
|
1048
|
+
rowData.forEach(function (line) {
|
|
1049
|
+
if (line.index < rowData.length) {
|
|
1050
|
+
const value = line.data[col];
|
|
1051
|
+
if (!uniqueValues.has(value)) {
|
|
1052
|
+
uniqueValues.add(value);
|
|
1053
|
+
result[0][col]++;
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
});
|
|
1057
|
+
result[0][col + '_unique_count'] = uniqueValues.size;
|
|
1058
|
+
});
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
api.setPinnedBottomRowData(result);
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1003
1064
|
const gridDiv = document.getElementById(options.id+'-grid');
|
|
1004
1065
|
|
|
1005
1066
|
|
|
@@ -1017,6 +1078,22 @@ dmx.Component('ag-grid', {
|
|
|
1017
1078
|
rowData: rowData,
|
|
1018
1079
|
...gridOptions
|
|
1019
1080
|
};
|
|
1081
|
+
// Conditionally add event listeners based on whether columnsToSum or columnsToCount are defined
|
|
1082
|
+
if ((options.columns_to_sum && options.columns_to_sum.split(',').length > 0) || (options.columns_to_count && options.columns_to_count.split(',').length > 0)) {
|
|
1083
|
+
let columnsToSum = options.columns_to_sum ? options.columns_to_sum.split(',') : [];
|
|
1084
|
+
let columnsToCount = options.columns_to_count ? options.columns_to_count.split(',') : [];
|
|
1085
|
+
let columnValueMatchCount = options.column_value_match_count
|
|
1086
|
+
|
|
1087
|
+
gridConfig.onFilterChanged = function (e) {
|
|
1088
|
+
totalRow(e.api, columnsToSum, columnsToCount, columnValueMatchCount);
|
|
1089
|
+
};
|
|
1090
|
+
gridConfig.onFirstDataRendered = function (e) {
|
|
1091
|
+
totalRow(e.api, columnsToSum, columnsToCount, columnValueMatchCount);
|
|
1092
|
+
};
|
|
1093
|
+
gridConfig.postSortRows = function (e) {
|
|
1094
|
+
totalRow(e.api, columnsToSum, columnsToCount,columnValueMatchCount);
|
|
1095
|
+
};
|
|
1096
|
+
}
|
|
1020
1097
|
// Create ag-Grid instance
|
|
1021
1098
|
gridInstance = new agGrid.Grid(gridDiv, gridConfig);
|
|
1022
1099
|
const gridElement = document.getElementById(options.id+'-grid');
|