@cdmx/wappler_ag_grid 1.1.9 → 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 +17 -0
- package/app_connect/components.hjson +67 -1
- package/dmx-ag-grid.js +27 -6
- package/package.json +1 -1
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": "
|
|
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
|
}
|
|
@@ -2504,6 +2536,40 @@
|
|
|
2504
2536
|
"allowedOn": {
|
|
2505
2537
|
"dmx-ag-grid": true
|
|
2506
2538
|
}
|
|
2539
|
+
},
|
|
2540
|
+
{
|
|
2541
|
+
"name": "dmx-ag-grid-export-filename",
|
|
2542
|
+
"attributeStartsWith": "dmx-bind",
|
|
2543
|
+
"attribute": "export_csv_filename",
|
|
2544
|
+
"title": "Export CSV Filename",
|
|
2545
|
+
"type": "boolean",
|
|
2546
|
+
"display": "fieldset",
|
|
2547
|
+
"icon": "fa fa-lg fa-chevron-right",
|
|
2548
|
+
"groupTitle": "Grid Config",
|
|
2549
|
+
"groupIcon": "fa fa-lg fa-cubes",
|
|
2550
|
+
"defaultValue": false,
|
|
2551
|
+
"show": [
|
|
2552
|
+
"exportCsvFilename"
|
|
2553
|
+
],
|
|
2554
|
+
"noChangeOnHide": true,
|
|
2555
|
+
"groupEnabler": true,
|
|
2556
|
+
"children": [
|
|
2557
|
+
{
|
|
2558
|
+
"name": "exportCsvFilename",
|
|
2559
|
+
"attributeStartsWith": "dmx-bind",
|
|
2560
|
+
"attribute": "export_csv_filename",
|
|
2561
|
+
"isValue": true,
|
|
2562
|
+
"dataBindings": true,
|
|
2563
|
+
"title": "CSV Filename",
|
|
2564
|
+
"type": "text",
|
|
2565
|
+
"help": "Export CSV filename.",
|
|
2566
|
+
"defaultValue": "export.csv",
|
|
2567
|
+
"initDisplay": "none"
|
|
2568
|
+
}
|
|
2569
|
+
],
|
|
2570
|
+
"allowedOn": {
|
|
2571
|
+
"dmx-ag-grid": true
|
|
2572
|
+
}
|
|
2507
2573
|
}
|
|
2508
2574
|
],
|
|
2509
2575
|
"events": [
|
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 },
|
|
@@ -60,6 +61,7 @@ dmx.Component('ag-grid', {
|
|
|
60
61
|
floating_filter: { type: Boolean, default: true },
|
|
61
62
|
column_hover_highlight: { type: Boolean, default: true },
|
|
62
63
|
export_to_csv: { type: Boolean, default: true },
|
|
64
|
+
export_csv_filename: { type: String, default: 'export.csv' },
|
|
63
65
|
fixed_header: { type: Boolean, default: false },
|
|
64
66
|
topbar_class: { type: String, default: 'topbar' },
|
|
65
67
|
fixed_header_offset: { type: Number, default: 100 },
|
|
@@ -727,7 +729,7 @@ dmx.Component('ag-grid', {
|
|
|
727
729
|
return cellData;
|
|
728
730
|
}, value);
|
|
729
731
|
}
|
|
730
|
-
|
|
732
|
+
|
|
731
733
|
// Check if there's a matching change in dataChanges
|
|
732
734
|
const matchingChange = dataChanges.find(change => change.field === key && change.value === String(value));
|
|
733
735
|
if (matchingChange && matchingChange.area === 'cell' ) {
|
|
@@ -952,6 +954,27 @@ dmx.Component('ag-grid', {
|
|
|
952
954
|
else {
|
|
953
955
|
headerName = humanize(key);
|
|
954
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
|
+
}
|
|
955
978
|
if (key =='status' && options.row_status_event) {
|
|
956
979
|
cellRenderer = 'checkboxCellRenderer';
|
|
957
980
|
colId = 'statusColumn';
|
|
@@ -964,10 +987,8 @@ dmx.Component('ag-grid', {
|
|
|
964
987
|
filter = null;
|
|
965
988
|
}
|
|
966
989
|
}
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
colId = undefined;
|
|
970
|
-
}
|
|
990
|
+
|
|
991
|
+
|
|
971
992
|
if (options.hide_sort) {
|
|
972
993
|
const hideSortArray = options.hide_sort.split(',');
|
|
973
994
|
if (hideSortArray.includes(key)) {
|
|
@@ -1488,7 +1509,7 @@ dmx.Component('ag-grid', {
|
|
|
1488
1509
|
(column) => !excludedColumnIds.includes(column.colId)
|
|
1489
1510
|
).map((column) => column.field);
|
|
1490
1511
|
const params = {
|
|
1491
|
-
fileName:
|
|
1512
|
+
fileName: options.export_csv_filename,
|
|
1492
1513
|
allColumns: true,
|
|
1493
1514
|
columnKeys: fieldsToExport,
|
|
1494
1515
|
processCellCallback: function (params) {
|