简体   繁体   中英

jstree incompatible checkbox and types plugin

I'm creating a tree using the jstree javascript library while using two jstree plugins:

  • checkbox plugin

  • types plugin

Here is a code example with

var mydata=[
id: "1",
parent: "#",
text: "node1",
},
{
id: "2",
parent: "#",
text: "node2",
type: "nodeattribute",
}];

        $('#dqResultsJSTree').jstree(
                {
                    'core' : {
                        'themes' : {
                            'variant' : 'large',
                            'icons' : false,
                        },
                        'data' : mydata,
                    },
                    'types' : {
                            'nodeattribute' : {
                              'icon' : 'http://icons.iconarchive.com/icons/hydrattz/multipurpose-alphabet/24/Letter-A-lg-icon.png',
                            },
                     },
                    'checkbox' : {
                        cascade : "",
                        three_state : false,
                    },
                    'plugins' : [ 'checkbox', 'types'],
                });

The problem I'm having is that the type is not working. The node with id=2 does not show the icon defined at type nodeattribute. Does anybody have had this problem using while using the checkbox at the same time?

Thanks in advance.

Source: https://www.jstree.com/plugins/

You have to set 'icons': true in the core section of jsTree config.

I also fixed your JSON - need a { for first object in mydata .

See demo: JS Fiddle

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM