@cdmx/wappler_ag_grid 1.2.0 → 1.2.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 CHANGED
@@ -135,9 +135,26 @@ This grid allows you to define custom data changes for specific fields. The grid
135
135
  The Display Data Manipulation feature allows you to add custom text, Combine fields data.
136
136
  The grid has the following settings:
137
137
 
138
+ **Using Field Data**
139
+
138
140
  1. **Field**: The field name for which you want to apply the custom data changes.
139
141
  2. **Data**: The value to be replaced in the field data ex: %first_name% %last_name%.
140
142
 
143
+ **Using JS Function**
144
+
145
+ 1. **Field**: The field name for which you want to apply the custom data changes.
146
+ 2. **Function**: Create a JavaScript function that defines the custom rendering logic. In your HTML or script section, define the JS function.
147
+ ex: jsChanges.
148
+
149
+ <script>
150
+ function jsChanges(data) {
151
+ const html = `
152
+ <div style="color: red; line-height: 2;">${data.code}</div>
153
+ <div style="color: green; line-height: 2;">This is a new line in green.</div>`;
154
+ return html;
155
+ }
156
+ </script>
157
+
141
158
  ---
142
159
  # Custom Headers
143
160
 
@@ -904,6 +904,7 @@
904
904
  "display": "fieldset",
905
905
  "show": [
906
906
  "displayDataChanges",
907
+ "jsDataChanges"
907
908
  ],
908
909
  "noChangeOnHide": true,
909
910
  "groupEnabler": true,
@@ -912,7 +913,7 @@
912
913
  {
913
914
  "name": "displayDataChanges",
914
915
  "attribute": "dmx-bind:display_data_changes",
915
- "title": "Fields Data",
916
+ "title": "Using Field Data",
916
917
  "type": "grid",
917
918
  "dataBindings": true,
918
919
  "jsonFormat": true,
@@ -939,6 +940,37 @@
939
940
  "field": "",
940
941
  "data": ""
941
942
  }
943
+ },
944
+ {
945
+ "name": "jsDataChanges",
946
+ "attribute": "dmx-bind:js_data_changes",
947
+ "title": "Using JS Function",
948
+ "type": "grid",
949
+ "dataBindings": true,
950
+ "jsonFormat": true,
951
+ "encloseBT": true,
952
+ "jsonBT": true,
953
+ "initDisplay": "none",
954
+ "columns": [
955
+ {
956
+ "field": "field",
957
+ "caption": "Field",
958
+ "editable": {
959
+ "type": "text"
960
+ }
961
+ },
962
+ {
963
+ field: "function",
964
+ caption: "Function",
965
+ editable: {
966
+ type: "text"
967
+ }
968
+ }
969
+ ],
970
+ "newRecord": {
971
+ "field": "",
972
+ "function": ""
973
+ }
942
974
  }
943
975
  ]
944
976
  }
package/dmx-ag-grid.js CHANGED
@@ -25,6 +25,7 @@ dmx.Component('ag-grid', {
25
25
  wrap_text: { type: Boolean, default: false },
26
26
  data_changes: { type: Array, default: [] },
27
27
  display_data_changes: { type: Array, default: [] },
28
+ js_data_changes: { type: Array, default: [] },
28
29
  data: { type: Array, default: [] },
29
30
  dom_layout: { type: String, default: 'autoHeight' },
30
31
  enable_cell_text_selection: { type: Boolean, default: true },
@@ -728,7 +729,7 @@ dmx.Component('ag-grid', {
728
729
  return cellData;
729
730
  }, value);
730
731
  }
731
-
732
+
732
733
  // Check if there's a matching change in dataChanges
733
734
  const matchingChange = dataChanges.find(change => change.field === key && change.value === String(value));
734
735
  if (matchingChange && matchingChange.area === 'cell' ) {
@@ -953,6 +954,27 @@ dmx.Component('ag-grid', {
953
954
  else {
954
955
  headerName = humanize(key);
955
956
  }
957
+
958
+ if (options.js_data_changes.length > 0 && Array.isArray(options.js_data_changes)) {
959
+ // Check if there's a matching change in jsDataChanges
960
+ const matchingJsChange = options.js_data_changes.find(change => change.field === key);
961
+ if (matchingJsChange) {
962
+ cellRenderer = function (params) {
963
+ if (typeof window[matchingJsChange.function] === 'function') {
964
+ const cellValue = window[matchingJsChange.function](params.data);
965
+ return cellValue;
966
+ }
967
+ }
968
+ }
969
+ else {
970
+ cellRenderer = undefined;
971
+ colId = undefined;
972
+ }
973
+ }
974
+ else {
975
+ cellRenderer = undefined;
976
+ colId = undefined;
977
+ }
956
978
  if (key =='status' && options.row_status_event) {
957
979
  cellRenderer = 'checkboxCellRenderer';
958
980
  colId = 'statusColumn';
@@ -965,10 +987,8 @@ dmx.Component('ag-grid', {
965
987
  filter = null;
966
988
  }
967
989
  }
968
- else {
969
- cellRenderer = undefined;
970
- colId = undefined;
971
- }
990
+
991
+
972
992
  if (options.hide_sort) {
973
993
  const hideSortArray = options.hide_sort.split(',');
974
994
  if (hideSortArray.includes(key)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdmx/wappler_ag_grid",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "type": "module",
5
5
  "description": "App Connect module for AG Grid Table Generation.",
6
6
  "license": "MIT",