@cdmx/wappler_ag_grid 0.2.1 → 0.2.2
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 +24 -80
- package/package.json +1 -1
package/dmx-ag-grid.js
CHANGED
|
@@ -2,45 +2,7 @@ dmx.Component('ag-grid', {
|
|
|
2
2
|
initialData: {
|
|
3
3
|
id: null,
|
|
4
4
|
data: {},
|
|
5
|
-
fields: {}
|
|
6
|
-
column_defs: [],
|
|
7
|
-
cstyles: null,
|
|
8
|
-
cnames: null,
|
|
9
|
-
cwidths: null,
|
|
10
|
-
data_changes: null,
|
|
11
|
-
gridInstance: null,
|
|
12
|
-
domLayout: 'autoHeight',
|
|
13
|
-
enableCellTextSelection: true,
|
|
14
|
-
rowSelection: null,
|
|
15
|
-
suppressRowDeselection: null,
|
|
16
|
-
pagination: null,
|
|
17
|
-
paginationPageSize: null,
|
|
18
|
-
rowHeight: null,
|
|
19
|
-
headerHeight: null,
|
|
20
|
-
suppressRowClickSelection: null,
|
|
21
|
-
suppressMenuHide: null,
|
|
22
|
-
suppressMovableColumns: null,
|
|
23
|
-
enableCellExpressions: null,
|
|
24
|
-
animateRows: null,
|
|
25
|
-
suppressAggFuncInHeader: null,
|
|
26
|
-
suppressAggAtRootLevel: null,
|
|
27
|
-
suppressClipboardPaste: null,
|
|
28
|
-
suppressScrollOnNewData: null,
|
|
29
|
-
suppressPropertyNamesCheck: null,
|
|
30
|
-
localeText: null,
|
|
31
|
-
minWidth: 150,
|
|
32
|
-
resizable: true,
|
|
33
|
-
sortable: true,
|
|
34
|
-
filter: true,
|
|
35
|
-
floatingFilter: true,
|
|
36
|
-
columnHoverHighlight: true,
|
|
37
|
-
exportToCSV: true,
|
|
38
|
-
fixedHeader: false,
|
|
39
|
-
topbarClass: null,
|
|
40
|
-
fixedHeaderOffset: 100,
|
|
41
|
-
fixedTopOffset: 80,
|
|
42
|
-
fixedHorizonatalScroll: false,
|
|
43
|
-
timezone: null
|
|
5
|
+
fields: {}
|
|
44
6
|
},
|
|
45
7
|
|
|
46
8
|
attributes: {
|
|
@@ -111,31 +73,14 @@ dmx.Component('ag-grid', {
|
|
|
111
73
|
},
|
|
112
74
|
|
|
113
75
|
refreshGrid: function () {
|
|
114
|
-
const
|
|
76
|
+
const options = this.props
|
|
115
77
|
const rowData = this.props.data;
|
|
116
|
-
const fixedHeader = this.props.fixedHeader;
|
|
117
|
-
const fixedHeaderOffset = this.props.fixedHeaderOffset;
|
|
118
|
-
const topbarClass = this.props.topbarClass;
|
|
119
|
-
const fixedTopOffset = this.props.fixedTopOffset;
|
|
120
78
|
const timezone = this.props.timezone || false;
|
|
121
79
|
const dataChanges = this.props.data_changes;
|
|
122
|
-
const grid_theme = this.props.grid_theme;
|
|
123
|
-
const enableCheckboxEvent = this.props.row_checkbox_event;
|
|
124
|
-
const enableStatusToggle = this.props.row_status_event;
|
|
125
|
-
const enableActions = this.props.enable_actions;
|
|
126
|
-
const pin_actions = this.props.pin_actions;
|
|
127
|
-
const edit_action_title = this.props.edit_action_title;
|
|
128
|
-
const edit_action_btn_class = this.props.edit_action_btn_class;
|
|
129
|
-
const edit_action_icon_class = this.props.edit_action_icon_class;
|
|
130
|
-
const view_action_title = this.props.view_action_title;
|
|
131
|
-
const view_action_btn_class = this.props.view_action_btn_class;
|
|
132
|
-
const view_action_icon_class = this.props.view_action_icon_class;
|
|
133
|
-
const edit_action_tooltip = this.props.edit_action_tooltip;
|
|
134
|
-
const view_action_tooltip = this.props.view_action_tooltip;
|
|
135
80
|
|
|
136
81
|
let columnDefs = [];
|
|
137
82
|
let exportToCSV = this.props.exportToCSV;
|
|
138
|
-
this.$node.innerHTML = `<div id=${
|
|
83
|
+
this.$node.innerHTML = `<div id=${options.id}-grid class="${options.grid_theme}"></div>`;
|
|
139
84
|
if (!rowData || rowData.length === 0) {
|
|
140
85
|
console.error('No row data provided.');
|
|
141
86
|
return;
|
|
@@ -162,8 +107,7 @@ dmx.Component('ag-grid', {
|
|
|
162
107
|
function clickCellRenderer(params) {
|
|
163
108
|
const idValue = params.data.id;
|
|
164
109
|
const columnName = params.colDef.field;
|
|
165
|
-
const
|
|
166
|
-
const value = formatValue(params.value, columnName, dataType, timezone);
|
|
110
|
+
const value = params.value
|
|
167
111
|
return `<div onclick="cellClickEvent('${columnName}', '${value}', '${idValue}')" style="cursor: pointer;">${value}</div>`;
|
|
168
112
|
}
|
|
169
113
|
|
|
@@ -451,7 +395,7 @@ dmx.Component('ag-grid', {
|
|
|
451
395
|
else {
|
|
452
396
|
headerName = humanize(key);
|
|
453
397
|
}
|
|
454
|
-
if (key =='status' &&
|
|
398
|
+
if (key =='status' && options.row_status_event) {
|
|
455
399
|
cellRenderer = 'checkboxCellRenderer';
|
|
456
400
|
filter = null;
|
|
457
401
|
}
|
|
@@ -484,7 +428,7 @@ dmx.Component('ag-grid', {
|
|
|
484
428
|
this.dispatchEvent('row_clicked')
|
|
485
429
|
}
|
|
486
430
|
let checkboxColumn;
|
|
487
|
-
if (
|
|
431
|
+
if (options.row_checkbox_event) {
|
|
488
432
|
checkboxColumn = {
|
|
489
433
|
headerCheckboxSelection: true,
|
|
490
434
|
headerCheckboxSelectionFilteredOnly: false,
|
|
@@ -500,21 +444,21 @@ dmx.Component('ag-grid', {
|
|
|
500
444
|
};
|
|
501
445
|
columnDefs.unshift(checkboxColumn);
|
|
502
446
|
}
|
|
503
|
-
if (
|
|
447
|
+
if (options.enable_actions) {
|
|
504
448
|
actionsColumn = {
|
|
505
449
|
headerName: 'Actions',
|
|
506
450
|
field: 'action',
|
|
507
451
|
filter: null,
|
|
508
452
|
cellRenderer: actionsRenderer,
|
|
509
|
-
pinned: pin_actions,
|
|
453
|
+
pinned: options.pin_actions,
|
|
510
454
|
cellRendererParams: {
|
|
511
455
|
// Custom button configurations
|
|
512
456
|
buttons: [
|
|
513
457
|
{
|
|
514
|
-
action: edit_action_title,
|
|
515
|
-
classNames: edit_action_btn_class,
|
|
516
|
-
tooltip: edit_action_tooltip,
|
|
517
|
-
icon: edit_action_icon_class,
|
|
458
|
+
action: options.edit_action_title,
|
|
459
|
+
classNames: options.edit_action_btn_class,
|
|
460
|
+
tooltip: options.edit_action_tooltip,
|
|
461
|
+
icon: options.edit_action_icon_class,
|
|
518
462
|
onClick: (rowData) => {
|
|
519
463
|
this.set('data', rowData);
|
|
520
464
|
this.set('id', rowData.id);
|
|
@@ -522,10 +466,10 @@ dmx.Component('ag-grid', {
|
|
|
522
466
|
},
|
|
523
467
|
},
|
|
524
468
|
{
|
|
525
|
-
action: view_action_title,
|
|
526
|
-
classNames: view_action_btn_class,
|
|
527
|
-
tooltip: view_action_tooltip,
|
|
528
|
-
icon: view_action_icon_class,
|
|
469
|
+
action: options.view_action_title,
|
|
470
|
+
classNames: options.view_action_btn_class,
|
|
471
|
+
tooltip: options.view_action_tooltip,
|
|
472
|
+
icon: options.view_action_icon_class,
|
|
529
473
|
onClick: (rowData) => {
|
|
530
474
|
this.set('data', rowData);
|
|
531
475
|
this.set('id', rowData.id);
|
|
@@ -579,11 +523,11 @@ dmx.Component('ag-grid', {
|
|
|
579
523
|
}
|
|
580
524
|
};
|
|
581
525
|
|
|
582
|
-
const gridDiv = document.getElementById(
|
|
526
|
+
const gridDiv = document.getElementById(options.id+'-grid');
|
|
583
527
|
|
|
584
528
|
|
|
585
529
|
if (!gridDiv) {
|
|
586
|
-
console.error(`Grid container element with ID '${
|
|
530
|
+
console.error(`Grid container element with ID '${options.id}' not found.`);
|
|
587
531
|
return;
|
|
588
532
|
}
|
|
589
533
|
|
|
@@ -597,10 +541,10 @@ dmx.Component('ag-grid', {
|
|
|
597
541
|
};
|
|
598
542
|
// Create ag-Grid instance
|
|
599
543
|
new agGrid.Grid(gridDiv, gridConfig);
|
|
600
|
-
const gridElement = document.getElementById(
|
|
544
|
+
const gridElement = document.getElementById(options.id+'-grid');
|
|
601
545
|
const gridContainer = gridElement.parentNode;
|
|
602
546
|
// Add an event listener to the grid
|
|
603
|
-
if (
|
|
547
|
+
if (options.row_checkbox_event) {
|
|
604
548
|
gridConfig.api.addEventListener('rowSelected', (event) => {
|
|
605
549
|
if (event.node && event.node.isSelected()) {
|
|
606
550
|
const rowData = event.node.data;
|
|
@@ -619,12 +563,12 @@ dmx.Component('ag-grid', {
|
|
|
619
563
|
console.error('Grid container not found.');
|
|
620
564
|
return;
|
|
621
565
|
}
|
|
622
|
-
if (fixedHeader) {
|
|
566
|
+
if (options.fixedHeader) {
|
|
623
567
|
window.addEventListener('scroll', function () {
|
|
624
568
|
const header = document.querySelector('.ag-header');
|
|
625
|
-
const topbar = document.querySelector('.' + topbarClass);
|
|
626
|
-
const topbarHeight = (topbar ? topbar.getBoundingClientRect().height : 0) + fixedTopOffset;
|
|
627
|
-
const headerPos = (topbar ? topbar.getBoundingClientRect().bottom : 0) + fixedHeaderOffset;
|
|
569
|
+
const topbar = document.querySelector('.' + options.topbarClass);
|
|
570
|
+
const topbarHeight = (topbar ? topbar.getBoundingClientRect().height : 0) + options.fixedTopOffset;
|
|
571
|
+
const headerPos = (topbar ? topbar.getBoundingClientRect().bottom : 0) + options.fixedHeaderOffset;
|
|
628
572
|
|
|
629
573
|
if (window.pageYOffset > headerPos) {
|
|
630
574
|
header.style.position = 'fixed';
|