@cdmx/wappler_ag_grid 1.6.1 → 1.6.3

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
@@ -35,37 +35,37 @@ To use the "Custom" theme, copy "ag-theme-custom.css" to public/css/ag-theme-cus
35
35
  6. **Floating Filter**: Specifies if the column has a floating filter. (Default: true)
36
36
  7. **Editiable Cells**: Makes cells editable. (Default: false)
37
37
  8. **Editiable Rows**: Makes row data editable. (Default: false)
38
- 9. **CSV Export**: Specifies if Export to CSV is enabled. (Default: true)
39
- 10. **Enable RTL**: Enabled Right to Left, used for Hebrew and Arabic. (Default: false)
40
- 11. **Column Hover Highlight**: Specifies column hover highlighting. (Default: true)
41
- 12. **Suppress Row Deselection**: Specifies if rows can be deselected. (Default: false)
42
- 13. **Pagination**: Enables pagination. (Default: true)
43
- 14. **Auto Pagination**: Enables automatic pagination. (Default: false)
44
- 15. **Page Limit Selectors**: Allowed selectors for for page size. Set to false to hide the page size selector. (Default: [20,50,100] ).
45
- 16. **Page Limit**: Number of rows to show per page. (Default: 20)
46
- 17. **Row Selection**: Row Selection (single or multiple).
38
+ 9. **Exclude Hidden Fields**: Specifies if Hidden fields are to be excluded in CSV export. (Default: false)
39
+ 10. **CSV Export**: Specifies if Export to CSV is enabled. (Default: true)
40
+ 11. **Enable RTL**: Enabled Right to Left, used for Hebrew and Arabic. (Default: false)
41
+ 12. **Column Hover Highlight**: Specifies column hover highlighting. (Default: true)
42
+ 13. **Suppress Row Deselection**: Specifies if rows can be deselected. (Default: false)
43
+ 14. **Pagination**: Enables pagination. (Default: true)
44
+ 15. **Auto Pagination**: Enables automatic pagination. (Default: false)
45
+ 16. **Page Limit Selectors**: Allowed selectors for for page size. Set to false to hide the page size selector. (Default: [20,50,100] ).
46
+ 17. **Page Limit**: Number of rows to show per page. (Default: 20)
47
+ 18. **Row Selection**: Row Selection (single or multiple).
47
48
  - "Single"
48
49
  - "Multiple" (Default)
49
- 18. **Timezone**: Timezone for Date Fields. Select the appropriate timezone from the dropdown list. (Default: Local)
50
- 19. **Date Format**: Date Format for displaying date values. (Default: "dd/MM/yyyy hh:mm A")
51
- 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)
52
- 21. **Loading Overlay**: This enables loading overlay. (Default: false)
53
- 22. **Loading Overlay Duration**: This sets loading overlay duration in ms. (Default: 500)
54
- 23. **Sticky Header and Horizontal Scrollbar**: Optionally specify the header offset and topbar class.
50
+ 19. **Timezone**: Timezone for Date Fields. Select the appropriate timezone from the dropdown list. (Default: Local)
51
+ 20. **Date Format**: Date Format for displaying date values. (Default: "dd/MM/yyyy hh:mm A")
52
+ 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)
53
+ 22. **Loading Overlay**: This enables loading overlay. (Default: false)
54
+ 23. **Loading Overlay Duration**: This sets loading overlay duration in ms. (Default: 500)
55
+ 24. **Sticky Header and Horizontal Scrollbar**: Optionally specify the header offset and topbar class.
55
56
  - Fixed Header: Enables sticky header. (Default: false)
56
57
  - Header Offset: Specifies offset from the top of the viewport area (Optional). (Default: 100)
57
58
  - Topbar Class: Specify class, e.g., "topbar", to measure the offset from (Optional). (Default: "topbar")
58
59
  - Topbar Offset: Specify topbar offset (Default: 80)
59
60
  - Fixed Horizontal Scroll: Enables Hovering horizontal scrollbar which stays at the bottom all the time. (Default: false)
60
61
  - Fixed Horizontal Scroll Width: Fixed horizontal scroll width percentage. (Default: 80%)
61
- 24. **Row Height**: Height of each row in pixels. (Default: Auto)
62
- 25. **Header Height**: Height of the header row in pixels. (Default: Auto)
63
- 26. **Wrap Header Text**: This will cause long headers to wrap. (Default: true)
64
- 27. **Auto Header Height**: The header height is automatically set based on the content of the header. (Default: true)
65
- 28. **Auto Height**: The height is automatically set based on the content of the cells. (Default: false)
66
- 29. **Wrap Text**: This will cause long texts to wrap in the cells. (Default: false)
67
- 30. **Center Align (V)**: Specifies if the cell data should be vertically centered. (Default: false)
68
- 31. **Center Align (H)**: Specifies if the cell data should be vertically centered. (Default: false)
62
+ 25. **Row Height**: Height of each row in pixels. (Default: Auto)
63
+ 26. **Header Height**: Height of the header row in pixels. (Default: Auto)
64
+ 27. **Wrap Header Text**: This will cause long headers to wrap. (Default: true)
65
+ 28. **Auto Header Height**: The header height is automatically set based on the content of the header. (Default: true)
66
+ 29. **Auto Height**: The height is automatically set based on the content of the cells. (Default: false)
67
+ 30. **Wrap Text**: This will cause long texts to wrap in the cells. (Default: false)
68
+ 31. **Center Align (V)**: Specifies if the cell data should be vertically centered. (Default: false)
69
69
  32. **Suppress Row Click Selection**: Disables row selection on row click. (Default: false)
70
70
  33. **Suppress Menu Hide**: Prevents hiding the column menu. (Default: false)
71
71
  34. **Suppress Movable Columns**: Disables moving columns. (Default: false)
@@ -94,16 +94,40 @@ This grid allows you to define custom type overrides for specific fields in the
94
94
 
95
95
  # Style Formatting
96
96
 
97
+ ## Text and Cell Colors
98
+
97
99
  The Style Formatting feature allows you to configure custom colors and fonts for column data based on certain conditions.
98
100
  This grid allows you to define custom color and font settings based on specific conditions. The grid has the following columns:
99
101
 
100
102
  1. **Field**: The field name for which you want to apply the custom color and font settings. (eg. first_name or status)
101
- 2. **Condition**: The condition to check for applying the custom color and font settings. (eg. status=false or name=K den)
103
+ 2. **Condition**: The condition to check for applying the custom color and font settings. (eg. status=false or name=K den).
104
+ You can also supply a function here to return true or false based on the input.
105
+ eg: input jsTest() in the condition field and define it as below:
106
+ ```javascript
107
+ <script>
108
+ function jsTest(data) {
109
+ return (data.status == 'success');
110
+ }
111
+ </script>
102
112
  3. **Color**: The custom color to apply when the condition is met. Enter the color in HEX format (e.g., "#FF0000") or use named colors (e.g., "red").
103
113
  4. **Area**: Choose where to apply the color: "text" (cell text) or "cell" (cell background).
104
114
  5. **Font**: Choose the font style: "normal," "italic," or "bold."
105
115
  ---
106
116
 
117
+ ## Configure Row Colors
118
+
119
+ 1. **Condition**: The condition to check for applying the custom color to rows. (eg. status=false or name=K den).
120
+ You can also supply a function here to return true or false based on the input.
121
+ eg: input jsTest() in the condition field and define it as below:
122
+ ```javascript
123
+ <script>
124
+ function jsTest(data) {
125
+ return (data.status == 'success');
126
+ }
127
+ </script>
128
+ </script>
129
+ 2. **Color**: The custom color to apply to row when the condition is met. Enter the color in HEX format (e.g., "#FF0000") or use named colors (e.g., "red").
130
+
107
131
  # Tooltip Settings
108
132
 
109
133
  The Tooltip Settings feature allows you to configure custom tooltips for specific fields in the data.
@@ -176,7 +176,7 @@
176
176
  "defaultValue": true,
177
177
  "help": "Specifies if the column has a floating filter"
178
178
  },
179
- {
179
+ {
180
180
  "name": "cellEditable",
181
181
  "attribute": "dmx-bind:cell_editable",
182
182
  "title": "Editable Cells",
@@ -192,6 +192,14 @@
192
192
  "defaultValue": false,
193
193
  "help": "Makes entire row editable."
194
194
  },
195
+ {
196
+ "name": "exportExcludeHidden",
197
+ "attribute": "dmx-bind:export_exclude_hidden_fields",
198
+ "title": "Exclude Hidden Fields",
199
+ "type": "boolean",
200
+ "defaultValue": false,
201
+ "help": "Specifies if Hidden fields are to be excluded in CSV export."
202
+ },
195
203
  {
196
204
  "name": "exportToCSV",
197
205
  "attribute": "dmx-bind:export_to_csv",
@@ -332,7 +340,7 @@
332
340
  "defaultValue": "dd/MM/yyyy hh:mm A",
333
341
  "help": "Date Format"
334
342
  },
335
- {
343
+ {
336
344
  "name": "quickFilterField",
337
345
  "attribute": "quick_filter_field",
338
346
  "title": "Filter Field ID",
@@ -467,7 +475,7 @@
467
475
  "defaultValue": false,
468
476
  "help": "This will cause long texts to wrap in the cells."
469
477
  },
470
- {
478
+ {
471
479
  "name": "vCenterCellData",
472
480
  "attribute": "dmx-bind:vert_center_cell_data",
473
481
  "title": "Center Align (V)",
@@ -689,7 +697,7 @@
689
697
  {
690
698
  "name": "listColors",
691
699
  "attribute": "dmx-bind:cstyles",
692
- "title": "Colors",
700
+ "title": "Text and Cell Colors",
693
701
  "type": "grid",
694
702
  "dataBindings": true,
695
703
  "jsonFormat": true,
@@ -752,6 +760,64 @@
752
760
  }
753
761
  }
754
762
  ]
763
+ },
764
+ {
765
+ "name": "rstyles",
766
+ "title": "Configure Row Colors",
767
+ "attributeStartsWith": "dmx-bind",
768
+ "attribute": "rstyles",
769
+ "type": "boolean",
770
+ "defaultValue": false,
771
+ "display": "fieldset",
772
+ "show": [
773
+ "listRowColors"
774
+ ],
775
+ "noChangeOnHide": true,
776
+ "groupEnabler": true,
777
+ "help": "Add custom Colors function that will return true or false. Add the fucntion name in the Function column."
778
+ "children": [
779
+ {
780
+ "name": "listRowColors",
781
+ "attribute": "dmx-bind:rstyles",
782
+ "title": "Row Colors",
783
+ "type": "grid",
784
+ "key": "field",
785
+ "dataBindings": true,
786
+ "jsonFormat": true,
787
+ "encloseBT": true,
788
+ "jsonBT": true,
789
+ "initDisplay": "none",
790
+ "columns": [
791
+ {
792
+ "field": "field",
793
+ "caption": "Field",
794
+ "editable": {
795
+ "type": "text"
796
+ }
797
+ },
798
+ {
799
+ "field": "condition",
800
+ "caption": "Function",
801
+ "editable": {
802
+ "type": "text"
803
+ }
804
+ },
805
+ {
806
+ "field": "customColor",
807
+ "caption": "Color",
808
+ "editable": {
809
+ "type": "text"
810
+ },
811
+ help: "Example: '#FF0000' or 'red'"
812
+ }
813
+ ],
814
+ "newRecord": {
815
+ "field": "",
816
+ "condition": "",
817
+ "customColor": ""
818
+ }
819
+ }
820
+ ]
755
821
  }
756
822
  ]
757
823
  },
@@ -1384,7 +1450,7 @@
1384
1450
  "columnsToSum",
1385
1451
  "enableFixedFooter",
1386
1452
  "fixedFooterBottomPadding",
1387
- "columnsToCountNonUnique"
1453
+ "columnsToCountNonUnique"
1388
1454
  ],
1389
1455
  "noChangeOnHide": true,
1390
1456
  "groupEnabler": true,
@@ -1420,7 +1486,7 @@
1420
1486
  "unique_values": ""
1421
1487
  }
1422
1488
  },
1423
- {
1489
+ {
1424
1490
  "name": "columnsToCountNonUnique",
1425
1491
  "attribute": "dmx-bind:columns_to_count_nonunique",
1426
1492
  "title": "Count Non-Unique",
@@ -2356,7 +2422,7 @@
2356
2422
  state: 'opened',
2357
2423
  help: 'Get Selected Rows',
2358
2424
  properties: []
2359
- },
2425
+ },
2360
2426
  {
2361
2427
  addTitle: 'quickFilter',
2362
2428
  title: 'Quick Filter',
@@ -2820,7 +2886,7 @@
2820
2886
  "dmx-ag-grid": true
2821
2887
  }
2822
2888
  },
2823
- {
2889
+ {
2824
2890
  "name": "dmx-ag-grid-cell-edited",
2825
2891
  "attributeStartsWith": "dmx-on",
2826
2892
  "attribute": "cell_data_edited",
package/dmx-ag-grid.js CHANGED
@@ -22,6 +22,7 @@ dmx.Component('ag-grid', {
22
22
  tooltip_config: { type: Array, default: [] },
23
23
  custom_tooltip: { type: String, default: null },
24
24
  cstyles: { type: Array, default: [] },
25
+ rstyles: { type: Array, default: {} },
25
26
  cnames: { type: Object, default: {} },
26
27
  cwidths: { type: Object, default: {} },
27
28
  ctypes: { type: Array, default: [] },
@@ -76,6 +77,7 @@ dmx.Component('ag-grid', {
76
77
  floating_filter: { type: Boolean, default: true },
77
78
  column_hover_highlight: { type: Boolean, default: true },
78
79
  quick_filter_field: { type: String, default: 'search_field' },
80
+ export_exclude_hidden_fields: { type: Boolean, default: false },
79
81
  export_to_csv: { type: Boolean, default: true },
80
82
  export_csv_filename: { type: String, default: 'export.csv' },
81
83
  fixed_header: { type: Boolean, default: false },
@@ -727,7 +729,6 @@ dmx.Component('ag-grid', {
727
729
  const options = {
728
730
  timeZone: timezone,
729
731
  };
730
-
731
732
  const convertedTimestamp = date.toLocaleString(options.date_locale, options);
732
733
  const [datePart, timePart] = convertedTimestamp.split(', ');
733
734
  const [day, month, year] = datePart.split('/');
@@ -754,6 +755,32 @@ dmx.Component('ag-grid', {
754
755
 
755
756
  return valueA.toLowerCase().localeCompare(valueB.toLowerCase());
756
757
  };
758
+ //Custom Row Styles
759
+ function createRowStyleFunction(rstyles) {
760
+ return function(params) {
761
+ if (!rstyles || !Array.isArray(rstyles) || rstyles.length === 0) {
762
+ return; // No styles to apply
763
+ }
764
+ const rowStyle = {};
765
+ for (const style of rstyles) {
766
+ const condition = style.condition.replace(/\(\)$/, ''); // Remove () if present at the end
767
+ const customColor = style.customColor;
768
+ let conditionResult;
769
+ if (typeof window[condition] === 'function') {
770
+ const result = window[condition](params.data);
771
+ if (typeof result !== 'boolean') {
772
+ console.error('Row condition function must return a boolean value.');
773
+ return;
774
+ }
775
+ conditionResult = result;
776
+ }
777
+ if (conditionResult) {
778
+ rowStyle.background = customColor;
779
+ }
780
+ }
781
+ return rowStyle;
782
+ };
783
+ }
757
784
  dateFilterParams = {
758
785
  comparator: function (filterLocalDateAtMidnight, cellValue) {
759
786
  var cellDate = new Date(cellValue);
@@ -842,7 +869,6 @@ dmx.Component('ag-grid', {
842
869
  if (matchingChange && matchingChange.area === 'cell' ) {
843
870
  return matchingChange.new_value;
844
871
  }
845
-
846
872
  // Check if there's a matching change in dataBindedChanges
847
873
  const matchingKeyData = keyLookup[key];
848
874
  if (matchingKeyData) {
@@ -882,14 +908,11 @@ dmx.Component('ag-grid', {
882
908
 
883
909
  return function (params) {
884
910
  const value = params.data[key];
885
-
886
-
887
911
  // Check if there's a matching change in dataChanges
888
912
  const matchingChange = dataChanges.find(change => change.field === key && change.value === String(value));
889
913
  if (matchingChange && matchingChange.area === 'tooltip' ) {
890
914
  return matchingChange.new_value;
891
915
  }
892
-
893
916
  // Check if there's a matching change in dataBindedChanges
894
917
  const matchingKeyData = keyLookup[key];
895
918
  if (matchingKeyData) {
@@ -932,7 +955,6 @@ dmx.Component('ag-grid', {
932
955
 
933
956
  return function (params) {
934
957
  const value = params.data[key];
935
-
936
958
  // Check if there's a matching change in dataChanges
937
959
  const matchingChange = dataChanges.find(change => change.field === key && change.value === String(value));
938
960
  if (matchingChange) {
@@ -1035,22 +1057,43 @@ dmx.Component('ag-grid', {
1035
1057
  function applyCellStyle(params) {
1036
1058
  const field = params.colDef.field.toString();
1037
1059
  const styles = cstyles.filter((cs) => cs.field === field);
1038
- const whiteSpace = options.wrap_text ? 'normal' : 'nowrap'
1060
+ const whiteSpace = options.wrap_text ? 'normal' : 'nowrap';
1039
1061
 
1040
1062
  for (const style of styles) {
1041
1063
  const condition = style.condition;
1042
1064
  const customColor = style.customColor;
1043
1065
  const font = style.font || 'normal';
1044
- const area = style.area || 'text';
1045
- const [left, operator, right] = extractConditionParts(condition);
1046
- if (
1047
- params.data.hasOwnProperty(left) &&
1048
- (params.data[left] !== null ? evaluateCondition(params.data[left], operator, right) : false)
1049
- ) {
1066
+ const area = style.area || 'text';
1067
+ let conditionResult = false;
1068
+ if (condition.endsWith('()') && typeof window[condition.replace(/\(\)$/, '')] === 'function') {
1069
+ const result = window[condition.replace(/\(\)$/, '')](params.data);
1070
+ if (typeof result !== 'boolean') {
1071
+ console.error('Custom condition function must return a boolean value.');
1072
+ return;
1073
+ }
1074
+ conditionResult = result;
1075
+ } else {
1076
+ const [left, operator, right] = extractConditionParts(condition);
1077
+ if (params.data.hasOwnProperty(left) &&
1078
+ (params.data[left] !== null ? evaluateCondition(params.data[left], operator, right) : false)
1079
+ ) {
1080
+ conditionResult = true;
1081
+ }
1082
+ }
1083
+ if (conditionResult) {
1050
1084
  if (area === 'text') {
1051
- return { color: customColor, fontStyle: font, fontWeight: (font==='bold'?'bold':null), whiteSpace: whiteSpace };
1085
+ return {
1086
+ color: customColor,
1087
+ fontStyle: font,
1088
+ fontWeight: (font === 'bold' ? 'bold' : null),
1089
+ whiteSpace: whiteSpace
1090
+ };
1052
1091
  } else if (area === 'cell') {
1053
- return { backgroundColor: customColor, fontStyle: font, whiteSpace: whiteSpace };
1092
+ return {
1093
+ backgroundColor: customColor,
1094
+ fontStyle: font,
1095
+ whiteSpace: whiteSpace
1096
+ };
1054
1097
  }
1055
1098
  }
1056
1099
  }
@@ -1059,7 +1102,6 @@ dmx.Component('ag-grid', {
1059
1102
  }
1060
1103
  return null;
1061
1104
  }
1062
-
1063
1105
  if (cnames.hasOwnProperty(key)) {
1064
1106
  const cname = cnames[key]
1065
1107
  headerName = cname ? cname.custom_name : humanize(key);
@@ -1301,6 +1343,7 @@ dmx.Component('ag-grid', {
1301
1343
  const gridOptions = {
1302
1344
  ...(idFieldPresent ? { getRowId: params => params.data.id } : {}),
1303
1345
  columnDefs: (groupedColumnDefs && groupedColumnDefs.length > 0) ? groupedColumnDefs : columnDefs,
1346
+ getRowStyle: options.rstyles ? createRowStyleFunction(options.rstyles): undefined,
1304
1347
  localeText: localeText,
1305
1348
  enableRtl: options.enable_rtl,
1306
1349
  onRowClicked: enableRowClickEvent ? onRowClicked : undefined,
@@ -1686,25 +1729,26 @@ dmx.Component('ag-grid', {
1686
1729
  fieldsAndColIds.push({
1687
1730
  field: column.field,
1688
1731
  colId: column.colId,
1732
+ hide: column.hide,
1689
1733
  });
1690
1734
  }
1691
1735
  });
1692
1736
  return fieldsAndColIds;
1693
1737
  };
1694
-
1695
1738
  // Traverse columnDefs to gather fields and colIds
1696
1739
  fieldsAndColIds = traverseColumns(gridConfig.columnDefs);
1697
-
1698
- } else {
1699
- fieldsAndColIds = gridConfig.columnDefs.map((column) => ({
1700
- field: column.field,
1701
- colId: column.colId,
1702
- }));
1703
- }
1704
- // Filtering out fields based on excludedColumnIds
1705
- const fieldsToExport = fieldsAndColIds.filter(
1706
- (column) => !excludedColumnIds.includes(column.colId)
1707
- ).map((column) => column.field);
1740
+ } else {
1741
+ fieldsAndColIds = gridConfig.columnDefs.map((column) => ({
1742
+ field: column.field,
1743
+ colId: column.colId,
1744
+ hide: column.hide,
1745
+ }));
1746
+ }
1747
+ const fieldsToExport = fieldsAndColIds.filter((column) => {
1748
+ return !excludedColumnIds.includes(column.colId) &&
1749
+ (!options.export_exclude_hidden_fields || !column.hide);
1750
+ }).map((column) => column.field);
1751
+
1708
1752
  const params = {
1709
1753
  fileName: options.export_csv_filename,
1710
1754
  allColumns: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdmx/wappler_ag_grid",
3
- "version": "1.6.1",
3
+ "version": "1.6.3",
4
4
  "type": "module",
5
5
  "description": "App Connect module for AG Grid Table Generation.",
6
6
  "license": "MIT",