简体   繁体   English

jstree不兼容的复选框和类型插件

[英]jstree incompatible checkbox and types plugin

I'm creating a tree using the jstree javascript library while using two jstree plugins: 我正在使用jstree javascript库创建树,同时使用了两个jstree插件:

  • 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. id = 2的节点不显示在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/ 资料来源: https : //www.jstree.com/plugins/

You have to set 'icons': true in the core section of jsTree config. 您必须在jsTree配置的core部分中设置'icons': true

I also fixed your JSON - need a { for first object in mydata . 我还修复了您的JSON- mydata第一个对象需要{

See demo: JS Fiddle 参见演示: JS Fiddle

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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