@cdmx/wappler_ag_grid 2.0.14 → 2.0.15
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 +46 -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 },
|
|
@@ -2154,6 +2155,21 @@ dmx.Component('ag-grid', {
|
|
|
2154
2155
|
updateHoveringBarStyles();
|
|
2155
2156
|
|
|
2156
2157
|
//CSV Export Function
|
|
2158
|
+
// Helper function to remove HTML tags from string
|
|
2159
|
+
const removeHtmlTags = (htmlString) => {
|
|
2160
|
+
if (typeof htmlString !== 'string') return htmlString;
|
|
2161
|
+
// Remove all HTML tags and decode common HTML entities
|
|
2162
|
+
return htmlString
|
|
2163
|
+
.replace(/<br\s*\/?>/gi, '\n') // Replace <br> tags with newlines
|
|
2164
|
+
.replace(/<[^>]*>/g, '') // Remove all other HTML tags
|
|
2165
|
+
.replace(/ /g, ' ') // Replace non-breaking space
|
|
2166
|
+
.replace(/</g, '<')
|
|
2167
|
+
.replace(/>/g, '>')
|
|
2168
|
+
.replace(/&/g, '&')
|
|
2169
|
+
.replace(/"/g, '"')
|
|
2170
|
+
.replace(/'/g, "'");
|
|
2171
|
+
};
|
|
2172
|
+
|
|
2157
2173
|
exportGridData = (currentGridInstance, currentGridConfig) => {
|
|
2158
2174
|
const excludedColumnIds = ['checkboxColumn', 'actionsColumn'];
|
|
2159
2175
|
const exportExcludeFieldsArray = options.export_exclude_fields ? options.export_exclude_fields.split(',') : [];
|
|
@@ -2287,6 +2303,11 @@ dmx.Component('ag-grid', {
|
|
|
2287
2303
|
}
|
|
2288
2304
|
}
|
|
2289
2305
|
|
|
2306
|
+
// Remove HTML tags if export_remove_html is true
|
|
2307
|
+
if (options.export_remove_html && typeof value === 'string') {
|
|
2308
|
+
value = removeHtmlTags(value);
|
|
2309
|
+
}
|
|
2310
|
+
|
|
2290
2311
|
// Trim value if export_trim is true
|
|
2291
2312
|
if (options.export_trim_data && typeof value === 'string') {
|
|
2292
2313
|
return value.trim();
|
|
@@ -2446,12 +2467,19 @@ dmx.Component('ag-grid', {
|
|
|
2446
2467
|
cnames[field].custom_name :
|
|
2447
2468
|
humanize(field)
|
|
2448
2469
|
) : '';
|
|
2470
|
+
let cellValue = !isHeader ? (
|
|
2471
|
+
(colDef.cellRenderer && typeof colDef.cellRenderer === 'function') ? colDef.cellRenderer(params) :
|
|
2472
|
+
(colDef.valueFormatter && typeof colDef.valueFormatter === 'function') ? colDef.valueFormatter(params) :
|
|
2473
|
+
gInstance.getValue(column, gInstance.getDisplayedRowAtIndex(0)) ?? ''
|
|
2474
|
+
) : headerName;
|
|
2475
|
+
|
|
2476
|
+
// Remove HTML tags if export_remove_html is true
|
|
2477
|
+
if (options.export_remove_html && typeof cellValue === 'string') {
|
|
2478
|
+
cellValue = removeHtmlTags(cellValue);
|
|
2479
|
+
}
|
|
2480
|
+
|
|
2449
2481
|
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,
|
|
2482
|
+
text: cellValue,
|
|
2455
2483
|
color: cellStyle?.color ?? 'black',
|
|
2456
2484
|
fillColor: cellStyle?.backgroundColor ? cellStyle.backgroundColor.replace('#', '') : undefined,
|
|
2457
2485
|
};
|
|
@@ -2474,11 +2502,20 @@ dmx.Component('ag-grid', {
|
|
|
2474
2502
|
api: currentGridInstance,
|
|
2475
2503
|
};
|
|
2476
2504
|
const cellStyle = applyCellStyle(params);
|
|
2477
|
-
|
|
2505
|
+
let value = currentGridInstance.getCellValue({ rowNode: node, colKey: col.colId }) ?? '-';
|
|
2506
|
+
|
|
2507
|
+
// Get the rendered value
|
|
2508
|
+
let displayValue = (colDef.cellRenderer && typeof colDef.cellRenderer === 'function') ? colDef.cellRenderer(params) :
|
|
2509
|
+
(colDef.valueFormatter && typeof colDef.valueFormatter === 'function') ? colDef.valueFormatter(params) :
|
|
2510
|
+
value;
|
|
2511
|
+
|
|
2512
|
+
// Remove HTML tags if export_remove_html is true
|
|
2513
|
+
if (options.export_remove_html && typeof displayValue === 'string') {
|
|
2514
|
+
displayValue = removeHtmlTags(displayValue);
|
|
2515
|
+
}
|
|
2516
|
+
|
|
2478
2517
|
return {
|
|
2479
|
-
text:
|
|
2480
|
-
(colDef.valueFormatter && typeof colDef.valueFormatter === 'function') ? colDef.valueFormatter(params) :
|
|
2481
|
-
value,
|
|
2518
|
+
text: displayValue,
|
|
2482
2519
|
color: cellStyle?.color ?? 'black',
|
|
2483
2520
|
fillColor: cellStyle?.backgroundColor ? cellStyle.backgroundColor.replace('#', '') : undefined,
|
|
2484
2521
|
};
|
package/package.json
CHANGED