@cdmx/wappler_ag_grid 0.6.0 → 0.6.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 +1 -1
- package/app_connect/components.hjson +84 -30
- package/dmx-ag-grid.js +113 -58
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -233,7 +233,7 @@ Specify the CSS class for styling the icon of the Delete Action button.
|
|
|
233
233
|
- Use Case: Used when you're awaiting the population of specific elements or data before loading the grid. It's also useful for refreshing the grid intentionally.
|
|
234
234
|
|
|
235
235
|
**Reload** (Beta)
|
|
236
|
-
- To be used in conjunction with "No Auto Load"
|
|
236
|
+
- To be used in conjunction with "No Auto Load" enabled
|
|
237
237
|
- This performs a transactional update of the client-side data in the grid after comparing the existing and updated datasets
|
|
238
238
|
- 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
239
|
|
|
@@ -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",
|
|
@@ -1098,12 +1081,74 @@
|
|
|
1098
1081
|
}
|
|
1099
1082
|
]
|
|
1100
1083
|
},
|
|
1084
|
+
{
|
|
1085
|
+
"group": "📒 Column Groups",
|
|
1086
|
+
"variables": [
|
|
1087
|
+
{
|
|
1088
|
+
"name": "groupConfig",
|
|
1089
|
+
"title": "Configure Column Groups",
|
|
1090
|
+
"attribute": "group_configs",
|
|
1091
|
+
"type": "boolean",
|
|
1092
|
+
"defaultValue": false,
|
|
1093
|
+
"display": "fieldset",
|
|
1094
|
+
"show": [
|
|
1095
|
+
"listGroupConfig",
|
|
1096
|
+
],
|
|
1097
|
+
"noChangeOnHide": true,
|
|
1098
|
+
"groupEnabler": true,
|
|
1099
|
+
"help": "Apply Column grouping"
|
|
1100
|
+
"children": [
|
|
1101
|
+
{
|
|
1102
|
+
"name": "listGroupConfig",
|
|
1103
|
+
"attribute": "dmx-bind:group_config",
|
|
1104
|
+
"title": "Group Config",
|
|
1105
|
+
"type": "grid",
|
|
1106
|
+
"dataBindings": true,
|
|
1107
|
+
"jsonFormat": true,
|
|
1108
|
+
"encloseBT": true,
|
|
1109
|
+
"jsonBT": true,
|
|
1110
|
+
"initDisplay": "none",
|
|
1111
|
+
"columns": [
|
|
1112
|
+
{
|
|
1113
|
+
"field": "name",
|
|
1114
|
+
"caption": "Group Name",
|
|
1115
|
+
"size": "25%",
|
|
1116
|
+
"editable": {
|
|
1117
|
+
"type": "text"
|
|
1118
|
+
}
|
|
1119
|
+
},
|
|
1120
|
+
{
|
|
1121
|
+
field: "start_field",
|
|
1122
|
+
caption: "Start Field",
|
|
1123
|
+
size: "25%",
|
|
1124
|
+
editable: {
|
|
1125
|
+
type: "text"
|
|
1126
|
+
}
|
|
1127
|
+
},
|
|
1128
|
+
{
|
|
1129
|
+
field: "end_field",
|
|
1130
|
+
caption: "Start Field",
|
|
1131
|
+
size: "25%",
|
|
1132
|
+
editable: {
|
|
1133
|
+
type: "text"
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
],
|
|
1137
|
+
"newRecord": {
|
|
1138
|
+
"name": "",
|
|
1139
|
+
"start_field": "",
|
|
1140
|
+
"end_field": ""
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
]
|
|
1144
|
+
}
|
|
1145
|
+
]
|
|
1146
|
+
},
|
|
1101
1147
|
{
|
|
1102
1148
|
"group": "📒 Configure Actions Column",
|
|
1103
1149
|
"variables": [
|
|
1104
1150
|
{
|
|
1105
1151
|
"name": "action_column",
|
|
1106
|
-
"attributeStartsWith": "dmx-bind",
|
|
1107
1152
|
"attribute": "action_column",
|
|
1108
1153
|
"title": "Configure Actions",
|
|
1109
1154
|
"type": "boolean",
|
|
@@ -1276,6 +1321,15 @@
|
|
|
1276
1321
|
state : 'opened',
|
|
1277
1322
|
help: 'Reload the AG Grid',
|
|
1278
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: []
|
|
1279
1333
|
}
|
|
1280
1334
|
],
|
|
1281
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,12 +80,13 @@ 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
|
-
compact_view_item_height: { type: Number, default: 20 }
|
|
88
|
+
compact_view_item_height: { type: Number, default: 20 },
|
|
89
|
+
group_config: { type: Array, default: [] }
|
|
89
90
|
},
|
|
90
91
|
|
|
91
92
|
methods: {
|
|
@@ -104,6 +105,15 @@ dmx.Component('ag-grid', {
|
|
|
104
105
|
let gridInstance = this.refreshGrid();
|
|
105
106
|
this.set('gridInstance', gridInstance);
|
|
106
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);
|
|
107
117
|
}
|
|
108
118
|
},
|
|
109
119
|
|
|
@@ -149,6 +159,7 @@ dmx.Component('ag-grid', {
|
|
|
149
159
|
const enableCellClickEvent = this.props.row_click_event && (this.props.enable_actions || this.props.row_checkbox_event);
|
|
150
160
|
let localeText;
|
|
151
161
|
let columnDefs = [];
|
|
162
|
+
let groupedColumnDefs = [];
|
|
152
163
|
let exportToCSV = this.props.export_to_csv;
|
|
153
164
|
let gridInstance = null;
|
|
154
165
|
this.$node.innerHTML = `<div id=${options.id}-grid class="${options.grid_theme}"></div>`;
|
|
@@ -456,8 +467,11 @@ dmx.Component('ag-grid', {
|
|
|
456
467
|
return matchingItem[output];
|
|
457
468
|
}
|
|
458
469
|
}
|
|
459
|
-
if (options.amount_fields
|
|
460
|
-
|
|
470
|
+
if (options.amount_fields) {
|
|
471
|
+
const amountFieldsArray = options.amount_fields.split(',');
|
|
472
|
+
if (amountFieldsArray.includes(key)) {
|
|
473
|
+
return parseFloat(value);
|
|
474
|
+
}
|
|
461
475
|
}
|
|
462
476
|
|
|
463
477
|
// Return the original value if no matching changes were found
|
|
@@ -548,8 +562,11 @@ dmx.Component('ag-grid', {
|
|
|
548
562
|
return matchingItem[output];
|
|
549
563
|
}
|
|
550
564
|
}
|
|
551
|
-
if (options.amount_fields
|
|
552
|
-
|
|
565
|
+
if (options.amount_fields) {
|
|
566
|
+
const amountFieldsArray = options.amount_fields.split(',');
|
|
567
|
+
if (amountFieldsArray.includes(key)) {
|
|
568
|
+
return parseFloat(value);
|
|
569
|
+
}
|
|
553
570
|
}
|
|
554
571
|
// Return the original value if no matching changes were found
|
|
555
572
|
return value;
|
|
@@ -559,7 +576,6 @@ dmx.Component('ag-grid', {
|
|
|
559
576
|
columnDefs = this.props.column_defs;
|
|
560
577
|
} else {
|
|
561
578
|
const firstRow = rowData[0];
|
|
562
|
-
|
|
563
579
|
columnDefs = Object.keys(firstRow).map(key => {
|
|
564
580
|
// Assuming rowData is an array of objects
|
|
565
581
|
const values = rowData.map(row => row[key]);
|
|
@@ -574,22 +590,26 @@ dmx.Component('ag-grid', {
|
|
|
574
590
|
let hide;
|
|
575
591
|
let type;
|
|
576
592
|
let colId;
|
|
593
|
+
let sortable;
|
|
577
594
|
|
|
578
595
|
if (dataType === 'number') {
|
|
579
596
|
filter = 'agNumberColumnFilter';
|
|
580
597
|
if (options.numeric_column_align){
|
|
581
598
|
type = 'numericColumn';
|
|
582
599
|
}
|
|
583
|
-
if (options.amount_fields
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
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
|
+
}
|
|
593
613
|
} else {
|
|
594
614
|
valueFormatter = blankOrNullValueFormatter;
|
|
595
615
|
}
|
|
@@ -704,15 +724,22 @@ dmx.Component('ag-grid', {
|
|
|
704
724
|
colId = 'statusColumn';
|
|
705
725
|
filter = null;
|
|
706
726
|
}
|
|
707
|
-
else if (options.hide_filters
|
|
708
|
-
|
|
727
|
+
else if (options.hide_filters) {
|
|
728
|
+
const hideFiltersArray = options.hide_filters.split(',');
|
|
729
|
+
|
|
730
|
+
if (hideFiltersArray.includes(key)) {
|
|
731
|
+
filter = null;
|
|
732
|
+
}
|
|
709
733
|
}
|
|
710
734
|
else {
|
|
711
735
|
cellRenderer = undefined;
|
|
712
736
|
colId = undefined;
|
|
713
737
|
}
|
|
714
|
-
if (options.hide_sort
|
|
715
|
-
|
|
738
|
+
if (options.hide_sort) {
|
|
739
|
+
const hideSortArray = options.hide_sort.split(',');
|
|
740
|
+
if (hideSortArray.includes(key)) {
|
|
741
|
+
sortable = false;
|
|
742
|
+
}
|
|
716
743
|
}
|
|
717
744
|
else {
|
|
718
745
|
sortable = true;
|
|
@@ -720,13 +747,16 @@ dmx.Component('ag-grid', {
|
|
|
720
747
|
if (options.hide_id_field && key == 'id') {
|
|
721
748
|
hide = true;
|
|
722
749
|
}
|
|
723
|
-
else if (options.hide_fields
|
|
724
|
-
|
|
750
|
+
else if (options.hide_fields) {
|
|
751
|
+
const hideFieldsArray = options.hide_fields.split(',');
|
|
752
|
+
|
|
753
|
+
if (hideFieldsArray.includes(key)) {
|
|
754
|
+
hide = true;
|
|
755
|
+
}
|
|
725
756
|
}
|
|
726
757
|
else {
|
|
727
758
|
hide = undefined;
|
|
728
759
|
}
|
|
729
|
-
|
|
730
760
|
return {
|
|
731
761
|
headerName: headerName,
|
|
732
762
|
field: key,
|
|
@@ -748,6 +778,27 @@ dmx.Component('ag-grid', {
|
|
|
748
778
|
cellRenderer: cellRenderer
|
|
749
779
|
};
|
|
750
780
|
});
|
|
781
|
+
if (options.group_config && options.group_config.length > 0) {
|
|
782
|
+
groupedColumnDefs = options.group_config.map(group => {
|
|
783
|
+
const startFieldIndex = columnDefs.findIndex(colDef => colDef.field === group.start_field);
|
|
784
|
+
const endFieldIndex = columnDefs.findIndex(colDef => colDef.field === group.end_field);
|
|
785
|
+
|
|
786
|
+
if (startFieldIndex === -1 || endFieldIndex === -1 || startFieldIndex > endFieldIndex) {
|
|
787
|
+
return null;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
const groupColumns = columnDefs.slice(startFieldIndex, endFieldIndex + 1)
|
|
791
|
+
.map(col => ({
|
|
792
|
+
...col,
|
|
793
|
+
columnGroupShow: 'open'
|
|
794
|
+
}));
|
|
795
|
+
|
|
796
|
+
return {
|
|
797
|
+
headerName: group.name,
|
|
798
|
+
children: groupColumns
|
|
799
|
+
};
|
|
800
|
+
}).filter(group => group !== null);
|
|
801
|
+
}
|
|
751
802
|
}
|
|
752
803
|
window.onRowClicked = (event) => {
|
|
753
804
|
const rowData = event.data;
|
|
@@ -834,7 +885,7 @@ dmx.Component('ag-grid', {
|
|
|
834
885
|
localeText = AG_GRID_LOCALE_HE
|
|
835
886
|
}
|
|
836
887
|
const gridOptions = {
|
|
837
|
-
columnDefs: columnDefs,
|
|
888
|
+
columnDefs: (groupedColumnDefs && groupedColumnDefs.length > 0) ? groupedColumnDefs : columnDefs,
|
|
838
889
|
localeText: localeText,
|
|
839
890
|
enableRtl: options.enable_rtl,
|
|
840
891
|
noRowsOverlayComponent: '<div>No Records Found.</div>',
|
|
@@ -968,6 +1019,37 @@ dmx.Component('ag-grid', {
|
|
|
968
1019
|
updateHoveringBarStyles();
|
|
969
1020
|
window.addEventListener('resize', updateHoveringBarStyles);
|
|
970
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
|
+
|
|
971
1053
|
// Create the export button
|
|
972
1054
|
if (exportToCSV) {
|
|
973
1055
|
const existingExportButton = document.getElementById('exportButton');
|
|
@@ -999,37 +1081,10 @@ dmx.Component('ag-grid', {
|
|
|
999
1081
|
exportButton.style.borderRadius = '5px';
|
|
1000
1082
|
exportButton.style.cursor = 'pointer';
|
|
1001
1083
|
exportButton.style.marginBottom = '10px';
|
|
1002
|
-
|
|
1084
|
+
|
|
1003
1085
|
exportButton.addEventListener('click', () => {
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
const fieldsAndColIds = gridConfig.columnDefs.map((column) => ({
|
|
1007
|
-
field: column.field,
|
|
1008
|
-
colId: column.colId,
|
|
1009
|
-
}));
|
|
1010
|
-
// Filtering out fields based on excludedColumnIds
|
|
1011
|
-
const fieldsToExport = fieldsAndColIds.filter(
|
|
1012
|
-
(column) => !excludedColumnIds.includes(column.colId)
|
|
1013
|
-
).map((column) => column.field);
|
|
1014
|
-
const params = {
|
|
1015
|
-
fileName: 'export.csv', // Set the desired file name here
|
|
1016
|
-
allColumns: true,
|
|
1017
|
-
columnKeys: fieldsToExport,
|
|
1018
|
-
processCellCallback: function (params) {
|
|
1019
|
-
const columnDef = params.column.getColDef();
|
|
1020
|
-
const valueFormatter = columnDef.valueFormatter;
|
|
1021
|
-
if (valueFormatter && typeof valueFormatter === "function") {
|
|
1022
|
-
const formattedValue = valueFormatter(params);
|
|
1023
|
-
if (formattedValue !== null && formattedValue !== undefined) {
|
|
1024
|
-
return formattedValue;
|
|
1025
|
-
}
|
|
1026
|
-
}
|
|
1027
|
-
return params.value;
|
|
1028
|
-
},
|
|
1029
|
-
};
|
|
1030
|
-
gridConfig.api.exportDataAsCsv(params);
|
|
1031
|
-
});
|
|
1032
|
-
|
|
1086
|
+
exportGridData()
|
|
1087
|
+
})
|
|
1033
1088
|
// Append the export button to the grid container
|
|
1034
1089
|
gridContainer.parentNode.insertBefore(exportButton, gridContainer);
|
|
1035
1090
|
exportButton.style.marginBottom = '10px';
|