What I’m trying to do:
I want to use Tabulator to change the background color for each cell by value, but it doesn’t change when I specify the color code in ‘formatter’ key’s value.
Changing the row_background in Container Properties does not seem to change row color.
Code Sample:
class Test(TestTemplate):
def __init__(self, **properties):
# Set Form properties and Data Bindings.
self.init_components(**properties)
self.tabulator.data = Globals.global_value_dict['rows']
self.tabulator.columns = [
{'id': '0', 'title': '', 'field': '0', 'data_key': '0', 'headerSort': False, 'formatter': '#ff0'},
{'id': '1', 'title': '', 'field': '1', 'data_key': '1', 'headerSort': False, 'formatter': '#f00'},
{'id': '2', 'title': '1', 'field': '2', 'data_key': '2', 'headerSort': False, 'formatter': '#fff'},
]
def form_show(self, **event_args):
"""This method is called when the HTML panel is shown on the screen"""
if not self.visible:
self.update()
self.visible = True
The above issue has been resolved.
However, a new problem is that when I try to replace the data in tabulator.data, I get an error as below. TypeError: <lambda>() missing 1 required argument: 'formatterParams'
When I open this Anvil App I get: AttributeError: The following column option(s) are invalid: 'id', 'data_key', 'cellFormatter'. You may need to include the required Module in Tabulator.modules.
at app/tabulator/Tabulator/_custom_modules.py:314
Can you please help, Stu, as I too want to have Tabulator make a custom color background depending on the cell value and am struggling with the steps required to do this! thank you!
@CyCy this app was created with Tabulator v1.0.0
You can see the app working as expected if you pin the version to Tabulator v1.0.0 in the Dependency Settings.
thank you Stu - would you be so kind to just simply explain the steps I can take for the latest version of Tabulator to have a column where if the number in a cell > 5 then it is shaded yellow? I will gladly send good vibes your way for a simple solution I can implement using the current (amazing) version of Tabulator for Anvil! thank you sir!