情不知从何起,一往而情深
排名
6
文章
6
粉丝
16
评论
8
{{item.articleTitle}}
{{item.blogName}} : {{item.content}}
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2024TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
欢迎加群交流技术

jstree自定义右键菜单

5011人阅读 2020/7/16 18:25 总访问:764112 评论:0 收藏:0 手机
分类: 前端

自定义右键菜单:

重写contextmenu即可,把他放到contextmenu中
$("#你的树形id").jstree({
    contextmenu:{
     }
});
代码如下:

"contextmenu": {
    items: {
        add: {
            "label": "新增分组",
            "action": function (data) {
                var inst = jQuery.jstree.reference(data.reference);
                obj = inst.get_node(data.reference);
                layer.open({
                    type: 2,
                    title: '新增[' + obj.text + ']的子组',
                    shadeClose: true,
                    area: ['380px', '300px'],
                    content: '/admin/Group/add/id/' + obj.id //iframe的url
                });
            }
        }
        ,
        "edit": {
            "label": "修改分组",
            "action": function (data) {
                var inst = jQuery.jstree.reference(data.reference);
                var obj = inst.get_node(data.reference);
                var type = obj.id.substr(0, 4);
                if (type == 'root') {
                    layer.msg('根节点无法修改', { 'time': 2000, 'icon': 2 });
                    return;
                }
                if (type == 'list') {
                    layer.msg('考核对象分组请在系统设置-指标分组权限列表中修改', { 'icon': 2 });
                    return;
                }
                layer.open({
                    type: 2,
                    title: '修改[' + obj.text + ']的子组',
                    shadeClose: true,
                    shade: 0.8,
                    area: ['380px', '300px'],
                    content: '/admin/Group/edit/id/' + obj.id //iframe的url
                });
            }
        },
        "del": {
            "label": "删除分组",
            "action": function (data) {
                console.log(data);
            }
        }
    }
}



欢迎加群讨论技术,群:677373950(满了,可以加,但通过不了),2群:656732739

评价