Saturday, October 20, 2012

Add Custom menu Item in ECB Menu using Javascript

Why to go for Visual Studio and customizing solutions when most of the tasks can be performed using the content editor web part, jQuery and JavaScript. I have been looking for a solution to add a custom menu item in ECB, but all the solutions I got were directed towards designing the solution using Visual Studio. But here is a very simple solution in which you can add this below given code in a  CEWP (Content Editor Web Part).

<script language="javascript">
function Custom_AddListMenuItems(m, ctx)
{
var strDisplayText = "Add Update";
var strAction = "STSNavigate('"+ctx.listUrlDir+"/EditForm.aspx?ID=" + currentItemID  + "')";
var strImagePath = ctx.imagesPath+"edititem.gif";
// 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
return false;
}
</script>

Try it !!!! ;)

No comments:

Post a Comment