@cdmx/wappler_ag_grid 0.1.3 → 0.1.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/app_connect/components.hjson +7 -2
- package/dmx-ag-grid.js +46 -10
- 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,10 +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
|
+
this.dispatchEvent('cell_clicked')
|
|
145
146
|
};
|
|
146
147
|
window.handleCheckboxClick = (event, columnName, value, idValue) => {
|
|
147
148
|
const isChecked = event.target.checked;
|
|
@@ -176,7 +177,7 @@ dmx.Component('ag-grid', {
|
|
|
176
177
|
const columnName = params.colDef.field;
|
|
177
178
|
const dataType = detectDataType([params.value]);
|
|
178
179
|
const value = formatValue(params.value, columnName, dataType, timezone);
|
|
179
|
-
return `<div onclick="
|
|
180
|
+
return `<div onclick="cellClickEvent('${columnName}', '${value}', '${idValue}')" style="cursor: pointer;">${value}</div>`;
|
|
180
181
|
}
|
|
181
182
|
function idCheckboxCellRenderer(params) {
|
|
182
183
|
const idValue = params.data.id;
|
|
@@ -411,7 +412,8 @@ dmx.Component('ag-grid', {
|
|
|
411
412
|
}
|
|
412
413
|
cnames = this.props.cnames
|
|
413
414
|
cwidths = this.props.cwidths
|
|
414
|
-
|
|
415
|
+
enableRowClickEvent = this.props.row_click_event;
|
|
416
|
+
enableCellClickEvent = this.props.cell_click_event;
|
|
415
417
|
if (cnames.hasOwnProperty(key)) {
|
|
416
418
|
console.log(key)
|
|
417
419
|
const cname = cnames[key]
|
|
@@ -432,14 +434,38 @@ dmx.Component('ag-grid', {
|
|
|
432
434
|
minWidth: parseInt(cwidths[key].min_width),
|
|
433
435
|
maxWidth: parseInt(cwidths[key].max_width),
|
|
434
436
|
}),
|
|
435
|
-
cellRenderer:
|
|
437
|
+
cellRenderer: enableCellClickEvent ? 'clickCellRenderer' : (enableStatusToggle ? 'checkboxCellRenderer' : undefined)
|
|
436
438
|
};
|
|
437
439
|
});
|
|
438
440
|
}
|
|
439
441
|
let checkboxColumn;
|
|
442
|
+
function headerCheckbox(params) {
|
|
443
|
+
const eHeaderCheckbox = document.createElement('input');
|
|
444
|
+
eHeaderCheckbox.type = 'checkbox';
|
|
445
|
+
eHeaderCheckbox.addEventListener('change', () => {
|
|
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;
|
|
464
|
+
}
|
|
440
465
|
if (enableCheckboxEvent) {
|
|
441
|
-
// Duplicate the column for 'id'
|
|
442
466
|
checkboxColumn = {
|
|
467
|
+
headerCheckboxSelection: true,
|
|
468
|
+
headerCheckboxSelectionFilteredOnly: false,
|
|
443
469
|
headerName: '',
|
|
444
470
|
field: 'id',
|
|
445
471
|
filter: '',
|
|
@@ -448,12 +474,21 @@ dmx.Component('ag-grid', {
|
|
|
448
474
|
width: 50,
|
|
449
475
|
maxWidth: 50,
|
|
450
476
|
suppressMenu: true,
|
|
477
|
+
// headerComponent: 'headerCheckbox'
|
|
451
478
|
};
|
|
452
479
|
columnDefs.unshift(checkboxColumn);
|
|
453
480
|
}
|
|
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
|
+
}
|
|
454
487
|
|
|
455
488
|
const gridOptions = {
|
|
456
489
|
columnDefs: columnDefs,
|
|
490
|
+
onRowClicked: enableRowClickEvent ? onRowClicked : undefined,
|
|
491
|
+
rowStyle: enableRowClickEvent ? { cursor: 'pointer' } : undefined,
|
|
457
492
|
defaultColDef: {
|
|
458
493
|
flex: 1,
|
|
459
494
|
minWidth: this.props.minWidth,
|
|
@@ -484,7 +519,8 @@ dmx.Component('ag-grid', {
|
|
|
484
519
|
components: {
|
|
485
520
|
clickCellRenderer: clickCellRenderer,
|
|
486
521
|
checkboxCellRenderer: checkboxCellRenderer,
|
|
487
|
-
idCheckboxCellRenderer: idCheckboxCellRenderer
|
|
522
|
+
idCheckboxCellRenderer: idCheckboxCellRenderer,
|
|
523
|
+
headerCheckbox: headerCheckbox
|
|
488
524
|
}
|
|
489
525
|
};
|
|
490
526
|
|