最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Dynamically display Edit Control Block menu item in SharePoint - Stack Overflow

programmeradmin1浏览0评论

I am trying to set up dynamic per-item menus (Edit Control Block) in SharePoint 2007. My goal is to have certain features that are available based on the current user's group membership.

I know that the CustomAction tag that controls the creation of this menu item has a Rights attribute. The problem that I have with this is that the groups I am using have identical rights in the site (ViewListItems, ManageAlerts, etc). The groups that we have set up deal more with function, such as Manager, Employee, etc. We want to be able to assign a custom feature to a group, and have the menu items associated with that feature visible only to members of that group. Everyone has the same basic site permissions, but will have extra options availble based on their login credentials.

I have seen several articles on modifying the Core.js file to hide items in the context menu, but they are an all-or-nothing approach. There is an interesting post at .aspx that shows how to dynamically modify the Actions menu. It is trivial to modify this example to check the users group and show or hide the menu based on membership. Unfortunately, this example does not seem to apply to context menu items as evidenced here /.

Does anyone know of a way to do this without using javascript? If not, what is the best way to check the user's group from javascript?

I am trying to set up dynamic per-item menus (Edit Control Block) in SharePoint 2007. My goal is to have certain features that are available based on the current user's group membership.

I know that the CustomAction tag that controls the creation of this menu item has a Rights attribute. The problem that I have with this is that the groups I am using have identical rights in the site (ViewListItems, ManageAlerts, etc). The groups that we have set up deal more with function, such as Manager, Employee, etc. We want to be able to assign a custom feature to a group, and have the menu items associated with that feature visible only to members of that group. Everyone has the same basic site permissions, but will have extra options availble based on their login credentials.

I have seen several articles on modifying the Core.js file to hide items in the context menu, but they are an all-or-nothing approach. There is an interesting post at http://blog.thekid.me.uk/archive/2008/04/29/sharepoint-custom-actions-in-a-list-view-webpart.aspx that shows how to dynamically modify the Actions menu. It is trivial to modify this example to check the users group and show or hide the menu based on membership. Unfortunately, this example does not seem to apply to context menu items as evidenced here http://forums.msdn.microsoft./en-US/sharepointdevelopment/thread/c2259839-24c4-4a7e-83e5-3925cdd17c44/.

Does anyone know of a way to do this without using javascript? If not, what is the best way to check the user's group from javascript?

Share Improve this question edited Sep 24, 2008 at 16:37 Eric Schoonover 48.4k50 gold badges159 silver badges203 bronze badges asked Aug 27, 2008 at 15:11 Jason ZJason Z 13.4k15 gold badges51 silver badges62 bronze badges 1
  • he title of this question would be more appropriate if it were "Dynamically modifying the List Item drop down menus in SharePoint"... can a moderator update? – Eric Schoonover Commented Sep 24, 2008 at 16:37
Add a ment  | 

2 Answers 2

Reset to default 2

There are two different Javascript functions that you can implement for dynamically adding menu items to list item drop downs. Core.js (C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033\CORE.JS) checks for the existence of these methods when generating the menu items for a selected list item. "Custom_AddDocLibMenuItems" and "Custom_AddListMenuItems" are the names of the Javascript methods.

One article that I think you can use to solve your specific problem, dynamic menu item customization based on user role membership, can be found here:

MSDN: Customizing the Context Menu of Document Library Items (note the process is exactly the same for any list type)

This article outlines how server side code can be executed to define the menu items that will be displayed:

[...] in more plex cases, you must retrieve the list of available mands from the server, because only there you can run your business logic and perhaps get the mands from a custom database. Typically, you want to do this if you are implementing a workflow solution where each document has its own process state, with mands associated to it.

The solution for this situation is to have the Custom_AddDocLibMenuItems dynamically call a custom ASP.NET page. This page takes the ID of the document library and the specific item on the query string, and returns an XML string containing all the information for the mands available for that particular document. These mands are available according to the document's process status (or some other custom business logic). [...]

Unfortunately this is not possible to acplish without using javascript. The ECB doesn't render server controls defined as a custom action (unlike the SiteActions etc).

To learn how to acplish this by using Javascript check out the following article: http://www.helloitsliam./archive/2007/08/10/moss2007-%E2%80%93-item-level-menus-investigation.aspx

发布评论

评论列表(0)

  1. 暂无评论