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

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

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

        大多说时候它看起来像这样:
        Elements.xml:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <CustomAction
Id="{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">
<Button
Id="{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>
<CommandUIHandler
Command="{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">
<Button
Id="{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>
<CommandUIHandler
Command="{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 SPSite
var web = properties.Feature.Parent as SPWeb; //Get list instance - here You can also create a new list
var list = web.Lists.TryGetList("RibbonButtonList"); if (list != null)
{
//Add new user custom action to the list
var userAction = list.UserCustomActions.Add();
//Set action's location
userAction.Location = "CommandUI.Ribbon";
//This one is Optional as we are adding the same later
userAction.ImageUrl = "/_layouts/images/menulistsettings.gif";
//Command body
userAction.CommandUIExtension = @"<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition Location=""Ribbon.List.Settings.Controls._children"">
<Button
Id=""{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>
<CommandUIHandler
Command=""{234F6E9E-80A3-4f70-9683-02067515801E}""
EnabledScript=""""
CommandAction=""javascript: alert('Programmatically Added Button!');"" />
</CommandUIHandlers> </CommandUIExtension>"; userAction.Update();
}
}

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



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

加入功能区buttonRibbon Button到SP2010特定列表或库的更多相关文章

  1. sharepoint 2013 列表和库标签 元数据导航配置(2)

    接前面提到的,如何创建一个术语库.sharepoint 2013 列表和库标签 元数据导航配置(1), 现在要做的,就是如何在自定义或者文档库中使用这个术语库,实现标签功能,通过这些标签,找到对应的文 ...

  2. 跟我学SharePoint 2013视频培训课程——排序、过滤在列表、库中的使用(10)

    课程简介 第10天,SharePoint 2013排序.过滤在列表.库中的使用. 视频 SharePoint 2013 交流群 41032413

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

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

  4. [Beginning SharePoint Designer 2010]列表和库&内部内容类型

    本章概要: 1.SPS如何组织管理数据 2.如何创建列表和文档库 3.如何使用视图来过滤分类,分组列表和库 4.如何创建内容类型来应用一个定义好的结构到数据和文档中

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

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

  6. Sharepoint学习笔记—习题系列--70-576习题解析 -(Q121-Q123)

    Question  121 You are designing a SharePoint 2010 workflow that will be used to monitor invoices. Th ...

  7. Sharepoint学习笔记—习题系列--70-576习题解析 -(Q1-Q3)

    这里我把从网上搜集到的针对Sharepoint 70-576的有关练习进行系统的解析,整理成一个系列, 分期.分批次共享出来,供大家研究. 70-573考试注重的是"知道"相关知识 ...

  8. 自定义和扩展 SharePoint 2010 Server 功能区

    了解构成 SharePoint 2010 服务器功能区的组件以及如何通过演练两个功能区自定义项方案来自定义功能区. 适用范围: Microsoft SharePoint Foundation 2010 ...

  9. SharePoint 2013无代码实现列表视图的时间段动态筛选

    本文介绍两种为列表视图设置时间段筛选器的方法.其中,第一个方法用于SharePoint Server,第二个方法同时还能用于SharePoint Foundation. 方法一:日期筛选器Web部件 ...

随机推荐

  1. Cortex-M3和Cortex-M4 Fault异常应用之二 ----- Fault处理函数的实现

    在项目处于调试期间,Fault处理程序可能只是一个断点指令,调试器遇到这个指令后停止程序的运行.默认情况下,由于非硬Fault被禁能,所有发生的非Fault都会上访成硬Fault,因此只要在硬Faul ...

  2. flex实现股票行情走势图

    原文 http://blog.csdn.net/shenjiancomputer/article/details/8051873 第一步: jsp:1 <%@page import=" ...

  3. JAVA的IO运用

    IO OF JAVA想写好一篇关于JAVA的IO的文章不容易,因为它涉及的东西很多难以写得有深度和有思路.我虽不才但也写.这篇文章有我个人不少的见解,虽然涉足计算机不深但我不想用一大堆这个可能那个可能 ...

  4. ubuntu下tcpdump使用

    Ubuntu默认是安装好了tcpdump工具的,如果没有安装的话使用sudo apt-get install tcpdump即可安装.   (如果遇到tcpdump: no suitable devi ...

  5. UICollectionView基础学习

    相信了解UICollectionView的也一定听过瀑布流吧,开始之前先提供两个瀑布流,有时间的可以深入研究研究 https://github.com/dingpuyu/WaterFall https ...

  6. python 网页爬虫+保存图片+多线程+网络代理

    今天,又算是浪费了一天了.python爬虫,之前写过简单的版本,那个时候还不懂原理,现在算是收尾吧. 以前对网页爬虫不了解,感觉非常神奇,但是解开这面面纱,似乎里面的原理并不是很难掌握.首先,明白一个 ...

  7. Struts2 初体验

    Sturts是一款优雅的,可扩展性很强的框架.它是由Struts开发团队和WebWord团队合作,共同开发的一个新的产品.新版本的Struts2 更加容易使用,更加接近Struts所追求的理念.从开发 ...

  8. 动态改变ComboBox下拉框的宽度

    在C++Builder中有时下拉框的内容比较长,标准长度下根本显示不完,可以调用PostMessage()方法来实现 ::PostMessage(comb->Handle,CB_SETDROPP ...

  9. poj 1149 pigs ---- 最大流

    题意以及分析:http://ycool.com/post/zhhrrm6#rule3 主要是建图,简化图,然后在套最大流的模板. #include <iostream> #include& ...

  10. js返回值

    看下js变量.作用域.内存文档. 1. <script type="text/javascript"> function c(){ return 23; } var a ...