It would be useful oftentimes in SharePoint, to be able to edit an item in a pop-up window. This can be done with a bit of Javascript in a Content Editor Web Part (CEWP) in the list view page concerned.
To use an additional Edit Content Block menu item as above, paste the following Javascript into a CEWP in the page concerned:
<script type=”text/javascript”> function Custom_AddListMenuItems(m, ctx) { var viewURL = window.location.protocol + “//” + window.location.host + ctx.displayFormUrl + “?ID=” + currentItemID; var editURL = window.location.protocol + “//” + window.location.host + ctx.editFormUrl + “?ID=” + currentItemID; var openMenu = CASubM(m,”Open in New Window”); CAMOpt(openMenu, “View Item”, “window.open(‘” + viewURL + “‘);”); CAMOpt(openMenu, “Edit Item”, “window.open(‘” + editURL + “‘);”, “/_layouts/images/edititem.gif”); return false; // render the default menu items too } </script> |
With thanks to Jan Tielens
July 23, 2010 at 7:02 pm
Hi,
Thanks for the great post.
I used this javascript in CEWP and its working great. I am using this to remove all the default ECB menu options (return true;) and provide only one ‘Link’ option in the ECB that will open the Listitem in an infopath form. But when user click on the Title column the listitem will open using defalut Dispform.aspx page, How can I make that Onclick event to redirect to my custom Link.
Thanks.
Harish.