Muthu
Muthu

Reputation: 431

How to remove edit option in context menu using jstree?

I need to remove Edit option in context menu using "jstree" jquery plugin. Please tell how to remove it.

my code is:

var contextualMenuSample = function() {

    $("#tree_3").jstree({
        "core" : {
            "themes" : {
                "responsive": false
            }, 
            // so that create works
            "check_callback" : true,
        },
        "types" : {
            "default" : {
                "icon" : "fa fa-folder icon-state-warning icon-lg"
            },
            "file" : {
                "icon" : "fa fa-file icon-state-warning icon-lg"
            }
        },
        "state" : { "key" : "demo2" },
        "plugins" : [ "contextmenu", "dnd", "state", "types" ],
        "contextmenu" : {
            "items" :{
            "Edit": false
            }
        }


    });

}

Upvotes: 4

Views: 1810

Answers (2)

Sadon Sergey
Sadon Sergey

Reputation: 11

this is my easiest option. All main code placed in "contextmenu.items" block.

$('#c-list').jstree({
    "core": {
        "themes": {"responsive": false},
        "check_callback": true,
    },
    "types": {
        "default": {
            "icon": "fa fa-folder text-warning fa-lg"
        },
        "file": {
            "icon": "fa fa-file text-warning fa-lg"
        }
    },
    "contextmenu":{
        'items' : function(node) {
            var items = $.jstree.defaults.contextmenu.items();
            items.ccp = false;

            return items;
        }
    },
    "plugins": ["contextmenu", "dnd", "types", "search", "wholerow","checkbox"]
});

Upvotes: 1

haibo cu
haibo cu

Reputation: 144

'contextmenu': {               
                'items' : function(node) {
                    var tmp = $.jstree.defaults.contextmenu.items();
                    tmp.ccp = false;
                }
 }

Upvotes: 0

Related Questions