International number formatting

I need to use the Brazilian number format. This page shows this:

"valueFormatter": {"function": "'$' + (params.value ? params.value : 0)"},

The output is 1,234.56. The Brazilian format is the opposite: 1.234,56. I can’t figure out how to do it by passing a function like above. Is that a JavaScript function?

The locale module can do it:

import locale
locale.setlocale(locale.LC_ALL, 'pt_BR.UTF8')
print(locale.format_string('%10.2f', 738213.78, grouping=True))

Can I use a Python function as the valueFormatter? Or should I just format the number as string before passing it to grid?

I found it:

valueFormatter= {"function": "(params.value ? params.value : 0).toLocaleString('pt-BR',{minimumFractionDigits: 2})"}

3 Likes