Treeview - How to have nodes default checked in JSON?

224 views Asked by At

For the jonmiles treeview plugin, how do I define in the json data that certain nodes are checked by default?

the following is completely ignored:

[{
        "text": "Parent 1",
        "checked": true,
        "nodes": [{
                "text": "Child 1",
                "nodes": [{
                        "text": "Grandchild 1"
                    },
                    {
                        "text": "Grandchild 2"
                    }
                ]
            },
            {
                "text": "Child 2"
            }
        ]
    },
    {
        "text": "Parent 2"
    },
    {
        "text": "Parent 3"
    },
    {
        "text": "Parent 4"
    },
    {
        "text": "Parent 5"
    }
]
1

There are 1 answers

0
Geshode On BEST ANSWER

It should work, if you use:

{
    "text": "Parent 1",
    "state": {
        "checked": true
    }
}

You forgot to put the state property. For reference look at data structure in the readme.