@cdmx/wappler_ag_grid 0.9.2 → 0.9.4
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 +4 -0
- package/app_connect/components.hjson +22 -2
- package/dmx-ag-grid.js +35 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -341,6 +341,10 @@ Specify the tooltip text for Button 10.
|
|
|
341
341
|
- This action enables you to reset the grid's column state to default state.
|
|
342
342
|
- It is useful when you want to revert the column configuration to a default configuration.
|
|
343
343
|
|
|
344
|
+
**Pin Columns to Left**
|
|
345
|
+
- This action allows you to pin one or more columns to the left side of the grid.
|
|
346
|
+
- It is useful when you want to freeze specific columns in place for easy reference, even as you scroll horizontally.
|
|
347
|
+
|
|
344
348
|
**Import File Data**
|
|
345
349
|
- The "Import File Data" action allows to import data from CSV and XLSX files into the AG Grid. This action simplifies the process of populating the grid with external data sources.
|
|
346
350
|
- Key Features:
|
|
@@ -1851,9 +1851,29 @@
|
|
|
1851
1851
|
name: 'resetColumnState',
|
|
1852
1852
|
icon: 'fa fa-lg fa-undo',
|
|
1853
1853
|
state: 'opened',
|
|
1854
|
-
help: '
|
|
1854
|
+
help: 'Reset Column State stored in Browser Local Storage',
|
|
1855
1855
|
properties: []
|
|
1856
1856
|
},
|
|
1857
|
+
{
|
|
1858
|
+
addTitle: 'pinColumnsState',
|
|
1859
|
+
title: 'Pin Columns',
|
|
1860
|
+
name: 'pinColumns',
|
|
1861
|
+
icon: 'fa fa-lg fa-thumbtack',
|
|
1862
|
+
state: 'opened',
|
|
1863
|
+
help: 'Pin Columns to Left',
|
|
1864
|
+
properties: [
|
|
1865
|
+
{
|
|
1866
|
+
group: 'Properties',
|
|
1867
|
+
variables: [
|
|
1868
|
+
{
|
|
1869
|
+
name: '1', optionName: '1', title: 'Column Name', type: 'text',
|
|
1870
|
+
dataBindings: true, defaultValue: '', required: true,
|
|
1871
|
+
help: 'Column Name to Pin to the Left'
|
|
1872
|
+
}
|
|
1873
|
+
]
|
|
1874
|
+
}
|
|
1875
|
+
]
|
|
1876
|
+
},
|
|
1857
1877
|
{
|
|
1858
1878
|
addTitle: 'importFileData',
|
|
1859
1879
|
title: 'Import File Data',
|
|
@@ -1867,7 +1887,7 @@
|
|
|
1867
1887
|
variables: [
|
|
1868
1888
|
{
|
|
1869
1889
|
name: '1', optionName: '1', title: 'File Field ID', type: 'text',
|
|
1870
|
-
dataBindings: true, defaultValue: 'csvfile', required: true,
|
|
1890
|
+
dataBindings: true, defaultValue: '"csvfile"', required: true,
|
|
1871
1891
|
help: 'Field ID of the file to import'
|
|
1872
1892
|
}
|
|
1873
1893
|
]
|
package/dmx-ag-grid.js
CHANGED
|
@@ -178,17 +178,24 @@ dmx.Component('ag-grid', {
|
|
|
178
178
|
if (typeof saveColumnStateToStorage === 'function') {
|
|
179
179
|
saveColumnStateToStorage();
|
|
180
180
|
} else {
|
|
181
|
-
console.error('Grid not loaded to perform
|
|
181
|
+
console.error('Grid not loaded to perform save column state');
|
|
182
182
|
}
|
|
183
183
|
}, this);
|
|
184
184
|
},
|
|
185
185
|
resetColumnState: function () {
|
|
186
186
|
dmx.nextTick(function() {
|
|
187
|
-
|
|
187
|
+
const idValue = this.$node.querySelector('dmx-ag-grid > div')?.getAttribute('id') ?? 'Grid not found';
|
|
188
|
+
const currentPageUrl = window.location.origin + window.location.pathname;
|
|
189
|
+
const uniqueId = `${currentPageUrl}_${idValue}`;
|
|
190
|
+
console.log(uniqueId)
|
|
191
|
+
localStorage.removeItem(`columnState_${uniqueId}`);
|
|
188
192
|
let gridInstance = this.refreshGrid();
|
|
189
193
|
this.set('gridInstance', gridInstance);
|
|
190
194
|
}, this);
|
|
191
195
|
},
|
|
196
|
+
pinColumns: function (fieldId) {
|
|
197
|
+
pinColumnToLeft(fieldId);
|
|
198
|
+
},
|
|
192
199
|
importFileData: async function (fieldId) {
|
|
193
200
|
await this.parseFileData(fieldId);
|
|
194
201
|
},
|
|
@@ -275,13 +282,15 @@ dmx.Component('ag-grid', {
|
|
|
275
282
|
};
|
|
276
283
|
|
|
277
284
|
const fileInput = document.getElementById(fieldId);
|
|
285
|
+
if (!fileInput) {
|
|
286
|
+
console.error('Field having field Id: '+fieldId+' not found.');
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
278
289
|
const file = fileInput.files[0];
|
|
279
|
-
|
|
280
290
|
if (!file) {
|
|
281
291
|
console.error('Please select a file.');
|
|
282
292
|
return;
|
|
283
293
|
}
|
|
284
|
-
|
|
285
294
|
const reader = new FileReader();
|
|
286
295
|
reader.onload = async (e) => {
|
|
287
296
|
const fileData = e.target.result;
|
|
@@ -1154,7 +1163,7 @@ dmx.Component('ag-grid', {
|
|
|
1154
1163
|
|
|
1155
1164
|
|
|
1156
1165
|
if (!gridDiv) {
|
|
1157
|
-
console.error(`Grid container element with ID '${options.id}' not found.`);
|
|
1166
|
+
console.error(`Grid container element with ID '${options.id}'-grid not found.`);
|
|
1158
1167
|
return;
|
|
1159
1168
|
}
|
|
1160
1169
|
|
|
@@ -1162,15 +1171,33 @@ dmx.Component('ag-grid', {
|
|
|
1162
1171
|
gridInstance.destroy();
|
|
1163
1172
|
gridInstance = null;
|
|
1164
1173
|
}
|
|
1174
|
+
const getPageId = () => {
|
|
1175
|
+
const currentPageUrl = window.location.origin + window.location.pathname;
|
|
1176
|
+
const optionsId = options.id+'-grid';
|
|
1177
|
+
const uniqueId = `${currentPageUrl}_${optionsId}`;
|
|
1178
|
+
return uniqueId;
|
|
1179
|
+
};
|
|
1165
1180
|
const gridConfig = {
|
|
1166
1181
|
onGridReady: function (params) {
|
|
1167
1182
|
const columnApi = params.columnApi;
|
|
1183
|
+
pinColumnToLeft = (fieldToPin) => {
|
|
1184
|
+
const columnState = columnApi.getColumnState();
|
|
1185
|
+
const columnIndex = columnState.findIndex(column => column.colId === fieldToPin);
|
|
1186
|
+
if (columnIndex !== -1) {
|
|
1187
|
+
for (let i = 0; i <= columnIndex; i++) {
|
|
1188
|
+
columnState[i].pinned = 'left';
|
|
1189
|
+
}
|
|
1190
|
+
columnApi.applyColumnState({ state: columnState });
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1168
1193
|
saveColumnStateToStorage = () => {
|
|
1169
1194
|
const columnState = columnApi.getColumnState();
|
|
1170
|
-
|
|
1195
|
+
const pageId = getPageId();
|
|
1196
|
+
localStorage.setItem(`columnState_${pageId}`, JSON.stringify(columnState));
|
|
1171
1197
|
}
|
|
1172
1198
|
function restoreColumnState() {
|
|
1173
|
-
const
|
|
1199
|
+
const pageId = getPageId();
|
|
1200
|
+
const savedColumnState = JSON.parse(localStorage.getItem(`columnState_${pageId}`));
|
|
1174
1201
|
if (savedColumnState) {
|
|
1175
1202
|
columnApi.applyColumnState({
|
|
1176
1203
|
state: savedColumnState,
|
|
@@ -1335,23 +1362,19 @@ dmx.Component('ag-grid', {
|
|
|
1335
1362
|
// Create the export button
|
|
1336
1363
|
if (exportToCSV) {
|
|
1337
1364
|
const existingExportButton = document.getElementById('exportButton');
|
|
1338
|
-
// If it already exists, just exit the function
|
|
1339
1365
|
if (existingExportButton) {
|
|
1340
1366
|
return;
|
|
1341
1367
|
}
|
|
1342
1368
|
const exportButton = document.createElement('button');
|
|
1343
1369
|
exportButton.id = 'exportButton';
|
|
1344
|
-
|
|
1345
|
-
// Add the icon
|
|
1346
1370
|
const icon = document.createElement('i');
|
|
1347
|
-
icon.classList.add('fas', 'fa-file-csv');
|
|
1371
|
+
icon.classList.add('fas', 'fa-file-csv');
|
|
1348
1372
|
exportButton.appendChild(icon);
|
|
1349
1373
|
|
|
1350
1374
|
// Add the button text
|
|
1351
1375
|
const buttonText = document.createElement('span');
|
|
1352
1376
|
buttonText.innerText = ' Export to CSV';
|
|
1353
1377
|
exportButton.appendChild(buttonText);
|
|
1354
|
-
// Add some fancy styles to the button
|
|
1355
1378
|
exportButton.style.backgroundColor = '#4CAF50';
|
|
1356
1379
|
exportButton.style.border = 'none';
|
|
1357
1380
|
exportButton.style.color = 'white';
|