when using 'children' but not 'parent' property in json model for jstree pushing to tree model doesn't update the jstree view
See original GitHub issueHi!
When I use json data for jsTree with children but without parent, like this:
{
id : "string" // will be autogenerated if omitted
text : "string" // node text
icon : "string" // string for custom
state : {
opened : boolean // is the node open
disabled : boolean // is the node disabled
selected : boolean // is the node selected
},
children : [] // array of strings or objects
li_attr : {} // attributes for the generated LI node
a_attr : {} // attributes for the generated A node
} // note there is no parent property in this json
– then pushing to ngJsTree’s model doesn’t rerender jsTree view. Incrementing version will do the trick, but I don’t want to rerender whole tree if only one node is added.
I noticed that you use following code to add to the jsTree’s model newly pushed node:
...
var parent = scope.tree.jstree(true).get_node(node.parent);
var res = scope.tree.jstree(true).create_node(parent, node, 'inside',function() {
...
– so if node doesn’t have parent property (as in my case) node wont’ be added/
Using both children and parent at the same time is impossible (https://www.jstree.com/docs/json/) as jstree prefers parent and ignores children as far as I understand.
Issue Analytics
- State:
- Created 8 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Populating the tree using JSON - jsTree
jsTree functions properly in either box-model (content-box or border-box), ... node object has two required fields: id & parent and no children property...
Read more >Turning graph data with multiple parents into data for jstree ...
The problem being that jstree data model does not allow same ID to be presented. This is not completly true, actually it doesn't...
Read more >Clear tree selection and state on UI - Google Groups
Have one jsTree Config and using refresh to load different trees with data from DB. Everything works fine. We have a requirement where...
Read more >Use the original JavaScript object as the node.original property.
Basically in this example each node object has a getChildren() method that will return an array of nodes to use as its children....
Read more >Parent Child Json Data Example
To model a parent-child relationship in the records of your Algolia JSON data: ... Your data structure does not, but you could add...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
+1. would need this.
ok, got it, thanks for your quick reply 😃