@cdmx/wappler_ag_grid 0.6.1 → 0.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 +25 -11
- package/app_connect/components.hjson +22 -30
- package/dmx-ag-grid.js +88 -54
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -112,6 +112,9 @@ This grid allows you to define custom data changes for specific fields. The grid
|
|
|
112
112
|
3. **New Value**: The new value to replace the original value in the field data.
|
|
113
113
|
4. **Area**: Choose where to apply the data changes: "cell" (cell text) or "tooltip" (tooltip text).
|
|
114
114
|
|
|
115
|
+
**Amount Fields** (Type: textbox, Default: null)
|
|
116
|
+
- Define the fields where the comma-separation and float parsing need to be applied.
|
|
117
|
+
|
|
115
118
|
---
|
|
116
119
|
**Configure Header Names**
|
|
117
120
|
This grid allows you to define custom header names for specific columns. The grid has the following columns:
|
|
@@ -152,16 +155,6 @@ Enter the names of the sort filters you want to hide separated by commas. The sp
|
|
|
152
155
|
|
|
153
156
|
---
|
|
154
157
|
|
|
155
|
-
# Amount Fields
|
|
156
|
-
The amount fields configuration consists of the following parameters:
|
|
157
|
-
|
|
158
|
-
- **Amount Fields** (Type: checkbox, Default: false)
|
|
159
|
-
- Enable or disable the comma-separation for amount fields.
|
|
160
|
-
|
|
161
|
-
- **Amount Fields** (Type: textbox, Default: null)
|
|
162
|
-
- Define the fields where the comma-separation and float parsing need to be applied.
|
|
163
|
-
---
|
|
164
|
-
|
|
165
158
|
# Compact View
|
|
166
159
|
The compact view configuration consists of the following parameters:
|
|
167
160
|
|
|
@@ -173,7 +166,24 @@ The compact view configuration consists of the following parameters:
|
|
|
173
166
|
|
|
174
167
|
- **Grid Item Height** (Type: number, Default: 20)
|
|
175
168
|
- Set the height of each item in the compact view.
|
|
176
|
-
|
|
169
|
+
---
|
|
170
|
+
# Column Groups
|
|
171
|
+
|
|
172
|
+
This feature allows you to organize and group columns for a more structured presentation of data. Instead of using the built-in top left corner button, you can opt for a separate Export button that triggers the action to download data as a CSV file.
|
|
173
|
+
|
|
174
|
+
## Group Configuration
|
|
175
|
+
This option enables column grouping functionality.
|
|
176
|
+
|
|
177
|
+
### Group Configurations
|
|
178
|
+
|
|
179
|
+
This option allows you separate fields into different groups.
|
|
180
|
+
Each configuration includes:
|
|
181
|
+
- **Group Name**: Assign a name to the group for easy identification.
|
|
182
|
+
- **Start Field**: Specify the starting field of the group.
|
|
183
|
+
- **End Field**: Define the ending field of the group.
|
|
184
|
+
|
|
185
|
+
These configurations help you create organized and logical groupings of columns for your data presentation needs.
|
|
186
|
+
|
|
177
187
|
---
|
|
178
188
|
|
|
179
189
|
# Configure Actions Column
|
|
@@ -237,6 +247,10 @@ Specify the CSS class for styling the icon of the Delete Action button.
|
|
|
237
247
|
- This performs a transactional update of the client-side data in the grid after comparing the existing and updated datasets
|
|
238
248
|
- To use this: Enable "No Auto Load", On Edit or update actions, perform an SC load, On Success of SC load perform the AG Grid Module Reload Action.
|
|
239
249
|
|
|
250
|
+
**Export**
|
|
251
|
+
- To be used if you wish to use a separate Export button instead of using the inbuilt top left-cornered Export button.
|
|
252
|
+
- Trigger this action to call Export Data to CSV download action.
|
|
253
|
+
|
|
240
254
|
## License
|
|
241
255
|
|
|
242
256
|
The AG Grid module is licensed under the MIT License. Please refer to the license file for more details.
|
|
@@ -264,6 +264,7 @@
|
|
|
264
264
|
{
|
|
265
265
|
"name": "fixedHeader",
|
|
266
266
|
"title": "Sticky Header and Horizontal Scrollbar",
|
|
267
|
+
"attribute": "f_header",
|
|
267
268
|
"type": "boolean",
|
|
268
269
|
"display": "fieldset",
|
|
269
270
|
"noChangeOnHide": true,
|
|
@@ -791,7 +792,8 @@
|
|
|
791
792
|
"defaultValue": false,
|
|
792
793
|
"display": "fieldset",
|
|
793
794
|
"show": [
|
|
794
|
-
"dataChanges"
|
|
795
|
+
"dataChanges",
|
|
796
|
+
"amountFields"
|
|
795
797
|
],
|
|
796
798
|
"noChangeOnHide": true,
|
|
797
799
|
"groupEnabler": true,
|
|
@@ -847,6 +849,13 @@
|
|
|
847
849
|
"new_value": "",
|
|
848
850
|
"area": "cell"
|
|
849
851
|
}
|
|
852
|
+
},
|
|
853
|
+
{
|
|
854
|
+
"name": "amountFields",
|
|
855
|
+
"attribute": "amount_fields",
|
|
856
|
+
"title": "Amount Fields",
|
|
857
|
+
"type": "text",
|
|
858
|
+
"initDisplay": "none"
|
|
850
859
|
}
|
|
851
860
|
]
|
|
852
861
|
}
|
|
@@ -994,7 +1003,7 @@
|
|
|
994
1003
|
"show": [
|
|
995
1004
|
"hideFields",
|
|
996
1005
|
"hideFilters",
|
|
997
|
-
"hideSort"
|
|
1006
|
+
"hideSort"
|
|
998
1007
|
],
|
|
999
1008
|
"noChangeOnHide": true,
|
|
1000
1009
|
"groupEnabler": true,
|
|
@@ -1025,39 +1034,13 @@
|
|
|
1025
1034
|
}
|
|
1026
1035
|
]
|
|
1027
1036
|
},
|
|
1028
|
-
{
|
|
1029
|
-
"group": "📒 Amount Fields",
|
|
1030
|
-
"variables": [
|
|
1031
|
-
{
|
|
1032
|
-
"name": "amount_fields",
|
|
1033
|
-
"title": "Amount Fields Config",
|
|
1034
|
-
"type": "boolean",
|
|
1035
|
-
"defaultValue": false,
|
|
1036
|
-
"display": "fieldset",
|
|
1037
|
-
"show": [
|
|
1038
|
-
"amountFields"
|
|
1039
|
-
],
|
|
1040
|
-
"noChangeOnHide": true,
|
|
1041
|
-
"groupEnabler": true,
|
|
1042
|
-
"help": "Configure amount fields to have comma-seperation implemented"
|
|
1043
|
-
"children": [
|
|
1044
|
-
{
|
|
1045
|
-
"name": "amountFields",
|
|
1046
|
-
"attribute": "amount_fields",
|
|
1047
|
-
"title": "Amount Fields",
|
|
1048
|
-
"type": "text",
|
|
1049
|
-
"initDisplay": "none"
|
|
1050
|
-
}
|
|
1051
|
-
]
|
|
1052
|
-
}
|
|
1053
|
-
]
|
|
1054
|
-
},
|
|
1055
1037
|
{
|
|
1056
1038
|
"group": "📒 Compact View",
|
|
1057
1039
|
"variables": [
|
|
1058
1040
|
{
|
|
1059
1041
|
"name": "compact_view",
|
|
1060
1042
|
"title": "Compact View Config",
|
|
1043
|
+
"attribute": "compact_views",
|
|
1061
1044
|
"type": "boolean",
|
|
1062
1045
|
"defaultValue": false,
|
|
1063
1046
|
"display": "fieldset",
|
|
@@ -1104,6 +1087,7 @@
|
|
|
1104
1087
|
{
|
|
1105
1088
|
"name": "groupConfig",
|
|
1106
1089
|
"title": "Configure Column Groups",
|
|
1090
|
+
"attribute": "group_configs",
|
|
1107
1091
|
"type": "boolean",
|
|
1108
1092
|
"defaultValue": false,
|
|
1109
1093
|
"display": "fieldset",
|
|
@@ -1165,7 +1149,6 @@
|
|
|
1165
1149
|
"variables": [
|
|
1166
1150
|
{
|
|
1167
1151
|
"name": "action_column",
|
|
1168
|
-
"attributeStartsWith": "dmx-bind",
|
|
1169
1152
|
"attribute": "action_column",
|
|
1170
1153
|
"title": "Configure Actions",
|
|
1171
1154
|
"type": "boolean",
|
|
@@ -1338,6 +1321,15 @@
|
|
|
1338
1321
|
state : 'opened',
|
|
1339
1322
|
help: 'Reload the AG Grid',
|
|
1340
1323
|
properties : []
|
|
1324
|
+
},
|
|
1325
|
+
{
|
|
1326
|
+
addTitle: 'Export',
|
|
1327
|
+
title: 'Export',
|
|
1328
|
+
name: 'exportGrid',
|
|
1329
|
+
icon: 'fa fa-lg fa-download',
|
|
1330
|
+
state: 'opened',
|
|
1331
|
+
help: 'Export AG Grid Data to CSV',
|
|
1332
|
+
properties: []
|
|
1341
1333
|
}
|
|
1342
1334
|
],
|
|
1343
1335
|
"children": [],
|
package/dmx-ag-grid.js
CHANGED
|
@@ -43,7 +43,7 @@ dmx.Component('ag-grid', {
|
|
|
43
43
|
locale_text: { type: String, default: null },
|
|
44
44
|
date_locale: { type: String, default: 'en-IN' },
|
|
45
45
|
date_format: { type: String, default: 'dd/MM/yyyy hh:mm A' },
|
|
46
|
-
amount_fields: { type:
|
|
46
|
+
amount_fields: { type: String, default: null },
|
|
47
47
|
min_width: { type: Number, default: 150 },
|
|
48
48
|
sortable: { type: Boolean, default: true },
|
|
49
49
|
resizable: { type: Boolean, default: true },
|
|
@@ -80,9 +80,9 @@ dmx.Component('ag-grid', {
|
|
|
80
80
|
delete_action_icon_class: {type: String, default: 'fas fa-trash' },
|
|
81
81
|
delete_action_btn_class: {type: String, default: 'btn-danger btn-xs' },
|
|
82
82
|
data_binded_changes: {type: Array, default: [] },
|
|
83
|
-
hide_fields: {type:
|
|
84
|
-
hide_filters: {type:
|
|
85
|
-
hide_sort: {type:
|
|
83
|
+
hide_fields: {type: String, default: null },
|
|
84
|
+
hide_filters: {type: String, default: null },
|
|
85
|
+
hide_sort: {type: String, default: null },
|
|
86
86
|
compact_view: { type: Boolean, default: false },
|
|
87
87
|
compact_view_grid_size: { type: Number, default: 3 },
|
|
88
88
|
compact_view_item_height: { type: Number, default: 20 },
|
|
@@ -105,6 +105,15 @@ dmx.Component('ag-grid', {
|
|
|
105
105
|
let gridInstance = this.refreshGrid();
|
|
106
106
|
this.set('gridInstance', gridInstance);
|
|
107
107
|
}, this);
|
|
108
|
+
},
|
|
109
|
+
exportGrid: function () {
|
|
110
|
+
dmx.nextTick(function() {
|
|
111
|
+
if (typeof exportGridData === 'function') {
|
|
112
|
+
exportGridData();
|
|
113
|
+
} else {
|
|
114
|
+
console.error('Grid not loaded to perform export');
|
|
115
|
+
}
|
|
116
|
+
}, this);
|
|
108
117
|
}
|
|
109
118
|
},
|
|
110
119
|
|
|
@@ -458,8 +467,11 @@ dmx.Component('ag-grid', {
|
|
|
458
467
|
return matchingItem[output];
|
|
459
468
|
}
|
|
460
469
|
}
|
|
461
|
-
if (options.amount_fields
|
|
462
|
-
|
|
470
|
+
if (options.amount_fields) {
|
|
471
|
+
const amountFieldsArray = options.amount_fields.split(',');
|
|
472
|
+
if (amountFieldsArray.includes(key)) {
|
|
473
|
+
return parseFloat(value);
|
|
474
|
+
}
|
|
463
475
|
}
|
|
464
476
|
|
|
465
477
|
// Return the original value if no matching changes were found
|
|
@@ -550,8 +562,11 @@ dmx.Component('ag-grid', {
|
|
|
550
562
|
return matchingItem[output];
|
|
551
563
|
}
|
|
552
564
|
}
|
|
553
|
-
if (options.amount_fields
|
|
554
|
-
|
|
565
|
+
if (options.amount_fields) {
|
|
566
|
+
const amountFieldsArray = options.amount_fields.split(',');
|
|
567
|
+
if (amountFieldsArray.includes(key)) {
|
|
568
|
+
return parseFloat(value);
|
|
569
|
+
}
|
|
555
570
|
}
|
|
556
571
|
// Return the original value if no matching changes were found
|
|
557
572
|
return value;
|
|
@@ -575,22 +590,26 @@ dmx.Component('ag-grid', {
|
|
|
575
590
|
let hide;
|
|
576
591
|
let type;
|
|
577
592
|
let colId;
|
|
593
|
+
let sortable;
|
|
578
594
|
|
|
579
595
|
if (dataType === 'number') {
|
|
580
596
|
filter = 'agNumberColumnFilter';
|
|
581
597
|
if (options.numeric_column_align){
|
|
582
598
|
type = 'numericColumn';
|
|
583
599
|
}
|
|
584
|
-
if (options.amount_fields
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
600
|
+
if (options.amount_fields) {
|
|
601
|
+
const amountFieldsArray = options.amount_fields.split(',');
|
|
602
|
+
if (amountFieldsArray.includes(key)) {
|
|
603
|
+
valueFormatter = function (params) {
|
|
604
|
+
if (params.value != null) {
|
|
605
|
+
return Number(params.value).toLocaleString("en-US", {
|
|
606
|
+
minimumFractionDigits: 2,
|
|
607
|
+
maximumFractionDigits: 2,
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
return '-';
|
|
611
|
+
};
|
|
612
|
+
}
|
|
594
613
|
} else {
|
|
595
614
|
valueFormatter = blankOrNullValueFormatter;
|
|
596
615
|
}
|
|
@@ -705,15 +724,22 @@ dmx.Component('ag-grid', {
|
|
|
705
724
|
colId = 'statusColumn';
|
|
706
725
|
filter = null;
|
|
707
726
|
}
|
|
708
|
-
else if (options.hide_filters
|
|
709
|
-
|
|
727
|
+
else if (options.hide_filters) {
|
|
728
|
+
const hideFiltersArray = options.hide_filters.split(',');
|
|
729
|
+
|
|
730
|
+
if (hideFiltersArray.includes(key)) {
|
|
731
|
+
filter = null;
|
|
732
|
+
}
|
|
710
733
|
}
|
|
711
734
|
else {
|
|
712
735
|
cellRenderer = undefined;
|
|
713
736
|
colId = undefined;
|
|
714
737
|
}
|
|
715
|
-
if (options.hide_sort
|
|
716
|
-
|
|
738
|
+
if (options.hide_sort) {
|
|
739
|
+
const hideSortArray = options.hide_sort.split(',');
|
|
740
|
+
if (hideSortArray.includes(key)) {
|
|
741
|
+
sortable = false;
|
|
742
|
+
}
|
|
717
743
|
}
|
|
718
744
|
else {
|
|
719
745
|
sortable = true;
|
|
@@ -721,8 +747,12 @@ dmx.Component('ag-grid', {
|
|
|
721
747
|
if (options.hide_id_field && key == 'id') {
|
|
722
748
|
hide = true;
|
|
723
749
|
}
|
|
724
|
-
else if (options.hide_fields
|
|
725
|
-
|
|
750
|
+
else if (options.hide_fields) {
|
|
751
|
+
const hideFieldsArray = options.hide_fields.split(',');
|
|
752
|
+
|
|
753
|
+
if (hideFieldsArray.includes(key)) {
|
|
754
|
+
hide = true;
|
|
755
|
+
}
|
|
726
756
|
}
|
|
727
757
|
else {
|
|
728
758
|
hide = undefined;
|
|
@@ -989,6 +1019,37 @@ dmx.Component('ag-grid', {
|
|
|
989
1019
|
updateHoveringBarStyles();
|
|
990
1020
|
window.addEventListener('resize', updateHoveringBarStyles);
|
|
991
1021
|
|
|
1022
|
+
//CSV Export Function
|
|
1023
|
+
exportGridData = () => {
|
|
1024
|
+
const excludedColumnIds = ['checkboxColumn', 'actionsColumn'];
|
|
1025
|
+
// Extracting fields and colIds from columnDefs
|
|
1026
|
+
const fieldsAndColIds = gridConfig.columnDefs.map((column) => ({
|
|
1027
|
+
field: column.field,
|
|
1028
|
+
colId: column.colId,
|
|
1029
|
+
}));
|
|
1030
|
+
// Filtering out fields based on excludedColumnIds
|
|
1031
|
+
const fieldsToExport = fieldsAndColIds.filter(
|
|
1032
|
+
(column) => !excludedColumnIds.includes(column.colId)
|
|
1033
|
+
).map((column) => column.field);
|
|
1034
|
+
const params = {
|
|
1035
|
+
fileName: 'export.csv', // Set the desired file name here
|
|
1036
|
+
allColumns: true,
|
|
1037
|
+
columnKeys: fieldsToExport,
|
|
1038
|
+
processCellCallback: function (params) {
|
|
1039
|
+
const columnDef = params.column.getColDef();
|
|
1040
|
+
const valueFormatter = columnDef.valueFormatter;
|
|
1041
|
+
if (valueFormatter && typeof valueFormatter === "function") {
|
|
1042
|
+
const formattedValue = valueFormatter(params);
|
|
1043
|
+
if (formattedValue !== null && formattedValue !== undefined) {
|
|
1044
|
+
return formattedValue;
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
return params.value;
|
|
1048
|
+
},
|
|
1049
|
+
};
|
|
1050
|
+
gridConfig.api.exportDataAsCsv(params);
|
|
1051
|
+
};
|
|
1052
|
+
|
|
992
1053
|
// Create the export button
|
|
993
1054
|
if (exportToCSV) {
|
|
994
1055
|
const existingExportButton = document.getElementById('exportButton');
|
|
@@ -1020,37 +1081,10 @@ dmx.Component('ag-grid', {
|
|
|
1020
1081
|
exportButton.style.borderRadius = '5px';
|
|
1021
1082
|
exportButton.style.cursor = 'pointer';
|
|
1022
1083
|
exportButton.style.marginBottom = '10px';
|
|
1023
|
-
|
|
1084
|
+
|
|
1024
1085
|
exportButton.addEventListener('click', () => {
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
const fieldsAndColIds = gridConfig.columnDefs.map((column) => ({
|
|
1028
|
-
field: column.field,
|
|
1029
|
-
colId: column.colId,
|
|
1030
|
-
}));
|
|
1031
|
-
// Filtering out fields based on excludedColumnIds
|
|
1032
|
-
const fieldsToExport = fieldsAndColIds.filter(
|
|
1033
|
-
(column) => !excludedColumnIds.includes(column.colId)
|
|
1034
|
-
).map((column) => column.field);
|
|
1035
|
-
const params = {
|
|
1036
|
-
fileName: 'export.csv', // Set the desired file name here
|
|
1037
|
-
allColumns: true,
|
|
1038
|
-
columnKeys: fieldsToExport,
|
|
1039
|
-
processCellCallback: function (params) {
|
|
1040
|
-
const columnDef = params.column.getColDef();
|
|
1041
|
-
const valueFormatter = columnDef.valueFormatter;
|
|
1042
|
-
if (valueFormatter && typeof valueFormatter === "function") {
|
|
1043
|
-
const formattedValue = valueFormatter(params);
|
|
1044
|
-
if (formattedValue !== null && formattedValue !== undefined) {
|
|
1045
|
-
return formattedValue;
|
|
1046
|
-
}
|
|
1047
|
-
}
|
|
1048
|
-
return params.value;
|
|
1049
|
-
},
|
|
1050
|
-
};
|
|
1051
|
-
gridConfig.api.exportDataAsCsv(params);
|
|
1052
|
-
});
|
|
1053
|
-
|
|
1086
|
+
exportGridData()
|
|
1087
|
+
})
|
|
1054
1088
|
// Append the export button to the grid container
|
|
1055
1089
|
gridContainer.parentNode.insertBefore(exportButton, gridContainer);
|
|
1056
1090
|
exportButton.style.marginBottom = '10px';
|