Search code examples
tabulator

Nesting Parent ID In Child For Tabulator Data Tree


I'm using a data tree to display a list of tasks (and sub tasks). Is it possible within Tabulator to store the data (for ease) with the Parent ID inside of the child?

Instead of parsing the children records through/inside their parents, the records would be parsed separately, but include the Parent ID.

Before

[
    {id:1, name:"Billy Bob", age:"12" "_children":[
        {id:2, name:"Mary May", age:"1"}, //child rows nested under billy bob
        {id:3, name:"Christine Lobowski", age:"42"},
        {id:4, name:"Brendon Philips", age:"125", "_children":[
            {id:5, name:"Margret Marmajuke", age:"16"}, //child rows nested under brendon philps
            {id:6, name:"Frank Peoney", age:"12"},
        ]},
    ]},
]

After

[
    {id:1, name:"Billy Bob", age:"12"}
    {id:2, name:"Mary May", age:"1", parentid:1},
    {id:3, name:"Christine Lobowski", age:"42", parentid:1},
    {id:4, name:"Brendon Philips", age:"125"},
    {id:5, name:"Margret Marmajuke", age:"16", parentid:4},
    {id:6, name:"Frank Peoney", age:"12", parentid:4},
]

Solution

  • That would have been a much easier (natural) way to proceed, yet Tabulator does not store Tree items the way you expressed it so there's no choice if you want to display the Tree in a hierarchical manner (the "natural" way will be listed as a flat list by Tabulator).