加入功能区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. Oracle EBS-SQL (PO-9):检查期间采购订单执行情况.sql

    --采购订单执行情况查询(七天内接收情况)select pha.segment1       采购订单,         msib.segment1      物料编码,         pla.qu ...

  2. [置顶] 【cocos2d-x入门实战】微信飞机大战之三:飞机要起飞了

    转载请表明地址:http://blog.csdn.net/jackystudio/article/details/11730601 不过明眼人一看就知道起飞的不是飞机,是背景,相对运动引起的错觉. 1 ...

  3. Linux中service命令和/etc/init.d/的关系

    Linux中service命令和/etc/init.d/的关系   service xxx启动 /etc/init.d/ 目录下的xxx脚本 如一个脚本名为 mysvc保存在/etc/init.d/下 ...

  4. 杭电oj1326 Box of Bricks

    Tips:先求出平均数再分别计算各数与平均数的差相加,注意两个测试结果之间要空一行 #include<iostream> using namespace std; int main() { ...

  5. Aix 文件名补齐及aix6.1 bash安装

    Aix历史查询快捷键=>按ESC+k 设置KSH的自动补全(仅仅是文件名补全,没有命令补全)和历史命令功能 方法一: set -o vi 历史命令功能(esc -,esc +)自动补全文件名(e ...

  6. 使用mod_cluster进行apache httpd server和jboss eap 6.1集群配置

    本文简单介绍,使用mod_cluster进行apache httpd server和jboss eap 6.1集群配置.本配置在windows上测试通过,linux下应该是一样的.可能要稍作调整.后面 ...

  7. @property和@synthesize

    main.m #import <Foundation/Foundation.h> #import "Student.h" int main(int argc, cons ...

  8. C#委托,事件,匿名委托

    作为一个初学者,写下来是当做自己的学习笔记,希望在以后遇到问题的时候能够快速的找到方法 如果能帮助跟我一样的新人是更好不过的了        如果有什么不正确或者可以改进的地方也希望大家能够指出来  ...

  9. JS精粹(二)

    这章主要讲语法,DC使用了表示形式语法的巴克斯范式图,这的确比语言来得准确简洁.我只想表达一个问题:表达式与表达式语句的关系.因为其他问题很明白. 从DC的巴科斯范式图上大致可以认为,表达式是比表达式 ...

  10. Android RadioGroup/RadioButton

    RadioGroup      RadioButton的集合,提供多选一的机制      属性:   android:orientation="horizontal/vertical&quo ...