Custom Component Value Formatter

  • Goal: Set up a custom component table using the AG Grid example given in the Retool depository with custom formats given in the columnDefs section using valueFormatter

  • Steps: I've set up my filter as the default, which works for most of my cases, however I would like 1 specific column to have a currency format but using the valueFormatter: params => params.data.(column name) provided in this blog gives me a for each error. Surrounding it in quotes results in it placing the format replacing the listed value. That said, removing the params=> section results in the code apparently running but it repeatedly giving the error that params isn't defined in the console and doesn't change the formatted values. Using {{}} format makes the value formatter disappear from the visible selection on the retool provided preview and also doesn't work.

My assumption is that I'm simply not using the correct format, and I thank you for your assistance.

The answer was gotten via including a call to the console log to see all the parameters that exist within the quotes. One of these parameter is the 'value' variable, which contains the cells default data so within the columnDefs, one of my columns reads as { "headerName": "Example Header", "field": "example_source", "minWidth":140, "valueFormatter": "new Intl.NumberFormat('en-US', {style: 'decimal',}).format(value)" },

I hope this helps anyone who is having a similar issue.

2 Likes