Aymen Kareem Aymen Kareem - 1 year ago 90
Javascript Question

How to display a checked jstree nodes when the tree is first displayed?

I have a jstree generated from https://www.youtube.com/watch?v=EKelQDay4wI.
Everything is fine and my tree is shown here:
enter image description here

Now I want to show some of the nodes checked already when loaded. For example, the code checks if the nodes exists in the database and set its checkbox as selected. How can I do that? I am using ASP.Net MVC

And how can I show it in expanded way when it is loaded?

Answer Source

If you use html data for if you want selected node you most use something like this

      <a href="#" class="jstree-clicked">Child</a>

attention to jstree-clicked class name. And if you use json data you data most be like this code

'data' : [
       'Simple root node',
         'text' : 'Root node 2',
         'state' : {
           'opened' : true,
           'selected' : true

as you see selected property of node make give you ability to make you node selected. for more samples you find in jsTree site

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download