http://chrissyblanco.blogspot.com/2007/12/bug-with-customaction-in-actions-menu.html
http://stephenkaye.blogspot.com/2008/02/bug-with-customactions.html
if you define a CustomAction as part of a feature and use tokens in the URL e.g.
Solution
I am a big believer in javascript. So here is the Javascript solution. After inspecting the page, it turns out that SharePoint creates a ctx javascript object for the list. This object contains a property listName, which holds the ListId property
1) If the MenuItem is yours and you have luxary to change the feature XML code, you coul
construct your
<UrlActionUrl="javacript:window.location='~site/_layouts/pageaspx?List'+ctx.listName"/>
2) If you are using third party feature or if you have issue with out of the box menuitems, you can insert the following Javascript, either by adding a "Content Editor WebPart" or by modifying the aspx page
var __menus = document.getElementsByTagName('ie:menuitem');
for (var i = 0; i <>
itm = __menus(i)
var str = itm.getAttribute("onMenuClick");
if (str && ctx && str.match('ListId') != null )
{ str = str.replace("ListId", ctx.listName)
itm.setAttribute('onMenuClick', str);
}
This code will replace the {ListId} token on all menus items where token is not replaced.
Note : This solution will only work if you have single list on a page. For multiple lists you need to get hold of "ctx" array object in those cases
5 comments:
This is great .. exactly what I was looking for
Do you have any examples where you can get a hold of the "ctx" array object? What is it called?
How to add concatenate "+ctx.ListName" to items on ListActionsToolbar? Here is it's code:
< UrlAction Url="~site/_layouts/AdvancedAlert/AdvancedSubNew.aspx?ListId={ListId}" >
This is a great blog. Thanks for all your hard work and the info you give. I am hoping you post again soon.I wish u keep on.
Thank You
SharePoint Custom Development
Post a Comment