SharePoint provides a build in JavaScript, which has two functions for ECB AddListMenuItems and AddDocLibMenuItems.These methods are executed by SharePoint to display context menu.
Below is an example for AddListMenuItems
function Custom_AddListMenuItems(m, ctx)
{
//Add your Menu Name which you want to display
var strDisplayText = “Copy Item”;
var itemId = GetAttributeFromItemTable(itemTable, “ItemId”, “Id”);
var listId = ctx.listName;
// you customize the action based on your needs
var strAction = “<<JavaScript Code>>”;
var strImagePath = “”;
// Add our new menu item
CAMOpt(m, strDisplayText, strAction, strImagePath);
// add a separator to the menu
CAMSep(m);
// false means that the standard menu items should also be rendered
// if you set true, it will show only the menu which you added( standard sharepoint menu items will not be available.
// you can control by setting the value of true or false
return false;
}
///Similary you can hide the “Delete Item” (particular) menu item in List Context Menu
// Add this below function
function CAMOpt(p,wzText,wzAct,wzISrc,wzIAlt,wzISeq,wzDesc)
{
var mo=CMOpt(wzText,wzAct,wzISrc,wzIAlt,wzISeq,wzDesc);
if(!mo)return null;
if(wzText != “Delete Item”) AChld(p,mo);
return mo;
}
Reference URL:
http://www.c-sharpcorner.com/blogs/how-to-customize-sharepoint-ecm-menu1
Recent Comments