Various tree icons visible and on / off checkboxes in jstree

I need to change the icons of tree images and enable / disable checkboxes, please see the code below:

function LoadJSTree() { $.noConflict(); $(function () { $('#demoTree').jstree({ 'checkbox': { 'keep_selected_style': false, 'two_state': true }, "types": { "#": { "max_children": 1, "max_depth": 4, "valid_children": ["root"] }, "root": { "icon": "/static/3.1.1/assets/images/tree_icon.png", "valid_children": ["default"], "check_node": false, }, "default": { "valid_children": ["default", "file"], "check_node": true, "uncheck_node": true }, "disabled":{ "check_node": false, "uncheck_node": false }, "file": { "icon": "glyphicon glyphicon-file", "valid_children": [], "check_node": true, "uncheck_node": true } }, "plugins": ["types"], 'core': { 'data': [ { "text": "Root node", "type": "root", "parent":"#", "children": [ { "text": "Child node 1", "type": "default" }, { "text": "Child node 2", "type": "default" }, { "text": "Child node 3", "type": "default" }, { "text": "Child node 4", "type": "default" }, { "text": "Child node 5", "type": "default" }, { "text": "Child node 6", "type": "default" }, { "text": "Child node 7", "type": "default" }, { "text": "Child node 8", "type": "default" } ] } ], }, 'plugins': ["checkbox"] }); 

This does not seem to work.

The tree is displayed using the same folder icons for each node and the checkbox always present for each node, should it not be disabled for the "root" node? Could you tell me what happened?

+5
source share
1 answer

You specified plugins twice in your configuration:

 "plugins": ["types"], ... 'plugins': ["checkbox"] 

Change this to one entry:

 "plugins": ["checkbox", "types"] 

However, keep in mind that there is no option (in version 3 if this is the version you are using) to prevent actions based on the node type. But using the latest jsTree commit, you can turn off node-based flags using the state property for node (you can also turn off the entire node) - if that's what you need, look here:
jsTree disable some checkboxes

+1
source

All Articles