@cdmx/wappler_ag_grid 0.8.2 → 0.8.4
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 +36 -0
- package/dmx-ag-grid.js +61 -3
- 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,42 @@
|
|
|
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
|
+
"columnsToSum"
|
|
1157
|
+
],
|
|
1158
|
+
"noChangeOnHide": true,
|
|
1159
|
+
"groupEnabler": true,
|
|
1160
|
+
"help": "Define the Columns to Count and Sum in the Footer row"
|
|
1161
|
+
"children": [
|
|
1162
|
+
{
|
|
1163
|
+
"name": "columnsToCount",
|
|
1164
|
+
"attribute": "columns_to_count",
|
|
1165
|
+
"title": "Columns To Count",
|
|
1166
|
+
"type": "text",
|
|
1167
|
+
"initDisplay": "none"
|
|
1168
|
+
},
|
|
1169
|
+
{
|
|
1170
|
+
"name": "columnsToSum",
|
|
1171
|
+
"attribute": "columns_to_sum",
|
|
1172
|
+
"title": "Columns To Sum",
|
|
1173
|
+
"type": "text",
|
|
1174
|
+
"initDisplay": "none"
|
|
1175
|
+
}
|
|
1176
|
+
]
|
|
1177
|
+
}
|
|
1178
|
+
]
|
|
1179
|
+
},
|
|
1144
1180
|
{
|
|
1145
1181
|
"group": "📒 Configure Actions Column",
|
|
1146
1182
|
"variables": [
|
package/dmx-ag-grid.js
CHANGED
|
@@ -140,7 +140,9 @@ 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
|
+
columns_to_sum: { type: String, default: null }
|
|
144
146
|
},
|
|
145
147
|
|
|
146
148
|
methods: {
|
|
@@ -351,11 +353,16 @@ dmx.Component('ag-grid', {
|
|
|
351
353
|
if (params.value == null) {
|
|
352
354
|
return "-";
|
|
353
355
|
}
|
|
354
|
-
|
|
355
356
|
if (typeof params.value === "string") {
|
|
356
357
|
return params.value.trim() === "" ? "-" : params.value;
|
|
357
358
|
}
|
|
358
|
-
|
|
359
|
+
if (typeof params.value === "object") {
|
|
360
|
+
try {
|
|
361
|
+
return JSON.stringify(params.value);
|
|
362
|
+
} catch (error) {
|
|
363
|
+
return "Object cannot be stringified";
|
|
364
|
+
}
|
|
365
|
+
}
|
|
359
366
|
return params.value;
|
|
360
367
|
}
|
|
361
368
|
function formatDate(timestamp) {
|
|
@@ -995,6 +1002,42 @@ dmx.Component('ag-grid', {
|
|
|
995
1002
|
actionsRenderer: actionsRenderer
|
|
996
1003
|
}
|
|
997
1004
|
};
|
|
1005
|
+
const totalRow = function (api, columnsToSum, columnsToCount) {
|
|
1006
|
+
if (!columnsToSum && !columnsToCount) {
|
|
1007
|
+
return;
|
|
1008
|
+
}
|
|
1009
|
+
let rowData = [];
|
|
1010
|
+
api.forEachNodeAfterFilter(node => {
|
|
1011
|
+
rowData.push({ "data": node.data, "index": node.childIndex });
|
|
1012
|
+
});
|
|
1013
|
+
let result = [{}];
|
|
1014
|
+
|
|
1015
|
+
if (columnsToSum) {
|
|
1016
|
+
// Initialize and calculate sum columns
|
|
1017
|
+
columnsToSum.forEach(function (col) {
|
|
1018
|
+
result[0][col] = 0;
|
|
1019
|
+
rowData.forEach(function (line) {
|
|
1020
|
+
if (line.index < rowData.length) {
|
|
1021
|
+
result[0][col] += parseFloat(line.data[col]) || line.data[col];
|
|
1022
|
+
}
|
|
1023
|
+
});
|
|
1024
|
+
});
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
if (columnsToCount) {
|
|
1028
|
+
// Initialize and calculate count columns
|
|
1029
|
+
columnsToCount.forEach(function (col) {
|
|
1030
|
+
result[0][col] = 0;
|
|
1031
|
+
rowData.forEach(function (line) {
|
|
1032
|
+
if (line.index < rowData.length) {
|
|
1033
|
+
result[0][col]++;
|
|
1034
|
+
}
|
|
1035
|
+
});
|
|
1036
|
+
});
|
|
1037
|
+
}
|
|
1038
|
+
api.setPinnedBottomRowData(result);
|
|
1039
|
+
}
|
|
1040
|
+
|
|
998
1041
|
const gridDiv = document.getElementById(options.id+'-grid');
|
|
999
1042
|
|
|
1000
1043
|
|
|
@@ -1012,6 +1055,21 @@ dmx.Component('ag-grid', {
|
|
|
1012
1055
|
rowData: rowData,
|
|
1013
1056
|
...gridOptions
|
|
1014
1057
|
};
|
|
1058
|
+
// 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)) {
|
|
1060
|
+
let columnsToSum = options.columns_to_sum ? options.columns_to_sum.split(',') : [];
|
|
1061
|
+
let columnsToCount = options.columns_to_count ? options.columns_to_count.split(',') : [];
|
|
1062
|
+
|
|
1063
|
+
gridConfig.onFilterChanged = function (e) {
|
|
1064
|
+
totalRow(e.api, columnsToSum, columnsToCount);
|
|
1065
|
+
};
|
|
1066
|
+
gridConfig.onFirstDataRendered = function (e) {
|
|
1067
|
+
totalRow(e.api, columnsToSum, columnsToCount);
|
|
1068
|
+
};
|
|
1069
|
+
gridConfig.postSortRows = function (e) {
|
|
1070
|
+
totalRow(e.api, columnsToSum, columnsToCount);
|
|
1071
|
+
};
|
|
1072
|
+
}
|
|
1015
1073
|
// Create ag-Grid instance
|
|
1016
1074
|
gridInstance = new agGrid.Grid(gridDiv, gridConfig);
|
|
1017
1075
|
const gridElement = document.getElementById(options.id+'-grid');
|