@cdmx/wappler_ag_grid 1.8.1 → 1.8.2

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 CHANGED
@@ -36,52 +36,53 @@ To use the "Custom" theme, copy "ag-theme-custom.css" to public/css/ag-theme-cus
36
36
  5. **Filter**: Specifies if the column has a filter. (Default: true)
37
37
  6. **Floating Filter**: Specifies if the column has a floating filter. (Default: true)
38
38
  7. **Exclude Hidden Fields**: Specifies if Hidden fields are to be excluded in CSV export. (Default: false)
39
- 8. **CSV Export**: Specifies if Export to CSV is enabled. (Default: true)
40
- 9. **Exclude Fields CSV**: Specifies fields to be excluded in CSV export. (Default: null)
41
- 10. **Enable RTL**: Enabled Right to Left, used for Hebrew and Arabic. (Default: false)
42
- 11. **Column Hover Highlight**: Specifies column hover highlighting. (Default: true)
43
- 12. **Suppress Row Deselection**: Specifies if rows can be deselected. (Default: false)
44
- 13. **Pagination**: Enables pagination. (Default: true)
45
- 14. **Auto Pagination**: Enables automatic pagination. (Default: false)
46
- 15. **Page Limit Selectors**: Allowed selectors for for page size. Set to false to hide the page size selector. (Default: [20,50,100] ).
47
- 16. **Page Limit**: Number of rows to show per page. (Default: 20)
48
- 17. **Row Selection**: Row Selection (single or multiple).
39
+ 8. **CSV Export**: Specifies if Export to CSV is enabled. (Default: true).
40
+ 9. **PDF Export**: Specifies if Export to PDF is enabled. (Default: false).
41
+ 10. **Exclude Fields CSV**: Specifies fields to be excluded in CSV export. (Default: null)
42
+ 11. **Enable RTL**: Enabled Right to Left, used for Hebrew and Arabic. (Default: false)
43
+ 12. **Column Hover Highlight**: Specifies column hover highlighting. (Default: true)
44
+ 13. **Suppress Row Deselection**: Specifies if rows can be deselected. (Default: false)
45
+ 14. **Pagination**: Enables pagination. (Default: true)
46
+ 15. **Auto Pagination**: Enables automatic pagination. (Default: false)
47
+ 16. **Page Limit Selectors**: Allowed selectors for for page size. Set to false to hide the page size selector. (Default: [20,50,100] ).
48
+ 17. **Page Limit**: Number of rows to show per page. (Default: 20)
49
+ 18. **Row Selection**: Row Selection (single or multiple).
49
50
  - "Single"
50
51
  - "Multiple" (Default)
51
- 18. **Timezone**: Timezone for Date Fields. Select the appropriate timezone from the dropdown list. (Default: Local)
52
- 19. **Date Format**: Date Format for displaying date values. (Default: "dd/MM/yyyy hh:mm A")
53
- 20. **Filter Field ID**: Specifies the field ID of the search field when using grid quick filter. Applicable when using Quick Filter feature of AG Grid, called from Dynamic Events on change event on the field. (Default: search_field)
54
- 21. **Loading Overlay**: This enables loading overlay. (Default: false)
55
- 22. **Loading Overlay Duration**: This sets loading overlay duration in ms. (Default: 500)
56
- 23. **Sticky Header and Horizontal Scrollbar**: Optionally specify the header offset and topbar class.
52
+ 19. **Timezone**: Timezone for Date Fields. Select the appropriate timezone from the dropdown list. (Default: Local)
53
+ 20. **Date Format**: Date Format for displaying date values. (Default: "dd/MM/yyyy hh:mm A")
54
+ 21. **Filter Field ID**: Specifies the field ID of the search field when using grid quick filter. Applicable when using Quick Filter feature of AG Grid, called from Dynamic Events on change event on the field. (Default: search_field)
55
+ 22. **Loading Overlay**: This enables loading overlay. (Default: false)
56
+ 23. **Loading Overlay Duration**: This sets loading overlay duration in ms. (Default: 500)
57
+ 24. **Sticky Header and Horizontal Scrollbar**: Optionally specify the header offset and topbar class.
57
58
  - Fixed Header: Enables sticky header. (Default: false)
58
59
  - Header Offset: Specifies offset from the top of the viewport area (Optional). (Default: 100)
59
60
  - Topbar Class: Specify class, e.g., "topbar", to measure the offset from (Optional). (Default: "topbar")
60
61
  - Topbar Offset: Specify topbar offset (Default: 80)
61
62
  - Fixed Horizontal Scroll: Enables Hovering horizontal scrollbar which stays at the bottom all the time. (Default: false)
62
63
  - Fixed Horizontal Scroll Width: Fixed horizontal scroll width percentage. (Default: 80%)
63
- 24. **Row Height**: Height of each row in pixels. (Default: Auto)
64
- 25. **Header Height**: Height of the header row in pixels. (Default: Auto)
65
- 26. **Wrap Header Text**: This will cause long headers to wrap. (Default: true)
66
- 27. **Auto Header Height**: The header height is automatically set based on the content of the header. (Default: true)
67
- 28. **Auto Height**: The height is automatically set based on the content of the cells. (Default: false)
68
- 29. **Wrap Text**: This will cause long texts to wrap in the cells. (Default: false)
69
- 30. **Center Align (V)**: Specifies if the cell data should be vertically centered. (Default: false)
70
- 31. **Suppress Row Click Selection**: Disables row selection on row click. (Default: false)
71
- 32. **Suppress Menu Hide**: Prevents hiding the column menu. (Default: false)
72
- 33. **Suppress Movable Columns**: Disables moving columns. (Default: false)
73
- 34. **Enable Cell Expressions**: Enables expressions in cell values. (Default: false)
74
- 35. **Animate Rows**: Enables row animation on data changes. (Default: false)
75
- 36. **Suppress Aggregation Function in Header**: Hides the aggregation function in column headers. (Default: false)
76
- 37. **Suppress Clipboard Paste**: Disables pasting data from the clipboard. (Default: false)
77
- 38. **Suppress Scroll on New Data**: Prevents scrolling to newly added data. (Default: false)
78
- 39. **Suppress Property Names Check**: Disables checking for duplicate property names. (Default: false)
79
- 40. **Hide ID Field**: Hides the ID Field in the Grid. (Default: false)
80
- 41. **Numeric Column Align**: Align numeric columns to the right. (Default: false)
81
- 42. **Row Click Events**: Enables row click events. This can be used in Dynamic events => Grid Events => Row Clicked. (Default: false)
82
- 43. **Row Double Click Events**: Enables row double click events. This can be used in Dynamic events => Grid Events => Row Double Clicked. (Default: false)
83
- 44. **Enable Row Selection**: Enables row selection. This can be used in Dynamic events => Grid Events => Checkbox Checked || Checkbox Unchecked. (Default: false)
84
- 45. **Enable Row Status Toggle**: Enables row status toggle events. This can be used in Dynamic events => Grid Events => Checkbox Checked || Checkbox Unchecked. (Default: false)
64
+ 25. **Row Height**: Height of each row in pixels. (Default: Auto)
65
+ 26. **Header Height**: Height of the header row in pixels. (Default: Auto)
66
+ 27. **Wrap Header Text**: This will cause long headers to wrap. (Default: true)
67
+ 28. **Auto Header Height**: The header height is automatically set based on the content of the header. (Default: true)
68
+ 29. **Auto Height**: The height is automatically set based on the content of the cells. (Default: false)
69
+ 30. **Wrap Text**: This will cause long texts to wrap in the cells. (Default: false)
70
+ 31. **Center Align (V)**: Specifies if the cell data should be vertically centered. (Default: false)
71
+ 32. **Suppress Row Click Selection**: Disables row selection on row click. (Default: false)
72
+ 33. **Suppress Menu Hide**: Prevents hiding the column menu. (Default: false)
73
+ 34. **Suppress Movable Columns**: Disables moving columns. (Default: false)
74
+ 35. **Enable Cell Expressions**: Enables expressions in cell values. (Default: false)
75
+ 36. **Animate Rows**: Enables row animation on data changes. (Default: false)
76
+ 37. **Suppress Aggregation Function in Header**: Hides the aggregation function in column headers. (Default: false)
77
+ 38. **Suppress Clipboard Paste**: Disables pasting data from the clipboard. (Default: false)
78
+ 39. **Suppress Scroll on New Data**: Prevents scrolling to newly added data. (Default: false)
79
+ 40. **Suppress Property Names Check**: Disables checking for duplicate property names. (Default: false)
80
+ 41. **Hide ID Field**: Hides the ID Field in the Grid. (Default: false)
81
+ 42. **Numeric Column Align**: Align numeric columns to the right. (Default: false)
82
+ 43. **Row Click Events**: Enables row click events. This can be used in Dynamic events => Grid Events => Row Clicked. (Default: false)
83
+ 44. **Row Double Click Events**: Enables row double click events. This can be used in Dynamic events => Grid Events => Row Double Clicked. (Default: false)
84
+ 45. **Enable Row Selection**: Enables row selection. This can be used in Dynamic events => Grid Events => Checkbox Checked || Checkbox Unchecked. (Default: false)
85
+ 46. **Enable Row Status Toggle**: Enables row status toggle events. This can be used in Dynamic events => Grid Events => Checkbox Checked || Checkbox Unchecked. (Default: false)
85
86
 
86
87
  # Data Type Overrides
87
88
 
@@ -101,7 +102,7 @@ The Style Formatting feature allows you to configure custom colors and fonts for
101
102
  This grid allows you to define custom color and font settings based on specific conditions. The grid has the following columns:
102
103
 
103
104
  1. **Field**: The field name for which you want to apply the custom color and font settings. (eg. first_name or status)
104
- 2. **Condition**: The condition to check for applying the custom color and font settings. (eg. status=false or name=K den).
105
+ 2. **Condition**: The condition to check for applying the custom color and font settings. (eg. status==false or name==K den).
105
106
  You can also supply a function here to return true or false based on the input.
106
107
  eg: input jsTest() in the condition field and define it as below:
107
108
  ```javascript
@@ -117,7 +118,7 @@ This grid allows you to define custom color and font settings based on specific
117
118
 
118
119
  ## Configure Row Colors
119
120
 
120
- 1. **Condition**: The condition to check for applying the custom color to rows. (eg. status=false or name=K den).
121
+ 1. **Condition**: The condition to check for applying the custom color to rows. (eg. status==false or name==K den).
121
122
  You can also supply a function here to return true or false based on the input.
122
123
  eg: input jsTest() in the condition field and define it as below:
123
124
  ```javascript
@@ -434,7 +435,7 @@ Specify the condition to Show the Button[i] Action button, eg: code==TEST, or st
434
435
 
435
436
  **Export**
436
437
  - To be used if you wish to use a separate Export button instead of using the inbuilt top left-cornered Export button.
437
- - Trigger this action to call Export Data to CSV download action.
438
+ - Trigger this action to call Export Data to CSV/PDF download action based on selected file Type.
438
439
 
439
440
  **Save Column State**
440
441
  - This action allows you to save the current state of the grid's columns, including their visibility and order, to the browser's local storage.
@@ -224,6 +224,14 @@
224
224
  "defaultValue": true,
225
225
  "help": "Specifies if Export to CSV to be enabled"
226
226
  },
227
+ {
228
+ "name": "exportToPDF",
229
+ "attribute": "dmx-bind:export_to_pdf",
230
+ "title": "PDF Export",
231
+ "type": "boolean",
232
+ "defaultValue": false,
233
+ "help": "Specifies if Export to PDF to be enabled"
234
+ },
227
235
  {
228
236
  "name": "exportExcludeHidden",
229
237
  "attribute": "dmx-bind:export_exclude_hidden_fields",
@@ -1409,6 +1417,7 @@
1409
1417
  {
1410
1418
  "name": "hideFields",
1411
1419
  "attribute": "hide_fields",
1420
+ "dataBindings": true,
1412
1421
  "title": "Hide Fields",
1413
1422
  "type": "text",
1414
1423
  "initDisplay": "none"
@@ -2492,8 +2501,24 @@
2492
2501
  name: 'exportGrid',
2493
2502
  icon: 'fa fa-lg fa-download',
2494
2503
  state: 'opened',
2495
- help: 'Export AG Grid Data to CSV',
2496
- properties: []
2504
+ help: 'Export AG Grid Data',
2505
+ properties: [
2506
+ {
2507
+ group: 'Properties',
2508
+ variables: [
2509
+ {
2510
+ name: '1', optionName: '1', title: 'CSV', type: 'boolean',
2511
+ dataBindings: true, defaultValue: true, required: false,
2512
+ help: 'Export Grid data as CSV file.'
2513
+ },
2514
+ {s
2515
+ name: '2', optionName: '2', title: 'PDF', type: 'boolean',
2516
+ dataBindings: true, defaultValue: false, required: false,
2517
+ help: 'Export Grid data as PDF file.'
2518
+ }
2519
+ ]
2520
+ }
2521
+ ]
2497
2522
  },
2498
2523
  {
2499
2524
  addTitle: 'SaveColumnState',
@@ -2607,6 +2632,14 @@
2607
2632
  "src": "../../../node_modules/exceljs/dist/exceljs.min.js",
2608
2633
  "dst": "js/exceljs.min.js"
2609
2634
  },
2635
+ {
2636
+ "src": "../../../node_modules/pdfmake/build/pdfmake.min.js",
2637
+ "dst": "js/pdfmake.min.js"
2638
+ },
2639
+ {
2640
+ "src": "../../../node_modules/pdfmake/build/vfs_fonts.js",
2641
+ "dst": "js/vfs_fonts.js"
2642
+ },
2610
2643
  {
2611
2644
  "src": "../../../node_modules/ag-grid-community/styles/ag-theme-alpine.css",
2612
2645
  "dst": "css/ag-theme-alpine.css"
@@ -2642,6 +2675,14 @@
2642
2675
  {
2643
2676
  "src": "pt.js",
2644
2677
  "dst": "js/locale/pt.js"
2678
+ },
2679
+ {
2680
+ "src": "pdfmake.min.js",
2681
+ "dst": "js/pdfmake.min.js"
2682
+ },
2683
+ {
2684
+ "src": "vfs_fonts.js",
2685
+ "dst": "js/vfs_fonts.js"
2645
2686
  }
2646
2687
  ],
2647
2688
  "linkFiles": [
@@ -2920,7 +2961,8 @@
2920
2961
  "groupIcon": "fa fa-lg fa-cubes",
2921
2962
  "defaultValue": false,
2922
2963
  "show": [
2923
- "exportCsvFilename"
2964
+ "exportCsvFilename",
2965
+ "exportPdfFilename"
2924
2966
  ],
2925
2967
  "noChangeOnHide": true,
2926
2968
  "groupEnabler": true,
@@ -2936,6 +2978,18 @@
2936
2978
  "help": "Export CSV filename.",
2937
2979
  "defaultValue": "export.csv",
2938
2980
  "initDisplay": "none"
2981
+ },
2982
+ {
2983
+ "name": "exportPdfFilename",
2984
+ "attributeStartsWith": "dmx-bind",
2985
+ "attribute": "export_pdf_filename",
2986
+ "isValue": true,
2987
+ "dataBindings": true,
2988
+ "title": "PDF Filename",
2989
+ "type": "text",
2990
+ "help": "Export PDF filename.",
2991
+ "defaultValue": "export.pdf",
2992
+ "initDisplay": "none"
2939
2993
  }
2940
2994
  ],
2941
2995
  "allowedOn": {
package/dmx-ag-grid.js CHANGED
@@ -86,6 +86,8 @@ dmx.Component('ag-grid', {
86
86
  export_exclude_fields: { type: String, default: null },
87
87
  export_to_csv: { type: Boolean, default: true },
88
88
  export_csv_filename: { type: String, default: 'export.csv' },
89
+ export_to_pdf: { type: Boolean, default: false },
90
+ export_pdf_filename: { type: String, default: 'export.pdf' },
89
91
  fixed_header: { type: Boolean, default: false },
90
92
  topbar_class: { type: String, default: 'topbar' },
91
93
  fixed_header_offset: { type: Number, default: 100 },
@@ -215,12 +217,14 @@ dmx.Component('ag-grid', {
215
217
  this.set('gridInstance', gridInstance);
216
218
  }, this);
217
219
  },
218
- exportGrid: function () {
219
- dmx.nextTick(function() {
220
- if (typeof exportGridData === 'function') {
221
- exportGridData();
220
+ exportGrid: function (Csv, Pdf) {
221
+ if (!Csv && !Pdf) return;
222
+ dmx.nextTick(() => {
223
+ const exportFunction = Csv ? exportGridData : (Pdf ? exportGridDataToPDF : null);
224
+ if (typeof exportFunction === 'function') {
225
+ exportFunction();
222
226
  } else {
223
- console.error('Grid not loaded to perform export');
227
+ console.error('Grid not loaded to perform the requested export');
224
228
  }
225
229
  }, this);
226
230
  },
@@ -406,6 +410,7 @@ dmx.Component('ag-grid', {
406
410
  let columnDefs = [];
407
411
  let groupedColumnDefs = [];
408
412
  let exportToCSV = this.props.export_to_csv;
413
+ let exportToPDF = this.props.export_to_pdf;
409
414
  let cellRenderer;
410
415
  const gridThemeClass = options.dark_mode ? `${options.grid_theme}-dark` : options.grid_theme;
411
416
  this.$node.innerHTML = `<div id=${options.id}-grid class="${gridThemeClass}"></div>`;
@@ -1641,10 +1646,10 @@ dmx.Component('ag-grid', {
1641
1646
  return;
1642
1647
  }
1643
1648
 
1644
- if (gridInstance) {
1645
- gridInstance.destroy();
1646
- gridInstance = null;
1647
- }
1649
+ // if (gridInstance) {
1650
+ // gridInstance.destroy();
1651
+ // gridInstance = null;
1652
+ // }
1648
1653
  const getPageId = () => {
1649
1654
  const currentPageUrl = window.location.origin + window.location.pathname;
1650
1655
  const optionsId = options.id+'-grid';
@@ -1939,6 +1944,191 @@ dmx.Component('ag-grid', {
1939
1944
  gridContainer.parentNode.insertBefore(exportButton, gridContainer);
1940
1945
  exportButton.style.marginBottom = '10px';
1941
1946
  }
1947
+ // Export AG Grid data to PDF
1948
+ exportGridDataToPDF = async () => {
1949
+ if (!gridInstance || gridInstance.isDestroyed()) {
1950
+ console.error('Grid API is destroyed or not initialized.');
1951
+ return;
1952
+ }
1953
+ const excludedColumnIds = ['checkboxColumn', 'actionsColumn'];
1954
+ const exportExcludeFieldsArray = options.export_exclude_fields ? options.export_exclude_fields.split(',') : [];
1955
+ let fieldsAndColIds;
1956
+ if (options.group_config) {
1957
+ // Helper function to traverse grouped column structure
1958
+ const traverseColumns = (columns) => {
1959
+ const fieldsAndColIds = [];
1960
+ columns.forEach((column) => {
1961
+ if (column.children) {
1962
+ fieldsAndColIds.push(...traverseColumns(column.children));
1963
+ } else {
1964
+ fieldsAndColIds.push({
1965
+ field: column.field,
1966
+ colId: column.colId,
1967
+ hide: column.hide,
1968
+ });
1969
+ }
1970
+ });
1971
+ return fieldsAndColIds;
1972
+ };
1973
+ // Traverse columnDefs to gather fields and colIds
1974
+ fieldsAndColIds = traverseColumns(gridConfig.columnDefs);
1975
+ } else {
1976
+ fieldsAndColIds = gridConfig.columnDefs.map((column) => ({
1977
+ field: column.field,
1978
+ colId: column.colId,
1979
+ hide: column.hide,
1980
+ }));
1981
+ }
1982
+ const fieldsToExport = fieldsAndColIds.filter((column) => {
1983
+ return !excludedColumnIds.includes(column.colId) &&
1984
+ (!options.export_exclude_hidden_fields || !column.hide) &&
1985
+ !exportExcludeFieldsArray.includes(column.field);
1986
+ }).map((column) => column.field);
1987
+
1988
+ const applyCellStyle = (params) => {
1989
+ if (params.data == null) return '-'
1990
+ const field = params.colDef.field.toString();
1991
+ const styles = this.props.cstyles.filter((cs) => cs.field === field);
1992
+ const whiteSpace = options.wrap_text ? 'normal' : 'nowrap';
1993
+
1994
+ for (const style of styles) {
1995
+ const condition = style.condition;
1996
+ const customColor = style.customColor;
1997
+ const font = style.font || 'normal';
1998
+ const area = style.area || 'text';
1999
+ let conditionResult = false;
2000
+ if (condition.endsWith('()') && typeof window[condition.replace(/\(\)$/, '')] === 'function') {
2001
+ const result = window[condition.replace(/\(\)$/, '')](params.data);
2002
+ if (typeof result !== 'boolean') {
2003
+ console.error('Custom condition function must return a boolean value.');
2004
+ return;
2005
+ }
2006
+ conditionResult = result;
2007
+ } else {
2008
+ const [left, operator, right] = extractConditionParts(condition);
2009
+ if (params.data.hasOwnProperty(left) &&
2010
+ (params.data[left] !== null ? evaluateCondition(params.data[left], operator, right) : false)
2011
+ ) {
2012
+ conditionResult = true;
2013
+ }
2014
+ }
2015
+ if (conditionResult) {
2016
+ const cellStyle = {
2017
+ color: customColor,
2018
+ fontStyle: font,
2019
+ fontWeight: (font === 'bold' ? 'bold' : null),
2020
+ whiteSpace: whiteSpace
2021
+ };
2022
+ return area === 'cell' ? { ...cellStyle, backgroundColor: customColor } : cellStyle;
2023
+ }
2024
+ }
2025
+ return options.wrap_text ? { whiteSpace: 'normal' } : null;
2026
+ };
2027
+
2028
+ const getColumnData = (gridInstance, isHeader) =>
2029
+ gridInstance.getAllDisplayedColumns()
2030
+ .filter(column => fieldsToExport.includes(column.getColDef().field))
2031
+ .map(column => {
2032
+ const colDef = column.getColDef();
2033
+ const field = colDef.field;
2034
+ const params = {
2035
+ value: isHeader ? null : gridInstance.getValue(column, gridInstance.getDisplayedRowAtIndex(0)),
2036
+ data: isHeader ? null : gridInstance.getDisplayedRowAtIndex(0).data,
2037
+ node: isHeader ? null : gridInstance.getDisplayedRowAtIndex(0),
2038
+ colDef,
2039
+ column,
2040
+ api: gridInstance,
2041
+ };
2042
+ const cellStyle = applyCellStyle(params);
2043
+ return {
2044
+ text: isHeader ? `${field[0].toUpperCase() + field.slice(1)}` :
2045
+ (colDef.cellRenderer && typeof colDef.cellRenderer === 'function') ? colDef.cellRenderer(params) :
2046
+ (colDef.valueFormatter && typeof colDef.valueFormatter === 'function') ? colDef.valueFormatter(params) :
2047
+ gridInstance.getValue(column, gridInstance.getDisplayedRowAtIndex(0)) ?? '',
2048
+ color: cellStyle?.color ?? 'black',
2049
+ fillColor: cellStyle?.backgroundColor ? cellStyle.backgroundColor.replace('#', '') : undefined,
2050
+ };
2051
+ });
2052
+
2053
+ const columns = gridInstance.getColumnState();
2054
+ const columnMap = new Map(columns.map(col => [col.colId, col]));
2055
+
2056
+ const rows = [];
2057
+ gridInstance.forEachNode(node => {
2058
+ const row = fieldsToExport.map(field => {
2059
+ const col = columnMap.get(field);
2060
+ const colDef = col ? gridInstance.getColumnDefs().find(def => def.colId === col.colId) : {};
2061
+ const params = {
2062
+ value: gridInstance.getCellValue({ rowNode: node, colKey: col.colId }) ?? '-',
2063
+ data: node.data,
2064
+ node,
2065
+ colDef,
2066
+ column: gridInstance.getColumnState().find(col => col.colId === col.colId),
2067
+ api: gridInstance,
2068
+ };
2069
+ const cellStyle = applyCellStyle(params);
2070
+ const value = gridInstance.getCellValue({ rowNode: node, colKey: col.colId }) ?? '-';
2071
+ return {
2072
+ text: (colDef.cellRenderer && typeof colDef.cellRenderer === 'function') ? colDef.cellRenderer(params) :
2073
+ (colDef.valueFormatter && typeof colDef.valueFormatter === 'function') ? colDef.valueFormatter(params) :
2074
+ value,
2075
+ color: cellStyle?.color ?? 'black',
2076
+ fillColor: cellStyle?.backgroundColor ? cellStyle.backgroundColor.replace('#', '') : undefined,
2077
+ };
2078
+ });
2079
+ rows.push(row);
2080
+ });
2081
+ const documentDefinition = {
2082
+ pageOrientation: 'landscape',
2083
+ content: [{
2084
+ table: {
2085
+ headerRows: 1,
2086
+ widths: fieldsToExport.map(() => `${100 / fieldsToExport.length}%`),
2087
+ body: [getColumnData(gridInstance, true), ...rows],
2088
+ heights: (rowIndex) => (rowIndex === 0 ? 40 : 15),
2089
+ fillColor: (rowIndex, colIndex) => rows[rowIndex][colIndex].fillColor,
2090
+ color: (rowIndex, colIndex) => rows[rowIndex][colIndex].color,
2091
+ },
2092
+ }],
2093
+ };
2094
+ pdfMake.createPdf(documentDefinition).download(options.export_pdf_filename);
2095
+ };
2096
+ if (exportToPDF) {
2097
+ const existingPdfExportButton = document.getElementById('exportPdfButton');
2098
+ if (existingPdfExportButton) {
2099
+ return;
2100
+ }
2101
+ const exportPdfButton = document.createElement('button');
2102
+ exportPdfButton.id = 'exportPdfButton';
2103
+ const icon = document.createElement('i');
2104
+ icon.classList.add('fas', 'fa-file-pdf');
2105
+ exportPdfButton.appendChild(icon);
2106
+
2107
+ // Add the button text
2108
+ const buttonText = document.createElement('span');
2109
+ buttonText.innerText = ' Export to PDF';
2110
+ exportPdfButton.appendChild(buttonText);
2111
+ exportPdfButton.style.backgroundColor = '#4CAF50';
2112
+ exportPdfButton.style.border = 'none';
2113
+ exportPdfButton.style.color = 'white';
2114
+ exportPdfButton.style.padding = '5px 10px';
2115
+ exportPdfButton.style.textAlign = 'center';
2116
+ exportPdfButton.style.textDecoration = 'none';
2117
+ exportPdfButton.style.display = 'inline-block';
2118
+ exportPdfButton.style.fontSize = '14px';
2119
+ exportPdfButton.style.borderRadius = '5px';
2120
+ exportPdfButton.style.cursor = 'pointer';
2121
+ exportPdfButton.style.marginBottom = '10px';
2122
+
2123
+ exportPdfButton.addEventListener('click', () => {
2124
+ exportGridDataToPDF(this)
2125
+ })
2126
+
2127
+ // Append the export button to the grid container
2128
+ gridContainer.parentNode.insertBefore(exportPdfButton, gridContainer);
2129
+ exportPdfButton.style.marginBottom = '10px';
2130
+ }
2131
+ // Return grid instance
1942
2132
  return gridInstance;
1943
2133
 
1944
2134
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdmx/wappler_ag_grid",
3
- "version": "1.8.1",
3
+ "version": "1.8.2",
4
4
  "type": "module",
5
5
  "description": "App Connect module for AG Grid Table Generation.",
6
6
  "license": "MIT",