'ag-grid - Set cellRendererParams to data.field items so they are usable in cellRenderer
I am working on an AG-Grid using JavaScript and am having difficulty passing additional parameters for use in a cellRenderer using cellRendererParams and valueGetter.
I have stripped this down to get rid of everything else while I troubleshoot what I am doing wrong.
First in my columnDefs I have these two columns (among others)
{ headerName: 'Test Getter', field: 'subType',
cellRenderer: LinkRenderer,
cellRendererParams: {
isNew: true,
valueGetter: (params) => ({ sizeL: params.data.size, fileNameL: params.data.fileName }),
},
suppressMenu: true, resizable: false, width: 120 },
{ headerName: 'Testing2', valueGetter: 'data.size + data.fileName', resizable: true },
And my simple cellRenderer class:
class LinkRenderer {
init(params) {
this.eGui = document.createElement('span');
// var ext = params.isNew;
var ext = params.sizeL;
this.eGui.innerHTML = `${ext}`;
}
getGui() {
return this.eGui;
}
refresh(params) {
return false;
}
}
There are a couple things to note in my code to hopefully show some tests I have done to make sure I have access to the data, and do have my cellRendererParams working for non-data strings.
- The column just below the one in question - that valueGetter is getting the data in those to fields just fine.
- The isNew parameter that is added first in cellRendererParams is accessible in the cellRenderer and works fine.
I am not sure where my problem is. I have tried all sorts of different things with the valueGetter that is inside the cellRendererParams, and I have tried all sorts of ways to address the fields in the cellRenderer but everything I try returns undefined.
Any thoughts or ideas?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
