加入功能区button到SP2010某一列表或库

有时候你须要给列表/库的功能区加入新button--没有什么比这更简单的了。

你仅仅须要新建一个SP项目。加入一个feature,加入一个空白元素。编辑它的Elements.xml文件。

大多说时候它看起来像这样:
Elements.xml:
<?xml version="1.0" encoding="utf-8"?><Elements xmlns="http://schemas.microsoft.com/sharepoint/"><CustomActionId="{41C23DD2-6FEB-4636-AE4F-41B8E2A2D415}"
<strong> RegistrationId="100"</strong>
<strong> RegistrationType="List"</strong>Location="CommandUI.Ribbon"Sequence="5"Title="Custom Lists Button"><CommandUIExtension><CommandUIDefinitions><CommandUIDefinition Location="Ribbon.List.Settings.Controls._children"><ButtonId="{09A51440-C3A6-4103-874A-383747042E75}"Alt="Custom Lists Button"Sequence="5"Command="{42844423-382B-4e87-BEC4-34B0601DA98F}"Image32by32="/_layouts/images/menulistsettings.gif"Image16by16="/_layouts/images/itdcl.gif"LabelText="Custom Lists Button"TemplateAlias="o1" /></CommandUIDefinition></CommandUIDefinitions><CommandUIHandlers><CommandUIHandlerCommand="{42844423-382B-4e87-BEC4-34B0601DA98F}"EnabledScript=""CommandAction="javascript: alert('Custom Lists Button!');" /></CommandUIHandlers></CommandUIExtension></CustomAction>
</Elements>

部署解决方式。激活feature结果是:


        这种方法的缺点是button会出如今每一个现有自己定义列表中,就算你新建自己定义列表也会出现。

原因是RegistrationId="100"。这里100是自己定义列表的类型。

假设要给某个列表实例提供button的话。你能够使用一下方法:

创建列表定义并分配RegistrationId到列表定义的Type

首先须要新创建列表定义:
打开列表定义的Elements.xml。复制Type值:
粘贴该值到button的Elements.xml中RegistrationId:
<CustomAction
Id="{67A1EB46-A49B-4aff-B456-068909C39599}"
RegistrationId="10000"
RegistrationType="List"
Location="CommandUI.Ribbon"
Sequence="5"
Title="List Definition Button"><CommandUIExtension><CommandUIDefinitions><CommandUIDefinition Location="Ribbon.List.Settings.Controls._children"><ButtonId="{3F083F8B-95D6-436b-A130-3EF1E8C04E3C}"Alt="List Definition Button"Sequence="5"Command="{AF90D558-00DA-4ccf-B4F4-169CD9162CD0}"Image32by32="/_layouts/images/menulistsettings.gif"Image16by16="/_layouts/images/itdcl.gif"LabelText="List Definition Button"TemplateAlias="o1" /></CommandUIDefinition></CommandUIDefinitions><CommandUIHandlers><CommandUIHandlerCommand="{AF90D558-00DA-4ccf-B4F4-169CD9162CD0}"EnabledScript=""CommandAction="javascript: alert('List Definition Button!');" /></CommandUIHandlers></CommandUIExtension></CustomAction>

最后,加入列表定义到feature,这样它能随着解决方式一起部署:
        激活feature后,你应该能够给予新建列表定义创建新的列表:

当你从定义创建列表时,你应该能看到button:
另外,为了阻止用户使用新列表定义创建列表。你能够将定义设置为隐藏(这样用户看不到),然后你能够在FeatureActivated方法的feature event receiver中创建列表实例。

用程序加入button

加入一个event receiver到feature:
加入例如以下代码到FeatureActivated方法中:
public override void FeatureActivated(SPFeatureReceiverProperties properties){//Depending from the feature scope - can be SPSitevar web = properties.Feature.Parent as SPWeb;//Get list instance - here You can also create a new listvar list = web.Lists.TryGetList("RibbonButtonList");if (list != null){//Add new user custom action to the listvar userAction = list.UserCustomActions.Add();//Set action's locationuserAction.Location = "CommandUI.Ribbon";//This one is Optional as we are adding the same lateruserAction.ImageUrl = "/_layouts/images/menulistsettings.gif";//Command bodyuserAction.CommandUIExtension = @"<CommandUIExtension><CommandUIDefinitions><CommandUIDefinition Location=""Ribbon.List.Settings.Controls._children""><ButtonId=""{5557CC45-324E-41bb-9E88-A535DBF1BF6B}""Alt=""Programmatically Added Button""Sequence=""5""Command=""{234F6E9E-80A3-4f70-9683-02067515801E}""Image32by32=""/_layouts/images/menulistsettings.gif""Image16by16=""/_layouts/images/itdcl.gif""LabelText=""Programmatically Added Button""TemplateAlias=""o1"" /></CommandUIDefinition></CommandUIDefinitions><CommandUIHandlers><CommandUIHandlerCommand=""{234F6E9E-80A3-4f70-9683-02067515801E}""EnabledScript=""""CommandAction=""javascript: alert('Programmatically Added Button!');"" /></CommandUIHandlers></CommandUIExtension>";userAction.Update();}}

部署解决方式时要确保我们要加入button的列表已经存在并激活feature。你应该能在列表功能区看到新button:


        这就是所有了,如今你应该能够通过以上方法加入功能区button到一个列表了吧。

加入功能区buttonRibbon Button到SP2010特定列表或库相关推荐

  1. pandas使用split函数将dataframe中的特定列表字段(list column)裂变为多个数据列并拼接到原dataframe中

    pandas使用split函数将dataframe中的特定列表字段(list column)裂变为多个数据列并拼接到原dataframe中(splitting column of lists into ...

  2. pandas使用query函数查询dataframe指定数据列的内容(数值)不包含在特定列表中的数据行(not contain in list)

    pandas使用query函数查询dataframe指定数据列的内容(数值)不包含在特定列表中的数据行(select rows which column values are not containe ...

  3. pandas使用query函数查询dataframe指定数据列的内容(数值)包含在特定列表中的数据行(select rows which column values contain in list)

    pandas使用query函数查询dataframe指定数据列的内容(数值)包含在特定列表中的数据行(select rows which column values contained in a li ...

  4. python中排序从小到大_Python实现对特定列表进行从小到大排序操作示例

    本文实例讲述了Python实现对特定列表进行从小到大排序操作.分享给大家供大家参考,具体如下: 1.在系统内新建文件rizhireplacelist.txt root@kali:~# cd pytho ...

  5. 跟我学SharePoint 2013视频培训课程——探索默认的列表和库(6)

    课程简介 第6天,探索默认的列表和库. 视频 SharePoint 2013 交流群 41032413

  6. 现代化自定制 - 列表和库部分

    博客地址:http://blog.csdn.net/FoxDave 在现代化网站时一个重要方面就是要去了解在网站上使用的自定制都有哪些,因为不是所有已存在的自定制还能正常工作.一个我们常常会遇到的典型 ...

  7. wpf 展示特定列表结构

    wpf中,ItemsControl可以将任何内容作为集合放置某容器中展示 具体用法 <ItemsControl x:Name="_button"><ItemsCo ...

  8. robotframework ie浏览器中click button不可用_RobotFramework自动化Selenium2Library库常用关键字...

    打开浏览器 # 常用浏览器简写(FrieFix:firefix.ff|Internet Explorer:internetexplorer.ie) # 常用浏览器简写(Google Chrome:go ...

  9. OSS.Common获取枚举字典列表标准库支持

    上篇(.Net Standard扩展支持实例分享)介绍了OSS.Common的标准库支持扩展,也列举了可能遇到问题的解决方案.由于时间有限,同时.net standard暂时还没有提供对Descrip ...

最新文章

  1. Delphi中点击DBGrid某一行获得其详细数据方法
  2. 方欣科技算法题面试:蛇形矩阵
  3. urlrewrite伪静态 及多参数传递-附正则表达式语法 [轉]
  4. git lfs的安装和使用详细案例
  5. 花了一个深夜,才用C语言写了一个2048游戏雏形
  6. html 链接 id属性_HTML id属性
  7. Linux故障解决(3)——YUM安装任何软件 报错:ERROR: XZ COMPRESSION NOT AVAILABLE
  8. 如何检索某学术会议全部论文?
  9. WIN10 Wifi已连接无internet完美解决办法
  10. linux下ftp命令删除文件夹命令,Linux中FTP账号无法删除文件夹的解决方案
  11. 为何中华武术不堪一击?武学大师临终前解密搏击格斗的残酷真相
  12. Elasticsearch(006):es中filtered和filter的区别
  13. 毫米波雷达「增量」升级
  14. 智能家居正进化成人们想要的样子
  15. linux启动网络服务的命令,linux重启服务命令
  16. 判断当前时间段是否在某个时间段内(当前小时是否在当日某个时间段)
  17. actf-2019-onerepeater
  18. 哪里可以下载Samsung Galaxy S2 USB驱动程序?
  19. Netdiscover网络扫描工具
  20. 注册表项目不能删除的解决方案

热门文章

  1. python内置函数下划线_python(内置函数)
  2. ‘sort’命令的14个有用的范例
  3. Microsoft.XMLHTTP基本用法
  4. Hadoop MapReduce编程 API入门系列之join(二十六)
  5. 读书笔记_Effective_C++_条款二十四: 若所有参数皆需类型转换,请为此采用non-member函数...
  6. 程序员为什么值得写博客
  7. IIS5IIS6IIS7的ASP.net 请求处理过程比较(转)
  8. LeetCode(59):螺旋矩阵 II
  9. 04-struts2框架中获取servlet api及Result结果类型
  10. CentOs 设置静态IP 方法[测试没问题]