I have a seemingly simply problem that has plagued me for several days. Apparently no one else in the history of ag-grid has ever had this problem as the complete lack of Google search results would suggest.
I'm trying to implement a simple value formatter for one of my columns. Here is the column definition...
...
{
headerName: 'OT Unit',
field: 'otUnitCode',
valueFormatter: this.formatOTUnit.bind(this)
},
....
The helper function 'this.formatOTUnit(...)' is defined as such:
formatOTUnit(params) {
console.log(params);
this.service.getOTUnitDesc(params.data.otUnitCode).subscribe((desc) => {
console.log(desc);
return desc;
});
}
Basically this function takes the numeric code that is stored in the JSON, and calls an asynchronous function to get the corresponding description. This description is what I want to display inside the table cell (not the numeric code).
console.log(params) shows me the event object, which contains the code that needs to be translated (params.data.otUnitCode), and console.log(desc) shows the correct description. However, the cell in the table is blank.
What am I missing here? Does ag-grid not support asynchronous callbacks as a valueFormatter?
ICellRendererCompinterface correctly into your cell renderer class you would've seen the refresh method... - nullptr.t