sharepoint 2010 如何在列表中添加功能菜单操作项
在做知识库文档管理模块中,有一个需求,就是想要在自定义列表当中,增加一个,我的收藏功能。按照sharepoint默认的列表来做,我们可以在列表的标题字段中,增加一个功能菜单项,叫我的收藏.如下图。
点击收藏,弹出一个提示框,点击确定,我们把这个纪录添加到收藏记录表。
还是沿用前面的一个sharepoint project ,sharepoint 2010 如何扩展webpart自定义属性边栏字段 custom webpart properties ,在其基础上,来做这个功能。
1。添加一个空元素,CollectionMenuItem。在这个空元素里面,添加一个CustomAction属性
<CustomAction
Id="CollectionMenuItem"
RegistrationType="List"
RegistrationId="100"
Location="EditControlBlock"
Sequence="301"
Title="我的收藏"
ImageUrl="/_layouts/images/ReportServer/editreport.gif">
<UrlAction Url="javascript:if(confirm('确认要收藏吗?')==false){ return false;}
else{window.location.href='/_layouts/WebpartBarTest/CollectionEdit.aspx?scope=item&ListId={ListId}&Itemid={ItemId}&CollectionType=CustomList'}"/>
</CustomAction>
2。部署下project,我们会看到,所有的sharepoint custom list,都会有“我的收藏”这个菜单项。点击我的收藏,会提交一条数据到收藏记录表。
SharePoint 2010 List Template Type Registration IDs SharePoint RegistrationID'sAttribute
Description
Command
Required. The name of a command. The value of this attribute matches the value of aCommand attribute on an element that defines a control.
CommandAction
Required. A script statement to execute when this handler is invoked. Microsoft SharePoint Foundation calls theeval method, passing in the value of this attribute.
The value of the attribute can contain substitution tokens that are transformed at rendering. The following tokens are recognized:
{ItemId} – ID (GUID) taken from the list view.
{ItemUrl} – Web-relative URL of the list item (Url).
{RecurrenceId} – ID of a recurrent item (RecurrenceID).
{SiteUrl} – The fully qualified URL to the site (Url).
{ListId} – ID (GUID) of the list (ID).
{ListUrlDir} – Server-relative URL of the site plus the list's folder.
{Source} – Fully qualified request URL.
{SelectedListId} – ID (GUID) of the list that is currently selected from a list view.
{SelectedItemId} – ID of the item that is currently selected from the list view.
EnabledScript
Optional. A script statement that is executed to determine whether the command is enabled or disabled. The script expression should return aBoolean value,true if the command is enabled andfalse if not. If the ribbon is disabled, commands are grayed out and are not clickable.
As with the CommandAction attribute, theeval method is called with the value of this attribute as an argument. TheEnabledScript attribute does not support the substitution tokens that are described for theCommandAction attribute.
广州京微信息科技有限公司,.微软sharepoint解决方案提供商。