Stree is a powerful tree-shaped page. But there are a lot of pits. Because my English level is poor, the above are all English comments, I write a memo
Introduce JS file. This online lot
I introduced the JSON data format to
$json = ' [
{
"id": "Ajson1",
"Parent": "#",
"Text": "Simple root node"
},
{
"id": "Ajson2",
"Parent": "#",
"Text": "Root Node 2"
},
{
"id": "Ajson3",
"Parent": "Ajson2",
"Text": "Child 1"
},
{
"id": "Ajson4",
"Parent": "Ajson2",
"Text": "Child 2"
}
]‘;
There are 3 pits here.
1. The ID of the child cannot overlap with the ID of the parent. This will not show all, I use the method is the parent ID is unique, the child ID I use the other to spell up, and then n=0;n++; Because the data i want here is just text.
2. The key value of the child must be 0.1.2.3.4 ... Such a type, if it is missing one, the back will not be shown, because I have the first data is empty, so I delete the array first data, the method is to re-"array_values"-This is the way PHP re-defines the array
3. If I'm going to destroy the tree before this time, create a new one. Use $.jstree.destroy (' #jstree '); This is written in the front of JS. Destroy in kind, haha, I have a bug here I do not understand you will not encounter, if destroyed, before the binding event on GG, But you can write it like I did, and I got it. Though I don't quite understand the reason
Jstree Tree Menu Issues