@cdmx/wappler_ag_grid 2.0.21 → 2.1.1
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 +20 -55
- package/app_connect/components.hjson +56 -0
- package/dmx-ag-grid.js +240 -15
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -1,65 +1,30 @@
|
|
|
1
1
|
#### Developed and Maintained by: Roney Dsilva
|
|
2
2
|
|
|
3
|
-
**Major Update:** This release upgrades
|
|
3
|
+
**Major Update:** This release upgrades AG Grid to v35.1.0, bringing continued performance improvements and new features.
|
|
4
4
|
|
|
5
|
-
## 🚀 What's New in v2.0.
|
|
5
|
+
## 🚀 What's New in v2.0.23
|
|
6
6
|
|
|
7
|
-
1. **🔥 AG Grid
|
|
8
|
-
2. **⚡
|
|
7
|
+
1. **🔥 AG Grid v35.1.0** - Latest version with all community features
|
|
8
|
+
2. **⚡ Smooth Upgrade** - Non-breaking upgrade from v34, all existing configurations continue to work
|
|
9
9
|
3. **🎨 HTML Tooltips** - Rich HTML tooltip support with JavaScript functions
|
|
10
10
|
4. **🔧 Enhanced Tooltip System** - Custom tooltip components with automatic HTML detection
|
|
11
|
-
5. **🚫 Suppress Model Update** -
|
|
11
|
+
5. **🚫 Suppress Model Update** - Option to prevent automatic reprocessing after update transactions
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
## 🚀 What's New in AG Grid v34.1.0
|
|
16
|
-
|
|
17
|
-
### New Features Available in This Release:
|
|
18
|
-
|
|
19
|
-
1. **✅ Cell Editor Validation** - Built-in validation for all cell editors:
|
|
20
|
-
- Automatic constraint checking based on column configuration
|
|
21
|
-
- Override defaults with custom validation rules
|
|
22
|
-
- Handle invalid values by reverting or blocking changes
|
|
23
|
-
|
|
24
|
-
2. **🎯 Bulk Cell Editing** - Edit multiple cells in a single action:
|
|
25
|
-
- Select cells, enter new value, commit with Tab key
|
|
26
|
-
- Ideal for updating status of multiple items or overriding null values
|
|
27
|
-
|
|
28
|
-
3. **⚡ Performance Improvements** - Up to 40% bundle size reduction through:
|
|
29
|
-
- Modular architecture improvements
|
|
30
|
-
- Better tree-shaking capabilities
|
|
31
|
-
- Optimized loading times
|
|
32
|
-
|
|
33
|
-
4. **🎨 Enhanced Theming** - New Theming API for:
|
|
34
|
-
- Dynamic theme manipulation at runtime
|
|
35
|
-
- Better integration with Theme Builder
|
|
36
|
-
- Easy customization via theme parameters
|
|
37
|
-
|
|
38
|
-
## 🔄 Migration from v1.x to v2.0
|
|
13
|
+
## 🔄 Migration from v34 to v35
|
|
39
14
|
|
|
40
15
|
### Compatibility Notes:
|
|
41
|
-
- **Good News:** This upgrade is
|
|
16
|
+
- **Good News:** This upgrade is **non-breaking** for existing implementations
|
|
42
17
|
- Your existing grids should continue to work without changes
|
|
43
|
-
-
|
|
18
|
+
- No deprecated API removals in v35
|
|
19
|
+
|
|
20
|
+
### What Changed Internally:
|
|
21
|
+
- New automatic overlays for filtering and exporting are now suppressed by default to preserve existing overlay behavior
|
|
22
|
+
- Date/number filter range validation now enforces start < end
|
|
44
23
|
|
|
45
24
|
### Recommended Steps:
|
|
46
|
-
1. **Update Package:** Simply update to
|
|
25
|
+
1. **Update Package:** Simply update to the latest version - no code changes required
|
|
47
26
|
2. **Test Your Grids:** Verify existing grids work as expected
|
|
48
|
-
3. **
|
|
49
|
-
- Enable Cell Editor Validation for better data quality
|
|
50
|
-
- Try Batch/Bulk editing for improved user experience
|
|
51
|
-
- Use the new Filters Tool Panel for better UX
|
|
52
|
-
- Implement Tree Data Drag & Drop for hierarchical data
|
|
53
|
-
|
|
54
|
-
### Performance Benefits:
|
|
55
|
-
- **Bundle Size:** Potential 20-40% reduction in bundle size
|
|
56
|
-
- **Loading Speed:** Faster grid initialization
|
|
57
|
-
- **Memory Usage:** Improved memory efficiency
|
|
58
|
-
|
|
59
|
-
### Breaking Changes (Minimal):
|
|
60
|
-
- Some very old deprecated APIs (from v31 and earlier) have been removed
|
|
61
|
-
- If you customized AG Grid CSS extensively, test your styling
|
|
62
|
-
- The new Theming API is now default (but legacy CSS themes still work)
|
|
27
|
+
3. **Test Exports:** Verify CSV/PDF exports work correctly
|
|
63
28
|
|
|
64
29
|
# AG Grid Module Documentation
|
|
65
30
|
|
|
@@ -657,7 +622,7 @@ You can also specify left-only conditions, where only the field name is provided
|
|
|
657
622
|
- Useful for resetting the grid view or preparing for new filter configurations.
|
|
658
623
|
- Automatically clears the `filterState` property.
|
|
659
624
|
|
|
660
|
-
## 💡 Implementation Examples
|
|
625
|
+
## 💡 Implementation Examples
|
|
661
626
|
|
|
662
627
|
### Filter Management Examples
|
|
663
628
|
|
|
@@ -779,14 +744,14 @@ tree_data_drag_drop: true
|
|
|
779
744
|
// ]
|
|
780
745
|
```
|
|
781
746
|
|
|
782
|
-
## 🔧 Best Practices
|
|
747
|
+
## 🔧 Best Practices
|
|
783
748
|
|
|
784
|
-
1. **Performance:** Start with basic features and gradually enable
|
|
749
|
+
1. **Performance:** Start with basic features and gradually enable enhancements
|
|
785
750
|
2. **Testing:** Test new features in development before production deployment
|
|
786
|
-
3. **Bundle Size:** Monitor bundle size improvements with the
|
|
787
|
-
4. **User Experience:** Combine multiple
|
|
751
|
+
3. **Bundle Size:** Monitor bundle size improvements with the modular architecture
|
|
752
|
+
4. **User Experience:** Combine multiple features for enhanced workflows:
|
|
788
753
|
- Use Batch Editing + Validation for better data entry
|
|
789
|
-
- Combine
|
|
754
|
+
- Combine Filters Tool Panel with server-side data
|
|
790
755
|
- Use Tree Data + Drag & Drop for hierarchical management
|
|
791
756
|
|
|
792
757
|
## License
|
|
@@ -243,6 +243,14 @@
|
|
|
243
243
|
"defaultValue": false,
|
|
244
244
|
"help": "Specifies if Export to PDF to be enabled"
|
|
245
245
|
},
|
|
246
|
+
{
|
|
247
|
+
"name": "exportToXLS",
|
|
248
|
+
"attribute": "dmx-bind:export_to_xls",
|
|
249
|
+
"title": "XLS Export",
|
|
250
|
+
"type": "boolean",
|
|
251
|
+
"defaultValue": false,
|
|
252
|
+
"help": "Specifies if Export to XLS (Excel) to be enabled"
|
|
253
|
+
},
|
|
246
254
|
{
|
|
247
255
|
"name": "exportExcludeHidden",
|
|
248
256
|
"attribute": "dmx-bind:export_exclude_hidden_fields",
|
|
@@ -3700,6 +3708,11 @@
|
|
|
3700
3708
|
name: '2', optionName: '2', title: 'PDF', type: 'boolean',
|
|
3701
3709
|
dataBindings: true, defaultValue: false, required: false,
|
|
3702
3710
|
help: 'Export Grid data as PDF file.'
|
|
3711
|
+
},
|
|
3712
|
+
{
|
|
3713
|
+
name: '3', optionName: '3', title: 'XLS', type: 'boolean',
|
|
3714
|
+
dataBindings: true, defaultValue: false, required: false,
|
|
3715
|
+
help: 'Export Grid data as Excel (.xlsx) file.'
|
|
3703
3716
|
}
|
|
3704
3717
|
]
|
|
3705
3718
|
}
|
|
@@ -3911,6 +3924,10 @@
|
|
|
3911
3924
|
{
|
|
3912
3925
|
"src": "../../../node_modules/pdfmake/build/vfs_fonts.js",
|
|
3913
3926
|
"dst": "js/vfs_fonts.js"
|
|
3927
|
+
},
|
|
3928
|
+
{
|
|
3929
|
+
"src": "../../../node_modules/exceljs/dist/exceljs.min.js",
|
|
3930
|
+
"dst": "js/exceljs.min.js"
|
|
3914
3931
|
}
|
|
3915
3932
|
],
|
|
3916
3933
|
"linkFiles": [
|
|
@@ -3954,6 +3971,11 @@
|
|
|
3954
3971
|
"type": "js",
|
|
3955
3972
|
"defer": true
|
|
3956
3973
|
},
|
|
3974
|
+
{
|
|
3975
|
+
"src": "js/exceljs.min.js",
|
|
3976
|
+
"type": "js",
|
|
3977
|
+
"defer": true
|
|
3978
|
+
},
|
|
3957
3979
|
{
|
|
3958
3980
|
"src": "css/ag-theme-alpine.css",
|
|
3959
3981
|
"type": "css"
|
|
@@ -4318,6 +4340,40 @@
|
|
|
4318
4340
|
"dmx-ag-grid": true
|
|
4319
4341
|
}
|
|
4320
4342
|
},
|
|
4343
|
+
{
|
|
4344
|
+
"name": "dmx-ag-grid-export-xls-filename",
|
|
4345
|
+
"attributeStartsWith": "dmx-bind",
|
|
4346
|
+
"attribute": "export_xls_filename",
|
|
4347
|
+
"title": "Export XLS Filename",
|
|
4348
|
+
"type": "boolean",
|
|
4349
|
+
"display": "fieldset",
|
|
4350
|
+
"icon": "fa fa-lg fa-chevron-right",
|
|
4351
|
+
"groupTitle": "Grid Config",
|
|
4352
|
+
"groupIcon": "fa fa-lg fa-cubes",
|
|
4353
|
+
"defaultValue": false,
|
|
4354
|
+
"show": [
|
|
4355
|
+
"exportXlsFilename"
|
|
4356
|
+
],
|
|
4357
|
+
"noChangeOnHide": true,
|
|
4358
|
+
"groupEnabler": true,
|
|
4359
|
+
"children": [
|
|
4360
|
+
{
|
|
4361
|
+
"name": "exportXlsFilename",
|
|
4362
|
+
"attributeStartsWith": "dmx-bind",
|
|
4363
|
+
"attribute": "export_xls_filename",
|
|
4364
|
+
"isValue": true,
|
|
4365
|
+
"dataBindings": true,
|
|
4366
|
+
"title": "XLS Filename",
|
|
4367
|
+
"type": "text",
|
|
4368
|
+
"help": "Export XLS filename.",
|
|
4369
|
+
"defaultValue": "export.xlsx",
|
|
4370
|
+
"initDisplay": "none"
|
|
4371
|
+
}
|
|
4372
|
+
],
|
|
4373
|
+
"allowedOn": {
|
|
4374
|
+
"dmx-ag-grid": true
|
|
4375
|
+
}
|
|
4376
|
+
},
|
|
4321
4377
|
{
|
|
4322
4378
|
"name": "dmx-ag-grid-dark-mode",
|
|
4323
4379
|
"attributeStartsWith": "dmx-bind",
|
package/dmx-ag-grid.js
CHANGED
|
@@ -94,6 +94,8 @@ dmx.Component('ag-grid', {
|
|
|
94
94
|
export_csv_filename: { type: String, default: 'export.csv' },
|
|
95
95
|
export_to_pdf: { type: Boolean, default: false },
|
|
96
96
|
export_pdf_filename: { type: String, default: 'export.pdf' },
|
|
97
|
+
export_to_xls: { type: Boolean, default: false },
|
|
98
|
+
export_xls_filename: { type: String, default: 'export.xlsx' },
|
|
97
99
|
fixed_header: { type: Boolean, default: false },
|
|
98
100
|
topbar_class: { type: String, default: 'topbar' },
|
|
99
101
|
fixed_header_offset: { type: Number, default: 100 },
|
|
@@ -353,9 +355,9 @@ dmx.Component('ag-grid', {
|
|
|
353
355
|
if (gridInstance) gridInstance.destroy();
|
|
354
356
|
}, this);
|
|
355
357
|
},
|
|
356
|
-
exportGrid: function (Csv, Pdf) {
|
|
357
|
-
// Default Csv to true if
|
|
358
|
-
if (!Csv && !Pdf) {
|
|
358
|
+
exportGrid: function (Csv, Pdf, Xls) {
|
|
359
|
+
// Default Csv to true if none specified
|
|
360
|
+
if (!Csv && !Pdf && !Xls) {
|
|
359
361
|
Csv = true;
|
|
360
362
|
}
|
|
361
363
|
dmx.nextTick(() => {
|
|
@@ -365,6 +367,8 @@ dmx.Component('ag-grid', {
|
|
|
365
367
|
exportGridData(gridInst, gridCfg);
|
|
366
368
|
} else if (Pdf) {
|
|
367
369
|
exportGridDataToPDF(gridInst, gridCfg);
|
|
370
|
+
} else if (Xls) {
|
|
371
|
+
exportGridDataToXLS(gridInst, gridCfg);
|
|
368
372
|
} else {
|
|
369
373
|
console.error('Grid not loaded to perform the requested export');
|
|
370
374
|
}
|
|
@@ -607,6 +611,7 @@ dmx.Component('ag-grid', {
|
|
|
607
611
|
let groupedColumnDefs = [];
|
|
608
612
|
let exportToCSV = this.props.export_to_csv;
|
|
609
613
|
let exportToPDF = this.props.export_to_pdf;
|
|
614
|
+
let exportToXLS = this.props.export_to_xls;
|
|
610
615
|
let cellRenderer;
|
|
611
616
|
|
|
612
617
|
const gridThemeClass = options.dark_mode ? `${options.grid_theme}-dark` : options.grid_theme;
|
|
@@ -1827,6 +1832,7 @@ dmx.Component('ag-grid', {
|
|
|
1827
1832
|
suppressScrollOnNewData: this.props.suppress_scroll_on_new_data,
|
|
1828
1833
|
columnHoverHighlight: this.props.column_hover_highlight,
|
|
1829
1834
|
tooltipShowDelay: options.tooltip_show_delay,
|
|
1835
|
+
suppressOverlays: ['noMatchingRows', 'exporting'],
|
|
1830
1836
|
onFilterModified: function (params) {
|
|
1831
1837
|
const columnApi = params.api;
|
|
1832
1838
|
const rowCount = columnApi.getDisplayedRowCount();
|
|
@@ -2042,16 +2048,20 @@ dmx.Component('ag-grid', {
|
|
|
2042
2048
|
const gridConfig = {
|
|
2043
2049
|
columnDefs: columnDefs,
|
|
2044
2050
|
...gridOptions,
|
|
2045
|
-
// Store export configuration
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2051
|
+
// Store export configuration in context to avoid AG Grid warnings
|
|
2052
|
+
context: {
|
|
2053
|
+
...gridOptions.context,
|
|
2054
|
+
exportConfig: {
|
|
2055
|
+
export_csv_filename: options.export_csv_filename,
|
|
2056
|
+
export_pdf_filename: options.export_pdf_filename,
|
|
2057
|
+
export_xls_filename: options.export_xls_filename,
|
|
2058
|
+
export_remove_html: options.export_remove_html,
|
|
2059
|
+
export_trim_data: options.export_trim_data,
|
|
2060
|
+
export_exclude_fields: options.export_exclude_fields,
|
|
2061
|
+
export_exclude_hidden_fields: options.export_exclude_hidden_fields,
|
|
2062
|
+
group_config: options.group_config,
|
|
2063
|
+
column_state_storage_key: options.column_state_storage_key
|
|
2064
|
+
}
|
|
2055
2065
|
}
|
|
2056
2066
|
};
|
|
2057
2067
|
// Store gridConfig on component instance for export functions
|
|
@@ -2243,7 +2253,7 @@ dmx.Component('ag-grid', {
|
|
|
2243
2253
|
};
|
|
2244
2254
|
|
|
2245
2255
|
exportGridData = (currentGridInstance, currentGridConfig) => {
|
|
2246
|
-
const exportConfig = currentGridConfig.exportConfig;
|
|
2256
|
+
const exportConfig = currentGridConfig.context.exportConfig;
|
|
2247
2257
|
const excludedColumnIds = ['checkboxColumn', 'actionsColumn'];
|
|
2248
2258
|
const exportExcludeFieldsArray = exportConfig.export_exclude_fields ? exportConfig.export_exclude_fields.split(',') : [];
|
|
2249
2259
|
|
|
@@ -2443,7 +2453,7 @@ dmx.Component('ag-grid', {
|
|
|
2443
2453
|
console.error('Grid API is destroyed or not initialized.');
|
|
2444
2454
|
return;
|
|
2445
2455
|
}
|
|
2446
|
-
const exportConfig = currentGridConfig.exportConfig;
|
|
2456
|
+
const exportConfig = currentGridConfig.context.exportConfig;
|
|
2447
2457
|
const excludedColumnIds = ['checkboxColumn', 'actionsColumn'];
|
|
2448
2458
|
const exportExcludeFieldsArray = exportConfig.export_exclude_fields ? exportConfig.export_exclude_fields.split(',') : [];
|
|
2449
2459
|
let fieldsAndColIds;
|
|
@@ -2656,6 +2666,221 @@ dmx.Component('ag-grid', {
|
|
|
2656
2666
|
exportPdfButton.style.marginBottom = '10px';
|
|
2657
2667
|
}
|
|
2658
2668
|
}
|
|
2669
|
+
// XLS Export Function using ExcelJS
|
|
2670
|
+
exportGridDataToXLS = async (currentGridInstance, currentGridConfig) => {
|
|
2671
|
+
if (!currentGridInstance || currentGridInstance.isDestroyed()) {
|
|
2672
|
+
console.error('Grid API is destroyed or not initialized.');
|
|
2673
|
+
return;
|
|
2674
|
+
}
|
|
2675
|
+
if (typeof ExcelJS === 'undefined') {
|
|
2676
|
+
console.error('ExcelJS library is not loaded. Make sure exceljs.min.js is included.');
|
|
2677
|
+
return;
|
|
2678
|
+
}
|
|
2679
|
+
const exportConfig = currentGridConfig.context.exportConfig;
|
|
2680
|
+
const excludedColumnIds = ['checkboxColumn', 'actionsColumn'];
|
|
2681
|
+
const exportExcludeFieldsArray = exportConfig.export_exclude_fields ? exportConfig.export_exclude_fields.split(',') : [];
|
|
2682
|
+
|
|
2683
|
+
// Determine fields to export (reuse same logic as CSV)
|
|
2684
|
+
let fieldsToExport = [];
|
|
2685
|
+
const pageId = getPageId();
|
|
2686
|
+
const storageKey = exportConfig.column_state_storage_key || pageId;
|
|
2687
|
+
const savedColumnState = localStorage.getItem(`dmxState-${storageKey}`);
|
|
2688
|
+
|
|
2689
|
+
if (savedColumnState) {
|
|
2690
|
+
try {
|
|
2691
|
+
const parsedState = JSON.parse(savedColumnState);
|
|
2692
|
+
fieldsToExport = parsedState
|
|
2693
|
+
.filter((col) => {
|
|
2694
|
+
if (excludedColumnIds.includes(col.colId)) return false;
|
|
2695
|
+
if (col.hide) return false;
|
|
2696
|
+
return true;
|
|
2697
|
+
})
|
|
2698
|
+
.map((col) => {
|
|
2699
|
+
const columnDef = findColumnDefByColId(col.colId, exportConfig, currentGridConfig);
|
|
2700
|
+
return columnDef ? columnDef.field : col.colId;
|
|
2701
|
+
})
|
|
2702
|
+
.filter((field) => !exportExcludeFieldsArray.includes(field));
|
|
2703
|
+
} catch (err) {
|
|
2704
|
+
console.warn(`Failed to parse saved column state for key: dmxState-${storageKey}`, err);
|
|
2705
|
+
fieldsToExport = [];
|
|
2706
|
+
}
|
|
2707
|
+
}
|
|
2708
|
+
|
|
2709
|
+
function findColumnDefByColId(colId, expConfig, gridCfg) {
|
|
2710
|
+
if (expConfig.group_config) {
|
|
2711
|
+
const traverseColumns = (columns) => {
|
|
2712
|
+
for (const column of columns) {
|
|
2713
|
+
if (column.children) {
|
|
2714
|
+
const result = traverseColumns(column.children);
|
|
2715
|
+
if (result) return result;
|
|
2716
|
+
} else if (column.colId === colId) {
|
|
2717
|
+
return column;
|
|
2718
|
+
}
|
|
2719
|
+
}
|
|
2720
|
+
return null;
|
|
2721
|
+
};
|
|
2722
|
+
return traverseColumns(gridCfg.columnDefs);
|
|
2723
|
+
} else {
|
|
2724
|
+
return gridCfg.columnDefs.find((column) => column.colId === colId);
|
|
2725
|
+
}
|
|
2726
|
+
}
|
|
2727
|
+
|
|
2728
|
+
if (!fieldsToExport || fieldsToExport.length === 0) {
|
|
2729
|
+
let fieldsAndColIds;
|
|
2730
|
+
if (exportConfig.group_config) {
|
|
2731
|
+
const traverseColumns = (columns) => {
|
|
2732
|
+
const result = [];
|
|
2733
|
+
columns.forEach((column) => {
|
|
2734
|
+
if (column.children) {
|
|
2735
|
+
result.push(...traverseColumns(column.children));
|
|
2736
|
+
} else {
|
|
2737
|
+
result.push({ field: column.field, colId: column.colId, hide: column.hide });
|
|
2738
|
+
}
|
|
2739
|
+
});
|
|
2740
|
+
return result;
|
|
2741
|
+
};
|
|
2742
|
+
fieldsAndColIds = traverseColumns(currentGridConfig.columnDefs);
|
|
2743
|
+
} else {
|
|
2744
|
+
fieldsAndColIds = currentGridConfig.columnDefs.map((column) => ({
|
|
2745
|
+
field: column.field, colId: column.colId, hide: column.hide,
|
|
2746
|
+
}));
|
|
2747
|
+
}
|
|
2748
|
+
fieldsToExport = fieldsAndColIds.filter((column) => {
|
|
2749
|
+
return !excludedColumnIds.includes(column.colId) &&
|
|
2750
|
+
(!exportConfig.export_exclude_hidden_fields || !column.hide) &&
|
|
2751
|
+
!exportExcludeFieldsArray.includes(column.field);
|
|
2752
|
+
}).map((column) => column.field);
|
|
2753
|
+
}
|
|
2754
|
+
|
|
2755
|
+
// Build headers
|
|
2756
|
+
const headers = fieldsToExport.map(field => {
|
|
2757
|
+
return cnames.hasOwnProperty(field) ? cnames[field].custom_name : humanize(field);
|
|
2758
|
+
});
|
|
2759
|
+
|
|
2760
|
+
// Build rows
|
|
2761
|
+
const rows = [];
|
|
2762
|
+
currentGridInstance.forEachNode(node => {
|
|
2763
|
+
const row = fieldsToExport.map(field => {
|
|
2764
|
+
const columns = currentGridInstance.getColumnState();
|
|
2765
|
+
const col = columns.find(c => c.colId === field);
|
|
2766
|
+
const colDef = col ? currentGridInstance.getColumnDefs().find(def => def.colId === col.colId) : {};
|
|
2767
|
+
const params = {
|
|
2768
|
+
value: currentGridInstance.getCellValue({ rowNode: node, colKey: field }) ?? '-',
|
|
2769
|
+
data: node.data,
|
|
2770
|
+
node,
|
|
2771
|
+
colDef,
|
|
2772
|
+
column: col,
|
|
2773
|
+
api: currentGridInstance,
|
|
2774
|
+
context: currentGridInstance.getContext ? currentGridInstance.getContext() : undefined,
|
|
2775
|
+
};
|
|
2776
|
+
|
|
2777
|
+
let displayValue;
|
|
2778
|
+
if (colDef.cellRenderer && typeof colDef.cellRenderer === 'function') {
|
|
2779
|
+
displayValue = colDef.cellRenderer(params);
|
|
2780
|
+
} else if (colDef.valueFormatter && typeof colDef.valueFormatter === 'function') {
|
|
2781
|
+
displayValue = colDef.valueFormatter(params);
|
|
2782
|
+
} else {
|
|
2783
|
+
displayValue = params.value;
|
|
2784
|
+
}
|
|
2785
|
+
|
|
2786
|
+
if (exportConfig.export_remove_html && typeof displayValue === 'string') {
|
|
2787
|
+
displayValue = removeHtmlTags(displayValue);
|
|
2788
|
+
}
|
|
2789
|
+
if (exportConfig.export_trim_data && typeof displayValue === 'string') {
|
|
2790
|
+
displayValue = displayValue.trim();
|
|
2791
|
+
}
|
|
2792
|
+
return displayValue;
|
|
2793
|
+
});
|
|
2794
|
+
rows.push(row);
|
|
2795
|
+
});
|
|
2796
|
+
|
|
2797
|
+
// Create workbook and worksheet using ExcelJS
|
|
2798
|
+
const workbook = new ExcelJS.Workbook();
|
|
2799
|
+
const worksheet = workbook.addWorksheet('Export');
|
|
2800
|
+
|
|
2801
|
+
// Add header row
|
|
2802
|
+
worksheet.addRow(headers);
|
|
2803
|
+
// Style header row
|
|
2804
|
+
const headerRow = worksheet.getRow(1);
|
|
2805
|
+
headerRow.font = { bold: true };
|
|
2806
|
+
headerRow.eachCell((cell) => {
|
|
2807
|
+
cell.fill = {
|
|
2808
|
+
type: 'pattern',
|
|
2809
|
+
pattern: 'solid',
|
|
2810
|
+
fgColor: { argb: 'FFE0E0E0' }
|
|
2811
|
+
};
|
|
2812
|
+
});
|
|
2813
|
+
|
|
2814
|
+
// Add data rows
|
|
2815
|
+
rows.forEach(row => worksheet.addRow(row));
|
|
2816
|
+
|
|
2817
|
+
// Auto-fit column widths
|
|
2818
|
+
worksheet.columns.forEach((column, i) => {
|
|
2819
|
+
let maxLength = headers[i] ? headers[i].length : 10;
|
|
2820
|
+
rows.forEach(row => {
|
|
2821
|
+
const cellValue = row[i];
|
|
2822
|
+
if (cellValue != null) {
|
|
2823
|
+
const len = String(cellValue).length;
|
|
2824
|
+
if (len > maxLength) maxLength = len;
|
|
2825
|
+
}
|
|
2826
|
+
});
|
|
2827
|
+
column.width = Math.min(maxLength + 2, 50);
|
|
2828
|
+
});
|
|
2829
|
+
|
|
2830
|
+
// Generate and download
|
|
2831
|
+
const buffer = await workbook.xlsx.writeBuffer();
|
|
2832
|
+
const blob = new Blob([buffer], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
|
|
2833
|
+
const url = window.URL.createObjectURL(blob);
|
|
2834
|
+
const a = document.createElement('a');
|
|
2835
|
+
a.href = url;
|
|
2836
|
+
a.download = exportConfig.export_xls_filename;
|
|
2837
|
+
document.body.appendChild(a);
|
|
2838
|
+
a.click();
|
|
2839
|
+
document.body.removeChild(a);
|
|
2840
|
+
window.URL.revokeObjectURL(url);
|
|
2841
|
+
};
|
|
2842
|
+
if (exportToXLS) {
|
|
2843
|
+
let exportXlsButton = document.getElementById(`exportXlsButton-${options.id}`);
|
|
2844
|
+
let isNewXlsButton = false;
|
|
2845
|
+
if (!exportXlsButton) {
|
|
2846
|
+
isNewXlsButton = true;
|
|
2847
|
+
exportXlsButton = document.createElement('button');
|
|
2848
|
+
exportXlsButton.id = `exportXlsButton-${options.id}`;
|
|
2849
|
+
const icon = document.createElement('i');
|
|
2850
|
+
icon.classList.add('fas', 'fa-file-excel');
|
|
2851
|
+
exportXlsButton.appendChild(icon);
|
|
2852
|
+
|
|
2853
|
+
const buttonText = document.createElement('span');
|
|
2854
|
+
buttonText.innerText = ' Export to XLS';
|
|
2855
|
+
exportXlsButton.appendChild(buttonText);
|
|
2856
|
+
exportXlsButton.style.backgroundColor = '#4CAF50';
|
|
2857
|
+
exportXlsButton.style.border = 'none';
|
|
2858
|
+
exportXlsButton.style.color = 'white';
|
|
2859
|
+
exportXlsButton.style.padding = '5px 10px';
|
|
2860
|
+
exportXlsButton.style.textAlign = 'center';
|
|
2861
|
+
exportXlsButton.style.textDecoration = 'none';
|
|
2862
|
+
exportXlsButton.style.display = 'inline-block';
|
|
2863
|
+
exportXlsButton.style.fontSize = '14px';
|
|
2864
|
+
exportXlsButton.style.borderRadius = '5px';
|
|
2865
|
+
exportXlsButton.style.cursor = 'pointer';
|
|
2866
|
+
exportXlsButton.style.marginBottom = '10px';
|
|
2867
|
+
}
|
|
2868
|
+
|
|
2869
|
+
exportXlsButton.onclick = () => {
|
|
2870
|
+
const currentGridInstance = this.get('gridInstance');
|
|
2871
|
+
const currentGridConfig = this.get('gridConfig');
|
|
2872
|
+
if (currentGridInstance && currentGridConfig) {
|
|
2873
|
+
exportGridDataToXLS(currentGridInstance, currentGridConfig);
|
|
2874
|
+
} else {
|
|
2875
|
+
console.error('Grid instance or configuration not available for export');
|
|
2876
|
+
}
|
|
2877
|
+
};
|
|
2878
|
+
|
|
2879
|
+
if (isNewXlsButton) {
|
|
2880
|
+
gridContainer.parentNode.insertBefore(exportXlsButton, gridContainer);
|
|
2881
|
+
exportXlsButton.style.marginBottom = '10px';
|
|
2882
|
+
}
|
|
2883
|
+
}
|
|
2659
2884
|
const paginationPanelCss = `
|
|
2660
2885
|
/* Flexbox layout for pagination panel */
|
|
2661
2886
|
.ag-paging-panel {
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cdmx/wappler_ag_grid",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "App Connect module for AG Grid
|
|
5
|
+
"description": "App Connect module for AG Grid v35 - Advanced data grid with enhanced editing, filtering, and tree data capabilities.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": {
|
|
8
8
|
"name": "cdmx-in",
|
|
@@ -14,8 +14,9 @@
|
|
|
14
14
|
"ag-grid"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@ag-grid-community/locale": "~
|
|
18
|
-
"ag-grid-community": "~
|
|
17
|
+
"@ag-grid-community/locale": "~35.1.0",
|
|
18
|
+
"ag-grid-community": "~35.1.0",
|
|
19
|
+
"exceljs": "^4.4.0",
|
|
19
20
|
"papaparse": "~5.5.2",
|
|
20
21
|
"pdfmake": "~0.2.18",
|
|
21
22
|
"read-excel-file": "~5.8.7"
|