Pages

Search This Blog

Thursday, July 23, 2015

Sharepoint hide an item from edit control block (ECB)

A simpler way to remove any item from the Edit Control Block of SharePoint 2013 site is to add some javascript in master page. This way we can also hide the item(s) from specific lists. To do this, just add the below code in a javascript file and link that js file to your master page. Alternatively you can also make use of Content Editor Web part to embed it in a page.


$(document).ready(function ()
{
    $('.ms-core-menu-list').live('focus', function ()
    {
        var ecbToHide = "Version History";
        var showVersionHistory = $("li[text='" + ecbToHide + "']");
        if window.location.href.toLowerCase().indexOf(encodeURIComponent('/Lists/TechPerspect/')) != -1)
        {
            showVersionHistory.hide();
        }
        else
        {
            showVersionHistory.show();
        }
    });

});

The above snippet will remove the ECB item - "Version History" from the List - "TechPerspect". 

No comments:

Post a Comment