@cdmx/wappler_ag_grid 0.1.4 → 0.1.5
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/dmx-ag-grid.js +27 -64
- package/package.json +1 -1
package/dmx-ag-grid.js
CHANGED
|
@@ -144,20 +144,6 @@ dmx.Component('ag-grid', {
|
|
|
144
144
|
this.set('id', idValue);
|
|
145
145
|
this.dispatchEvent('cell_clicked')
|
|
146
146
|
};
|
|
147
|
-
window.handleCheckboxClick = (event, columnName, value, idValue) => {
|
|
148
|
-
const isChecked = event.target.checked;
|
|
149
|
-
if (isChecked) {
|
|
150
|
-
// Code for when the checkbox is checked
|
|
151
|
-
this.set('id', idValue);
|
|
152
|
-
this.set('fields', {"field": columnName, "data": value});
|
|
153
|
-
this.dispatchEvent('row_checkbox_checked')
|
|
154
|
-
} else {
|
|
155
|
-
// Code for when the checkbox is unchecked
|
|
156
|
-
this.set('id', idValue);
|
|
157
|
-
this.set('fields', {"field": columnName, "data": value});
|
|
158
|
-
this.dispatchEvent('row_checkbox_unchecked')
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
147
|
window.handleStatusToggle = (event, columnName, value, idValue) => {
|
|
162
148
|
const isChecked = event.target.checked;
|
|
163
149
|
if (isChecked) {
|
|
@@ -179,18 +165,6 @@ dmx.Component('ag-grid', {
|
|
|
179
165
|
const value = formatValue(params.value, columnName, dataType, timezone);
|
|
180
166
|
return `<div onclick="cellClickEvent('${columnName}', '${value}', '${idValue}')" style="cursor: pointer;">${value}</div>`;
|
|
181
167
|
}
|
|
182
|
-
function idCheckboxCellRenderer(params) {
|
|
183
|
-
const idValue = params.data.id;
|
|
184
|
-
const columnName = params.colDef.field;
|
|
185
|
-
const dataType = detectDataType([params.value]);
|
|
186
|
-
const value = formatValue(params.value, columnName, dataType, timezone);
|
|
187
|
-
return `
|
|
188
|
-
<input
|
|
189
|
-
type="checkbox"
|
|
190
|
-
onclick="handleCheckboxClick(event, '${columnName}', '${value}', '${idValue}')"
|
|
191
|
-
/>
|
|
192
|
-
`;
|
|
193
|
-
}
|
|
194
168
|
|
|
195
169
|
function checkboxCellRenderer(params) {
|
|
196
170
|
const idValue = params.data.id;
|
|
@@ -438,30 +412,13 @@ dmx.Component('ag-grid', {
|
|
|
438
412
|
};
|
|
439
413
|
});
|
|
440
414
|
}
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
const columnName = params.colDef.field;
|
|
447
|
-
const value = params.value;
|
|
448
|
-
|
|
449
|
-
params.api.forEachNode((node) => {
|
|
450
|
-
if (node.rowPinned) return; // Skip pinned rows
|
|
451
|
-
if (node.visible) {
|
|
452
|
-
const idValue = node.data.id;
|
|
453
|
-
cellClickEvent(columnName, value, idValue);
|
|
454
|
-
node.setSelected(eHeaderCheckbox.checked);
|
|
455
|
-
}
|
|
456
|
-
});
|
|
457
|
-
});
|
|
458
|
-
|
|
459
|
-
const eLabel = document.createElement('label');
|
|
460
|
-
eLabel.appendChild(eHeaderCheckbox);
|
|
461
|
-
eLabel.appendChild(document.createTextNode('Select All'));
|
|
462
|
-
|
|
463
|
-
return eLabel;
|
|
415
|
+
window.onRowClicked = (event) => {
|
|
416
|
+
const rowData = event.data;
|
|
417
|
+
this.set('data', rowData);
|
|
418
|
+
this.set('id', rowData.id);
|
|
419
|
+
this.dispatchEvent('row_clicked')
|
|
464
420
|
}
|
|
421
|
+
let checkboxColumn;
|
|
465
422
|
if (enableCheckboxEvent) {
|
|
466
423
|
checkboxColumn = {
|
|
467
424
|
headerCheckboxSelection: true,
|
|
@@ -469,21 +426,15 @@ dmx.Component('ag-grid', {
|
|
|
469
426
|
headerName: '',
|
|
470
427
|
field: 'id',
|
|
471
428
|
filter: '',
|
|
472
|
-
|
|
429
|
+
checkboxSelection: true,
|
|
430
|
+
showDisabledCheckboxes: true,
|
|
473
431
|
resizable: false,
|
|
474
432
|
width: 50,
|
|
475
433
|
maxWidth: 50,
|
|
476
|
-
suppressMenu: true
|
|
477
|
-
// headerComponent: 'headerCheckbox'
|
|
434
|
+
suppressMenu: true
|
|
478
435
|
};
|
|
479
436
|
columnDefs.unshift(checkboxColumn);
|
|
480
437
|
}
|
|
481
|
-
window.onRowClicked = (event) => {
|
|
482
|
-
const rowData = event.data;
|
|
483
|
-
this.set('data', rowData);
|
|
484
|
-
this.set('id', rowData.id);
|
|
485
|
-
this.dispatchEvent('row_clicked')
|
|
486
|
-
}
|
|
487
438
|
|
|
488
439
|
const gridOptions = {
|
|
489
440
|
columnDefs: columnDefs,
|
|
@@ -518,13 +469,12 @@ dmx.Component('ag-grid', {
|
|
|
518
469
|
localeText: this.props.localeText,
|
|
519
470
|
components: {
|
|
520
471
|
clickCellRenderer: clickCellRenderer,
|
|
521
|
-
checkboxCellRenderer: checkboxCellRenderer
|
|
522
|
-
idCheckboxCellRenderer: idCheckboxCellRenderer,
|
|
523
|
-
headerCheckbox: headerCheckbox
|
|
472
|
+
checkboxCellRenderer: checkboxCellRenderer
|
|
524
473
|
}
|
|
525
474
|
};
|
|
526
475
|
|
|
527
476
|
const gridDiv = document.getElementById(gridId+'-grid');
|
|
477
|
+
|
|
528
478
|
|
|
529
479
|
if (!gridDiv) {
|
|
530
480
|
console.error(`Grid container element with ID '${gridId}' not found.`);
|
|
@@ -543,7 +493,20 @@ dmx.Component('ag-grid', {
|
|
|
543
493
|
new agGrid.Grid(gridDiv, gridConfig);
|
|
544
494
|
const gridElement = document.getElementById(gridId+'-grid');
|
|
545
495
|
const gridContainer = gridElement.parentNode;
|
|
546
|
-
|
|
496
|
+
// Add an event listener to the grid
|
|
497
|
+
gridConfig.api.addEventListener('rowSelected', (event) => {
|
|
498
|
+
if (event.node && event.node.isSelected()) {
|
|
499
|
+
const rowData = event.node.data;
|
|
500
|
+
this.set('data', rowData);
|
|
501
|
+
this.set('id', rowData.id);
|
|
502
|
+
this.dispatchEvent('row_checkbox_checked');
|
|
503
|
+
} else {
|
|
504
|
+
const rowData = event.node.data;
|
|
505
|
+
this.set('data', rowData);
|
|
506
|
+
this.set('id', rowData.id);
|
|
507
|
+
this.dispatchEvent('row_checkbox_unchecked');
|
|
508
|
+
}
|
|
509
|
+
});
|
|
547
510
|
if (!gridContainer) {
|
|
548
511
|
console.error('Grid container not found.');
|
|
549
512
|
return;
|
|
@@ -599,15 +562,15 @@ dmx.Component('ag-grid', {
|
|
|
599
562
|
|
|
600
563
|
events: {
|
|
601
564
|
row_clicked: Event,
|
|
565
|
+
cell_clicked: Event,
|
|
602
566
|
row_checkbox_checked: Event,
|
|
603
567
|
row_checkbox_unchecked: Event,
|
|
604
568
|
row_status_enabled: Event,
|
|
605
|
-
row_status_disabled: Event
|
|
569
|
+
row_status_disabled: Event,
|
|
606
570
|
},
|
|
607
571
|
|
|
608
572
|
render: function(node) {
|
|
609
573
|
if (this.$node) {
|
|
610
|
-
|
|
611
574
|
this.$parse();
|
|
612
575
|
}
|
|
613
576
|
},
|