question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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 issue

Hi!

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:open
  • Created 8 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
LorandLorinczcommented, Jan 20, 2016

+1. would need this.

0reactions
fastovezzcommented, Nov 5, 2015

ok, got it, thanks for your quick reply 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found