How to remove SharePoint context menus selectively

I need to figure out how I could I selectively remove some Standard SharePoint list context menu. For example, most of the list context menus contain Edit Item, Delete Item etc. assume I have to keep the delete menu but need to strike out the “Edit Item”. How can we do that?

 

Go to the page settings. Add a new content editor web part into he page and go to the settings of this content editor web part. Open the source editor. Put the following scripts on it.

function Custom_AddListMenuItems(m, ctx)

{

var strDelete=”Delete this Item”;

var imgDelete=”;

var strDeleteAction=”deleteThisSelectedListItem();” ;

CAMOpt(m, strDelete, strDeleteAction, imgDelete);

// add a separator to the menu

CAMSep(m);

// false means that the standard menu items should also rendered

return true;

}

function deleteThisSelectedListItem()

{

if (! IsContextSet())

        return;

    var ctx=currentCtx;

    var ciid=currentItemID;

    if (confirm(ctx.RecycleBinEnabled ? L_STSRecycleConfirm_Text : L_STSDelConfirm_Text))

    {

        SubmitFormPost(ctx.HttpPath+”&Cmd=Delete&List=”+ctx.listName+                    “&ID=”+ciid+”&NextUsing=”+GetSource());

    }

}

 

Finally make the content editor web part invisible. Voila!