I am generating jstree from struts2 and JSON from database. From DB I have one flag which tell me active and disable, so can you please somebody help me how to disable a jstree node according to this.
After google I find that it is possible by “type” pluging but I cant understand how to use type plugin for this.If any example available then it is very helpful for me.
I am generating jstree from struts2 and JSON from database. From DB I have
Share
Take a look at this other answer by me as you will need it:
How do you format "li" and "a" DOM elements in jsTree by setting their class?
Basically, what you need is to build the JSON as you are doing now, in the backend, and because you know which nodes need to be disabled (or styled) you can set different CSS class names or different attributes like, for example,
class="disabled"orrel="disabled"in this JSON response as shown in the link.I don´t know what level of customization you need to accomplish in those nodes, but styling them would be enough to change font and background.
Then, as you said, you can use the Types plugin to customize behaviour of these “disabled” nodes, i.e.
Note we defined the Type and named it “disabled” so you will need to put a
rel="disabled"in each<li>element (node) you want to disable. This is how jsTree seek for types by default, using the rel attribute.I hope this helps you.