@cdmx/wappler_ag_grid 1.7.6 → 1.7.8
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 +3 -2
- package/dmx-ag-grid.js +51 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -126,6 +126,7 @@ This grid allows you to define custom color and font settings based on specific
|
|
|
126
126
|
return (data.status == 'success');
|
|
127
127
|
}
|
|
128
128
|
</script>
|
|
129
|
+
```
|
|
129
130
|
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
131
|
|
|
131
132
|
# Tooltip Settings
|
|
@@ -185,7 +186,7 @@ The grid has the following settings:
|
|
|
185
186
|
1. **Field**: The field name for which you want to apply the custom data changes.
|
|
186
187
|
2. **Function**: Create a JavaScript function that defines the custom rendering logic. In your HTML or script section, define the JS function.
|
|
187
188
|
ex: jsChanges.
|
|
188
|
-
|
|
189
|
+
```javascript
|
|
189
190
|
<script>
|
|
190
191
|
function jsChanges(data) {
|
|
191
192
|
const html = `
|
|
@@ -194,7 +195,7 @@ ex: jsChanges.
|
|
|
194
195
|
return html;
|
|
195
196
|
}
|
|
196
197
|
</script>
|
|
197
|
-
|
|
198
|
+
```
|
|
198
199
|
---
|
|
199
200
|
# Custom Headers
|
|
200
201
|
|
package/dmx-ag-grid.js
CHANGED
|
@@ -728,6 +728,32 @@ dmx.Component('ag-grid', {
|
|
|
728
728
|
}
|
|
729
729
|
});
|
|
730
730
|
}
|
|
731
|
+
function getDateForComparison(value, timezone) {
|
|
732
|
+
if (value) {
|
|
733
|
+
const date = new Date(value);
|
|
734
|
+
if (timezone) {
|
|
735
|
+
const options = {
|
|
736
|
+
timeZone: timezone,
|
|
737
|
+
year: 'numeric',
|
|
738
|
+
month: '2-digit',
|
|
739
|
+
day: '2-digit',
|
|
740
|
+
hour: '2-digit',
|
|
741
|
+
minute: '2-digit',
|
|
742
|
+
second: '2-digit',
|
|
743
|
+
hour12: false,
|
|
744
|
+
};
|
|
745
|
+
const convertedTimestamp = date.toLocaleString('en-US', options);
|
|
746
|
+
const [datePart, timePart] = convertedTimestamp.split(', ');
|
|
747
|
+
const [month, day, year] = datePart.split('/');
|
|
748
|
+
const [hours, minutes, seconds] = timePart.split(':');
|
|
749
|
+
return new Date(`${year}-${month}-${day}T${hours}:${minutes}:${seconds}`);
|
|
750
|
+
} else {
|
|
751
|
+
return date;
|
|
752
|
+
}
|
|
753
|
+
} else {
|
|
754
|
+
return null;
|
|
755
|
+
}
|
|
756
|
+
}
|
|
731
757
|
function formatTime(params, timezone) {
|
|
732
758
|
if (params.value) {
|
|
733
759
|
const date = new Date(params.value)
|
|
@@ -789,9 +815,8 @@ dmx.Component('ag-grid', {
|
|
|
789
815
|
}
|
|
790
816
|
dateFilterParams = {
|
|
791
817
|
comparator: function (filterLocalDateAtMidnight, cellValue) {
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
818
|
+
const cellDate = getDateForComparison(cellValue, timezone);
|
|
819
|
+
const filterDate = new Date(filterLocalDateAtMidnight);
|
|
795
820
|
// Compare the date portion of the cell value with the filter value
|
|
796
821
|
var cellDateOnly = new Date(cellDate.getFullYear(), cellDate.getMonth(), cellDate.getDate());
|
|
797
822
|
var filterDateOnly = new Date(filterDate.getFullYear(), filterDate.getMonth(), filterDate.getDate());
|
|
@@ -1165,8 +1190,8 @@ dmx.Component('ag-grid', {
|
|
|
1165
1190
|
filter = null;
|
|
1166
1191
|
}
|
|
1167
1192
|
}
|
|
1168
|
-
|
|
1169
|
-
|
|
1193
|
+
|
|
1194
|
+
|
|
1170
1195
|
if (options.hide_sort) {
|
|
1171
1196
|
const hideSortArray = options.hide_sort.split(',');
|
|
1172
1197
|
if (hideSortArray.includes(key)) {
|
|
@@ -1205,7 +1230,7 @@ dmx.Component('ag-grid', {
|
|
|
1205
1230
|
}
|
|
1206
1231
|
}
|
|
1207
1232
|
function lookupValue(mappings, key) {
|
|
1208
|
-
if (key==''||key === undefined){
|
|
1233
|
+
if (mappings === undefined || key==''||key === undefined){
|
|
1209
1234
|
return options.cselect_placeholder
|
|
1210
1235
|
}
|
|
1211
1236
|
return mappings[key];
|
|
@@ -1214,6 +1239,8 @@ dmx.Component('ag-grid', {
|
|
|
1214
1239
|
editable = true;
|
|
1215
1240
|
cellEditor = 'agSelectCellEditor';
|
|
1216
1241
|
valueFormatter = (params) => {
|
|
1242
|
+
if (params.api.isDestroyed()) return;
|
|
1243
|
+
|
|
1217
1244
|
const selectedNode = params.api.getSelectedNodes()[0];
|
|
1218
1245
|
const dynamicOptions = options.cdynamic_select_editors[key];
|
|
1219
1246
|
const staticOptions = options.cstatic_select_editors[key];
|
|
@@ -1228,7 +1255,7 @@ dmx.Component('ag-grid', {
|
|
|
1228
1255
|
} else {
|
|
1229
1256
|
selectOptions = selectedNode?.data[dynamicOptions.options_field];
|
|
1230
1257
|
}
|
|
1231
|
-
|
|
1258
|
+
return lookupValue(selectOptions, params.value);
|
|
1232
1259
|
};
|
|
1233
1260
|
valueParser = (params) => {
|
|
1234
1261
|
return lookupKey(selectOptions, params.newValue);
|
|
@@ -1317,7 +1344,7 @@ dmx.Component('ag-grid', {
|
|
|
1317
1344
|
editable: false,
|
|
1318
1345
|
width: 50,
|
|
1319
1346
|
maxWidth: 50,
|
|
1320
|
-
|
|
1347
|
+
suppressHeaderMenuButton: true
|
|
1321
1348
|
};
|
|
1322
1349
|
columnDefs.unshift(checkboxColumn);
|
|
1323
1350
|
}
|
|
@@ -1852,7 +1879,22 @@ dmx.Component('ag-grid', {
|
|
|
1852
1879
|
processCellCallback: function (params) {
|
|
1853
1880
|
const columnDef = params.column.getColDef();
|
|
1854
1881
|
const valueFormatter = columnDef.valueFormatter;
|
|
1855
|
-
|
|
1882
|
+
const cellRenderer = columnDef.cellRenderer;
|
|
1883
|
+
// Apply cellRenderer if it exists
|
|
1884
|
+
if (cellRenderer && typeof cellRenderer === "function") {
|
|
1885
|
+
const cellRendererParams = {
|
|
1886
|
+
value: params.value,
|
|
1887
|
+
data: params.node.data,
|
|
1888
|
+
node: params.node,
|
|
1889
|
+
colDef: columnDef,
|
|
1890
|
+
column: params.column,
|
|
1891
|
+
api: params.api,
|
|
1892
|
+
context: params.context,
|
|
1893
|
+
};
|
|
1894
|
+
const cellRendererValue = cellRenderer(cellRendererParams);
|
|
1895
|
+
return cellRendererValue;
|
|
1896
|
+
}
|
|
1897
|
+
else if (valueFormatter && typeof valueFormatter === "function") {
|
|
1856
1898
|
const formattedValue = valueFormatter(params);
|
|
1857
1899
|
if (formattedValue !== null && formattedValue !== undefined) {
|
|
1858
1900
|
return formattedValue;
|