anvilistas / tabulator

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

Unable to get nested rows to work #142

Closed akrishnamo closed 7 months ago

akrishnamo commented 7 months ago

I am unable to get the children rows to display, not sure what is not working

image

        self.tabulator_1.data_tree = True
        self.tabulator_1.data_tree_start_expanded = False  # Start with the tree collapsed

        # Define columns for the Tabulator component
        self.tabulator_1.columns = [
            {"title": "ID", "field": "id", "formatter": "plaintext"},
            {"title": "Name", "field": "name", "formatter": "plaintext"},
            {"title": "Position", "field": "position", "formatter": "plaintext"}
        ]

        # Sample hierarchical data with nested rows
        data = [
            {"id": 1, "name": "John Doe", "position": "CEO", "_children": [
                {"id": 2, "name": "Jane Doe", "position": "CFO"},
                {"id": 3, "name": "Richard Roe", "position": "CTO", "_children": [
                    {"id": 4, "name": "Alice Roe", "position": "Senior Engineer"},
                    {"id": 5, "name": "Bob Roe", "position": "Junior Engineer"}
                ]}
            ]},
            {"id": 6, "name": "Emily Smith", "position": "Marketing Director"}
        ]

        # Set the data for the Tabulator component
        self.tabulator_1.data = data
s-cork commented 7 months ago

Where are you inferring data_tree as a valid attribute? Typically you put these in the tabulator.options dictionary

akrishnamo commented 7 months ago

tried that earlier, didn't work. Am i doing this wrong?

self.tabulator_1.options={'data_tree': True, 'data_tree_start_expanded' : True} 

AttributeError: The following table option(s) are invalid: 'dataTree', 'dataTreeStartExpanded'. You may need to include the required Module in Tabulator.modules.
at app/tabulator/Tabulator/_custom_modules.py:331
s-cork commented 7 months ago

Take a look at the readme. You'll need to add the data tree module. The DataTree module is not loaded by default

akrishnamo commented 7 months ago

Works! Super, Thank you!!

image