@cdmx/wappler_ag_grid 0.1.3 → 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/app_connect/components.hjson +7 -2
- package/dmx-ag-grid.js +41 -42
- package/package.json +1 -1
|
@@ -18,6 +18,11 @@
|
|
|
18
18
|
"title": "Id",
|
|
19
19
|
"type": "number"
|
|
20
20
|
},
|
|
21
|
+
{
|
|
22
|
+
"name": "data",
|
|
23
|
+
"title": "Data",
|
|
24
|
+
"type": "object"
|
|
25
|
+
}
|
|
21
26
|
{
|
|
22
27
|
"name": "fields",
|
|
23
28
|
"title": "Fields",
|
|
@@ -357,7 +362,7 @@
|
|
|
357
362
|
"title": "Row Click Events",
|
|
358
363
|
"type": "boolean",
|
|
359
364
|
"defaultValue": false,
|
|
360
|
-
"help": "This
|
|
365
|
+
"help": "This enabled row click events which can then be used in Dynamic events => Grid Events => Row Clicked"
|
|
361
366
|
},
|
|
362
367
|
{
|
|
363
368
|
"name": "rowCheckboxEvent",
|
|
@@ -373,7 +378,7 @@
|
|
|
373
378
|
"title": "Enable Row Status Toggle",
|
|
374
379
|
"type": "boolean",
|
|
375
380
|
"defaultValue": false,
|
|
376
|
-
"help": "This
|
|
381
|
+
"help": "This enabled row status events which can then be used in Dynamic events => Grid Events => Checkbox Checked || Checkbox Unchecked"
|
|
377
382
|
}
|
|
378
383
|
]
|
|
379
384
|
},
|
package/dmx-ag-grid.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
dmx.Component('ag-grid', {
|
|
2
2
|
initialData: {
|
|
3
3
|
id: null,
|
|
4
|
-
|
|
4
|
+
data: {},
|
|
5
|
+
fields: {},
|
|
5
6
|
column_defs: [],
|
|
6
7
|
cstyles: null,
|
|
7
8
|
cnames: null,
|
|
@@ -39,8 +40,7 @@ dmx.Component('ag-grid', {
|
|
|
39
40
|
fixedHeaderOffset: 100,
|
|
40
41
|
fixedTopOffset: 80,
|
|
41
42
|
fixedHorizonatalScroll: false,
|
|
42
|
-
timezone: null
|
|
43
|
-
fields: {}
|
|
43
|
+
timezone: null
|
|
44
44
|
},
|
|
45
45
|
|
|
46
46
|
attributes: {
|
|
@@ -85,6 +85,7 @@ dmx.Component('ag-grid', {
|
|
|
85
85
|
fixedTopOffset: { type: Number, default: 80 },
|
|
86
86
|
fixedHorizonatalScroll: { type: Boolean, default: false },
|
|
87
87
|
timezone: {type: Text, default: '' },
|
|
88
|
+
cell_click_event: {type: Boolean, default: false },
|
|
88
89
|
row_click_event: {type: Boolean, default: false },
|
|
89
90
|
row_checkbox_event: {type: Boolean, default: false },
|
|
90
91
|
row_status_event: {type: Boolean, default: false }
|
|
@@ -138,24 +139,10 @@ dmx.Component('ag-grid', {
|
|
|
138
139
|
return blankOrNullValueFormatter(params);
|
|
139
140
|
}
|
|
140
141
|
}
|
|
141
|
-
window.
|
|
142
|
+
window.cellClickEvent = (columnName, value, idValue) => {
|
|
142
143
|
this.set('fields', {"field": columnName, "data": value});
|
|
143
144
|
this.set('id', idValue);
|
|
144
|
-
this.dispatchEvent('
|
|
145
|
-
};
|
|
146
|
-
window.handleCheckboxClick = (event, columnName, value, idValue) => {
|
|
147
|
-
const isChecked = event.target.checked;
|
|
148
|
-
if (isChecked) {
|
|
149
|
-
// Code for when the checkbox is checked
|
|
150
|
-
this.set('id', idValue);
|
|
151
|
-
this.set('fields', {"field": columnName, "data": value});
|
|
152
|
-
this.dispatchEvent('row_checkbox_checked')
|
|
153
|
-
} else {
|
|
154
|
-
// Code for when the checkbox is unchecked
|
|
155
|
-
this.set('id', idValue);
|
|
156
|
-
this.set('fields', {"field": columnName, "data": value});
|
|
157
|
-
this.dispatchEvent('row_checkbox_unchecked')
|
|
158
|
-
}
|
|
145
|
+
this.dispatchEvent('cell_clicked')
|
|
159
146
|
};
|
|
160
147
|
window.handleStatusToggle = (event, columnName, value, idValue) => {
|
|
161
148
|
const isChecked = event.target.checked;
|
|
@@ -176,19 +163,7 @@ dmx.Component('ag-grid', {
|
|
|
176
163
|
const columnName = params.colDef.field;
|
|
177
164
|
const dataType = detectDataType([params.value]);
|
|
178
165
|
const value = formatValue(params.value, columnName, dataType, timezone);
|
|
179
|
-
return `<div onclick="
|
|
180
|
-
}
|
|
181
|
-
function idCheckboxCellRenderer(params) {
|
|
182
|
-
const idValue = params.data.id;
|
|
183
|
-
const columnName = params.colDef.field;
|
|
184
|
-
const dataType = detectDataType([params.value]);
|
|
185
|
-
const value = formatValue(params.value, columnName, dataType, timezone);
|
|
186
|
-
return `
|
|
187
|
-
<input
|
|
188
|
-
type="checkbox"
|
|
189
|
-
onclick="handleCheckboxClick(event, '${columnName}', '${value}', '${idValue}')"
|
|
190
|
-
/>
|
|
191
|
-
`;
|
|
166
|
+
return `<div onclick="cellClickEvent('${columnName}', '${value}', '${idValue}')" style="cursor: pointer;">${value}</div>`;
|
|
192
167
|
}
|
|
193
168
|
|
|
194
169
|
function checkboxCellRenderer(params) {
|
|
@@ -411,7 +386,8 @@ dmx.Component('ag-grid', {
|
|
|
411
386
|
}
|
|
412
387
|
cnames = this.props.cnames
|
|
413
388
|
cwidths = this.props.cwidths
|
|
414
|
-
|
|
389
|
+
enableRowClickEvent = this.props.row_click_event;
|
|
390
|
+
enableCellClickEvent = this.props.cell_click_event;
|
|
415
391
|
if (cnames.hasOwnProperty(key)) {
|
|
416
392
|
console.log(key)
|
|
417
393
|
const cname = cnames[key]
|
|
@@ -432,28 +408,38 @@ dmx.Component('ag-grid', {
|
|
|
432
408
|
minWidth: parseInt(cwidths[key].min_width),
|
|
433
409
|
maxWidth: parseInt(cwidths[key].max_width),
|
|
434
410
|
}),
|
|
435
|
-
cellRenderer:
|
|
411
|
+
cellRenderer: enableCellClickEvent ? 'clickCellRenderer' : (enableStatusToggle ? 'checkboxCellRenderer' : undefined)
|
|
436
412
|
};
|
|
437
413
|
});
|
|
438
414
|
}
|
|
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')
|
|
420
|
+
}
|
|
439
421
|
let checkboxColumn;
|
|
440
422
|
if (enableCheckboxEvent) {
|
|
441
|
-
// Duplicate the column for 'id'
|
|
442
423
|
checkboxColumn = {
|
|
424
|
+
headerCheckboxSelection: true,
|
|
425
|
+
headerCheckboxSelectionFilteredOnly: false,
|
|
443
426
|
headerName: '',
|
|
444
427
|
field: 'id',
|
|
445
428
|
filter: '',
|
|
446
|
-
|
|
429
|
+
checkboxSelection: true,
|
|
430
|
+
showDisabledCheckboxes: true,
|
|
447
431
|
resizable: false,
|
|
448
432
|
width: 50,
|
|
449
433
|
maxWidth: 50,
|
|
450
|
-
suppressMenu: true
|
|
434
|
+
suppressMenu: true
|
|
451
435
|
};
|
|
452
436
|
columnDefs.unshift(checkboxColumn);
|
|
453
437
|
}
|
|
454
438
|
|
|
455
439
|
const gridOptions = {
|
|
456
440
|
columnDefs: columnDefs,
|
|
441
|
+
onRowClicked: enableRowClickEvent ? onRowClicked : undefined,
|
|
442
|
+
rowStyle: enableRowClickEvent ? { cursor: 'pointer' } : undefined,
|
|
457
443
|
defaultColDef: {
|
|
458
444
|
flex: 1,
|
|
459
445
|
minWidth: this.props.minWidth,
|
|
@@ -483,12 +469,12 @@ dmx.Component('ag-grid', {
|
|
|
483
469
|
localeText: this.props.localeText,
|
|
484
470
|
components: {
|
|
485
471
|
clickCellRenderer: clickCellRenderer,
|
|
486
|
-
checkboxCellRenderer: checkboxCellRenderer
|
|
487
|
-
idCheckboxCellRenderer: idCheckboxCellRenderer
|
|
472
|
+
checkboxCellRenderer: checkboxCellRenderer
|
|
488
473
|
}
|
|
489
474
|
};
|
|
490
475
|
|
|
491
476
|
const gridDiv = document.getElementById(gridId+'-grid');
|
|
477
|
+
|
|
492
478
|
|
|
493
479
|
if (!gridDiv) {
|
|
494
480
|
console.error(`Grid container element with ID '${gridId}' not found.`);
|
|
@@ -507,7 +493,20 @@ dmx.Component('ag-grid', {
|
|
|
507
493
|
new agGrid.Grid(gridDiv, gridConfig);
|
|
508
494
|
const gridElement = document.getElementById(gridId+'-grid');
|
|
509
495
|
const gridContainer = gridElement.parentNode;
|
|
510
|
-
|
|
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
|
+
});
|
|
511
510
|
if (!gridContainer) {
|
|
512
511
|
console.error('Grid container not found.');
|
|
513
512
|
return;
|
|
@@ -563,15 +562,15 @@ dmx.Component('ag-grid', {
|
|
|
563
562
|
|
|
564
563
|
events: {
|
|
565
564
|
row_clicked: Event,
|
|
565
|
+
cell_clicked: Event,
|
|
566
566
|
row_checkbox_checked: Event,
|
|
567
567
|
row_checkbox_unchecked: Event,
|
|
568
568
|
row_status_enabled: Event,
|
|
569
|
-
row_status_disabled: Event
|
|
569
|
+
row_status_disabled: Event,
|
|
570
570
|
},
|
|
571
571
|
|
|
572
572
|
render: function(node) {
|
|
573
573
|
if (this.$node) {
|
|
574
|
-
|
|
575
574
|
this.$parse();
|
|
576
575
|
}
|
|
577
576
|
},
|