需求:需要对document中的author进行修改。
分析:
1,sdk中显示该属性为只读的,无法修改。于是只好新建了另一个字段来做当Author。
2,怎么修改?添加menu在menu bar里面,然后再弹出一个新的窗口来修改。
3,用户先选中需要修改的item,然后通过点击menu实现。
实现:
本文先描述添加Menu的过程。
1, 在该目录下: C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES新建DocumentEditAuthor的目录,首先新建Feature.xml(必须)。
<?xml version="1.0" encoding="utf-8"?>
<Feature Id="619d2b43-47df-46ae-89e3-af5b43abbcc4"
Title="Edit Author Actions"
Description="A Feature with Update document author menu"
Version="1.0.0.0"
Hidden="FALSE"
Scope="Web"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="MenuItem.xml" />
</ElementManifests>
</Feature>
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2, 然后新建另一个文件MenuItem.xml(根据ElementManifest location的内容)。
<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction Id="MyCustomSelectedMenuAction"
RegistrationType="List"
RegistrationId="101"
GroupId="ActionsMenu"
Location="Microsoft.SharePoint.StandardMenu"
Sequence="1001"
Title="Update Selected
"
ImageUrl="/_layouts/images/completeallwftasks.gif"
Description="Update selected document author.">
<UrlAction Url="javascript:GotoEditAuthor(0,' + {ListId} + ')"/>
</CustomAction>
<CustomAction Id="MyCustomAllMenuAction"
RegistrationType="List"
RegistrationId="101"
GroupId="ActionsMenu"
Location="Microsoft.SharePoint.StandardMenu"
Sequence="1002"
Title="Update All
"
ImageUrl="/_layouts/images/menuEditItem.gif"
Description="Update all document author.">
<UrlAction Url="javascript:GotoEditAuthor(1,' + {ListId} + ')"/>
</CustomAction>
</Elements>
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
注意, 在UrlAction Url里面可以直接写某目录下的文件, 同时可以是javascript。
3, 发布该Feature.
stsadm.exe –o installfeature –name DocumentEditAuthor –force.
stsadm.exe –o activatefeature –name DocumentEditAuthor –url http://WebName/Docs/ -force.
4, IISRESET.
效果:
![](https://images.cnblogs.com/cnblogs_com/lordan/120531/r_Menubar.jpg)
这里再描述另一种显示在item上的menu。
1, 同样在Feature下建一个目录DocumentExpire,然后Feature:
<?xml version="1.0" encoding="utf-8"?>
<Feature Id="A7A2885A-64B8-49F0-955B-7D976D6E293B"
Title="Extended List Actions"
Description="Expire Item"
Version="1.0.0.0"
Hidden="FALSE"
Scope="Web"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="Actions.xml" />
</ElementManifests>
</Feature>
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2, Actions.xml的文件:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="CustomExpireItem"
Location="EditControlBlock"
Title="Expire Item "
ImageUrl="/_layouts/images/GORTL.GIF"
Sequence="300"
RegistrationType="ContentType"
RegistrationId="0x01">
<UrlAction Url="~site/_layouts/ExpireItemFolder/ExpireItem.aspx?List={ListId}&ID={ItemId}"/>
</CustomAction>
</Elements>
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3, 发布该Feature:
stsadm.exe –o installfeature –name DocumentExpire –force.
stsadm.exe –o activatefeature –name DocumentExpire –url http://WebName/Docs/ -force
4, IISRESET
效果:
![](https://images.cnblogs.com/cnblogs_com/lordan/120531/r_ItemMenu.jpg)
不同的menu,注意RegistrationType和RegistrationId。
关于Guid 可以通过 http://www.famkruithof.net/uuid/uuidgen很方便的生成。
关于Feature的详细内容,参考: http://msdn2.microsoft.com/en-us/library/ms473643.aspx。