anvilistas / tabulator

Anvil Wrapper for Tabulator
MIT License
18 stars 5 forks source link

Update Column Definition with formatterParams - TypeError #106

Closed NicoN13 closed 1 year ago

NicoN13 commented 1 year ago

Hi @s-cork,

I have a tabulator component on my form and depending on a user input, I need to update the displayed value in a column.

I can update a column definition by getting the column component and using column.updateDefinition({ }) on it. It works fine except when we need to update the formatter parameters.

Here is a sample column definition: {"title": "My Title", "formatter": myFormatter, "formatterParams": {"value_type": "units"}}

If I wish to update the value_type, I can't say column.updateDefinition({"formatterParams": {"valueType": "currency"}}) because it throws the following type error:

TypeError: <lambda>() got an unexpected keyword argument 'units'
at app/tabulator/Tabulator/_helpers.py:142

I have a work around by updating the column definition by including the formatter again as such: column.updateDefinition({"formatter": myFormatter,"formatterParams": {"valueType": "currency"}})

Just thought might be worth mentioning.

s-cork commented 1 year ago

Yeah I guess that's to do with the internals of tabulator js. I don't do anything special here with params so I'm inclined to think your work around is probably the correct solution.