在子级中为制表符数据树嵌套父级ID

时间:2019-05-02 01:45:44

标签: tabulator

我正在使用数据树显示任务(和子任务)列表。在Tabulator中是否可以(为了简便)将带有父ID的数据存储在孩子内部?

不是通过父母内部解析儿童记录,而是单独解析记录,但包括父母ID。

之前

[
    {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"},
        ]},
    ]},
]

之后

[
    {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},
]

1 个答案:

答案 0 :(得分:0)

这本来是一种更简单(自然)的方法,但是Tabulator不会以您表示的方式存储Tree项,因此,如果您想以分层方式显示Tree(“自然”方式),则别无选择将由Tabulator列为平面列表。