@cdmx/wappler_ag_grid 2.0.14 → 2.0.16
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/app_connect/components.hjson +8 -0
- package/dmx-ag-grid.js +49 -9
- package/package.json +1 -1
|
@@ -253,6 +253,14 @@
|
|
|
253
253
|
"type": "text",
|
|
254
254
|
"help": "Specifies fields to be excluded in CSV export (comma-seperated)."
|
|
255
255
|
},
|
|
256
|
+
{
|
|
257
|
+
"name": "exportRemoveHtml",
|
|
258
|
+
"attribute": "dmx-bind:export_remove_html",
|
|
259
|
+
"title": "Remove HTML from Export",
|
|
260
|
+
"type": "boolean",
|
|
261
|
+
"defaultValue": false,
|
|
262
|
+
"help": "Removes HTML tags from exported data (CSV/PDF). Converts <br> tags to newlines."
|
|
263
|
+
},
|
|
256
264
|
{
|
|
257
265
|
"name": "paginationPageSizeSelector",
|
|
258
266
|
"attribute": "dmx-bind:pagination_page_size_selector",
|
package/dmx-ag-grid.js
CHANGED
|
@@ -87,6 +87,7 @@ dmx.Component('ag-grid', {
|
|
|
87
87
|
export_trim_data: { type: Boolean, default: false },
|
|
88
88
|
export_exclude_hidden_fields: { type: Boolean, default: false },
|
|
89
89
|
export_exclude_fields: { type: String, default: null },
|
|
90
|
+
export_remove_html: { type: Boolean, default: false },
|
|
90
91
|
export_to_csv: { type: Boolean, default: true },
|
|
91
92
|
export_csv_filename: { type: String, default: 'export.csv' },
|
|
92
93
|
export_to_pdf: { type: Boolean, default: false },
|
|
@@ -1312,6 +1313,8 @@ dmx.Component('ag-grid', {
|
|
|
1312
1313
|
const amountFieldsArray = options.amount_fields.split(',');
|
|
1313
1314
|
if (amountFieldsArray.includes(key)) {
|
|
1314
1315
|
valueFormatter = function (params) {
|
|
1316
|
+
const num = Number(params.value);
|
|
1317
|
+
if (isNaN(num)) return '-';
|
|
1315
1318
|
if (params.value != null) {
|
|
1316
1319
|
return Number(params.value).toLocaleString(options.date_locale, {
|
|
1317
1320
|
minimumFractionDigits: options.amount_field_precision,
|
|
@@ -1324,6 +1327,7 @@ dmx.Component('ag-grid', {
|
|
|
1324
1327
|
} else {
|
|
1325
1328
|
valueFormatter = blankOrNullValueFormatter;
|
|
1326
1329
|
}
|
|
1330
|
+
comparator = options.ci_sort ? caseInsensitiveComparator : undefined;
|
|
1327
1331
|
} else if (dataType === 'date') {
|
|
1328
1332
|
filter = 'agDateColumnFilter';
|
|
1329
1333
|
valueFormatter = (params) => formatTime(params, timezone);
|
|
@@ -2154,6 +2158,21 @@ dmx.Component('ag-grid', {
|
|
|
2154
2158
|
updateHoveringBarStyles();
|
|
2155
2159
|
|
|
2156
2160
|
//CSV Export Function
|
|
2161
|
+
// Helper function to remove HTML tags from string
|
|
2162
|
+
const removeHtmlTags = (htmlString) => {
|
|
2163
|
+
if (typeof htmlString !== 'string') return htmlString;
|
|
2164
|
+
// Remove all HTML tags and decode common HTML entities
|
|
2165
|
+
return htmlString
|
|
2166
|
+
.replace(/<br\s*\/?>/gi, '\n') // Replace <br> tags with newlines
|
|
2167
|
+
.replace(/<[^>]*>/g, '') // Remove all other HTML tags
|
|
2168
|
+
.replace(/ /g, ' ') // Replace non-breaking space
|
|
2169
|
+
.replace(/</g, '<')
|
|
2170
|
+
.replace(/>/g, '>')
|
|
2171
|
+
.replace(/&/g, '&')
|
|
2172
|
+
.replace(/"/g, '"')
|
|
2173
|
+
.replace(/'/g, "'");
|
|
2174
|
+
};
|
|
2175
|
+
|
|
2157
2176
|
exportGridData = (currentGridInstance, currentGridConfig) => {
|
|
2158
2177
|
const excludedColumnIds = ['checkboxColumn', 'actionsColumn'];
|
|
2159
2178
|
const exportExcludeFieldsArray = options.export_exclude_fields ? options.export_exclude_fields.split(',') : [];
|
|
@@ -2287,6 +2306,11 @@ dmx.Component('ag-grid', {
|
|
|
2287
2306
|
}
|
|
2288
2307
|
}
|
|
2289
2308
|
|
|
2309
|
+
// Remove HTML tags if export_remove_html is true
|
|
2310
|
+
if (options.export_remove_html && typeof value === 'string') {
|
|
2311
|
+
value = removeHtmlTags(value);
|
|
2312
|
+
}
|
|
2313
|
+
|
|
2290
2314
|
// Trim value if export_trim is true
|
|
2291
2315
|
if (options.export_trim_data && typeof value === 'string') {
|
|
2292
2316
|
return value.trim();
|
|
@@ -2446,12 +2470,19 @@ dmx.Component('ag-grid', {
|
|
|
2446
2470
|
cnames[field].custom_name :
|
|
2447
2471
|
humanize(field)
|
|
2448
2472
|
) : '';
|
|
2473
|
+
let cellValue = !isHeader ? (
|
|
2474
|
+
(colDef.cellRenderer && typeof colDef.cellRenderer === 'function') ? colDef.cellRenderer(params) :
|
|
2475
|
+
(colDef.valueFormatter && typeof colDef.valueFormatter === 'function') ? colDef.valueFormatter(params) :
|
|
2476
|
+
gInstance.getValue(column, gInstance.getDisplayedRowAtIndex(0)) ?? ''
|
|
2477
|
+
) : headerName;
|
|
2478
|
+
|
|
2479
|
+
// Remove HTML tags if export_remove_html is true
|
|
2480
|
+
if (options.export_remove_html && typeof cellValue === 'string') {
|
|
2481
|
+
cellValue = removeHtmlTags(cellValue);
|
|
2482
|
+
}
|
|
2483
|
+
|
|
2449
2484
|
return {
|
|
2450
|
-
text:
|
|
2451
|
-
(colDef.cellRenderer && typeof colDef.cellRenderer === 'function') ? colDef.cellRenderer(params) :
|
|
2452
|
-
(colDef.valueFormatter && typeof colDef.valueFormatter === 'function') ? colDef.valueFormatter(params) :
|
|
2453
|
-
gInstance.getValue(column, gInstance.getDisplayedRowAtIndex(0)) ?? ''
|
|
2454
|
-
) : headerName,
|
|
2485
|
+
text: cellValue,
|
|
2455
2486
|
color: cellStyle?.color ?? 'black',
|
|
2456
2487
|
fillColor: cellStyle?.backgroundColor ? cellStyle.backgroundColor.replace('#', '') : undefined,
|
|
2457
2488
|
};
|
|
@@ -2474,11 +2505,20 @@ dmx.Component('ag-grid', {
|
|
|
2474
2505
|
api: currentGridInstance,
|
|
2475
2506
|
};
|
|
2476
2507
|
const cellStyle = applyCellStyle(params);
|
|
2477
|
-
|
|
2508
|
+
let value = currentGridInstance.getCellValue({ rowNode: node, colKey: col.colId }) ?? '-';
|
|
2509
|
+
|
|
2510
|
+
// Get the rendered value
|
|
2511
|
+
let displayValue = (colDef.cellRenderer && typeof colDef.cellRenderer === 'function') ? colDef.cellRenderer(params) :
|
|
2512
|
+
(colDef.valueFormatter && typeof colDef.valueFormatter === 'function') ? colDef.valueFormatter(params) :
|
|
2513
|
+
value;
|
|
2514
|
+
|
|
2515
|
+
// Remove HTML tags if export_remove_html is true
|
|
2516
|
+
if (options.export_remove_html && typeof displayValue === 'string') {
|
|
2517
|
+
displayValue = removeHtmlTags(displayValue);
|
|
2518
|
+
}
|
|
2519
|
+
|
|
2478
2520
|
return {
|
|
2479
|
-
text:
|
|
2480
|
-
(colDef.valueFormatter && typeof colDef.valueFormatter === 'function') ? colDef.valueFormatter(params) :
|
|
2481
|
-
value,
|
|
2521
|
+
text: displayValue,
|
|
2482
2522
|
color: cellStyle?.color ?? 'black',
|
|
2483
2523
|
fillColor: cellStyle?.backgroundColor ? cellStyle.backgroundColor.replace('#', '') : undefined,
|
|
2484
2524
|
};
|
package/package.json
CHANGED