如何删除jsTree contextMenu左侧的空白区域

时间:2015-12-15 07:36:19

标签: asp.net-mvc contextmenu jstree

我在ASP.NET MVC应用程序中使用jsTree插件并且有一个奇怪的问题。我已附加了contextMenu插件,但其项目左侧有一个奇怪的空白区域,如下图所示:

enter image description here

我的代码是:

$(function () {
    $("#competence-areas-tree").jstree({
        core: {
            data: {
                cache: false,
                url: '@Url.Action("GetTreeData", "CompetenceArea")'
            },
            multiple: false
        },
        types: {
            competenceArea: {
                icon: "@Url.Stylesheet("/jstree-3.0.0b/competenceArea.png")"
            }
        },
        contextmenu: {
            items: function ($node) {
                return {
                    createItem: {
                        separator_before: false,
                        separator_after: false,
                        label: "Создать",
                        submenu: {
                            create: {
                                separator_before: false,
                                separator_after: false,
                                label: "Создать на текущем уровне",
                                action: function() {
                                    Create($node.parent);
                                }
                            },
                            createChild: {
                                separator_before: false,
                                separator_after: false,
                                label: "Создать потомка",
                                action: function() {
                                    Create($node.id);
                                }
                            }
                        }
                    },
                    editItem: {
                        separator_before: false,
                        separator_after: false,
                        label: "Редактировать",
                        action: function() {
                            Edit($node.id);
                        }
                    },
                    deleteItem: {
                        separator_before: false,
                        separator_after: false,
                        label: "Удалить",
                        action: function() {
                            Delete($node.id);
                        }
                    },
                    detailGraphItem: {
                        separator_before: false,
                        separator_after: false,
                        label: "Перейти к графу",
                        action: function() {
                            DetailGraph($node.id);
                        }
                    }
                }
            }
        },
        plugins: ["types", "contextmenu", "themes"]
    }).on("changed.jstree", function(e, data) { 
        if (data.action === "select_node") {
            OnSelectingNode(data.node.original.id);
        }
    });
});

谢谢!

1 个答案:

答案 0 :(得分:1)

嗯,我为你提供的上下文菜单制作了一个jsfiddle,但它没有任何问题。左边总是有一个默认空间,在jstree中有上下文菜单,但是没有达到你所拥有的程度。这是jsfiddle,看看它是否有帮助:

URI#encode_www_form

public static void main(String[] args) {
    VertxOptions op = new VertxOptions();
    op.setClustered(true);
    Vertx.clusteredVertx(op, e -> {
        if (e.succeeded()) {
            HelloWorldVerticle hwv = new HelloWorldVerticle();
            e.result().deployVerticle(hwv);
        } else {
            e.cause().printStackTrace();
        }
    });
}