how to initialize primeng tree component

前端 未结 3 1461
春和景丽
春和景丽 2021-02-06 19:37

Given a tree how to initialize it in such way that the nodes are expanded at will?

I already tried to get a reference with @ViewChildren(Tree) tree

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-06 20:07

    For initialize your tree component expanded you only need set in you json format the property expanded as true.

    Sample:

    {
        "data": 
        [
            {
                "label": "Pictures",
                "data": "Pictures Folder",
                "expandedIcon": "fa-folder-open",
                "collapsedIcon": "fa-folder",
                "expanded": true, // this flag shoud be true
                "children": [
                    {"label": "barcelona.jpg", "icon": "fa-file-image-o", "data": "Barcelona Photo"},
                    {"label": "logo.jpg", "icon": "fa-file-image-o", "data": "PrimeFaces Logo"},
                    {"label": "primeui.png", "icon": "fa-file-image-o", "data": "PrimeUI Logo"}]
            },
        ]
    }
    

提交回复
热议问题