加入功能区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. 大型网站性能优化(页面(HTML)优化的方法)

    页面(HTML)优化的方法 除了语言层面上进行优化外,对Web开发,HTML的优化将很大程度上减轻服务器的负载,提高网站的性能 1). 减少HTTP请求数.打开网页,浏览器会发出很多请求,图片,脚本, ...

  2. 重启VirtualBox里面的系统提示VT-x features locked or unavailable in MSR错误

    有次不小心设置了一下virtualbox里面的一些配置,然后启动系统时出现了如下提示 在网上找了一些资料尝试了一些方法偶然有一次成功 原来是自己把那个cpu个数设置成了2,改成1就好了,不知道为什么做 ...

  3. Delphi XE6 试用Android视频采集

    FMX支持视频采集,具体见FMX.Media,提供了很类支持音频.视频的处理. 按帮助文档,用Note3做了测试,结果,效率太低,不可用. 具体可查询帮助Video Capturing一节,我就是按这 ...

  4. Codeforces 325D

    #include <cstdio> #include <algorithm> #include <cstring> #include <cstdlib> ...

  5. StudentSchema student实例数据库环境搭建

    环境搭建 查看默认表空间和临时表空间 select tablespace_name from dba_tablespaces: 创建用户 并给用户设置默认表空间和临时表空间 SQL> creat ...

  6. MySQL Troubleshoting:Waiting on query cache mutex

    今天被MySQL Query Cache 炕了.线上大量 Waiting on query cache mutex 那么什么是 Query Cache? QC 缓存的是整个SELECT的结果集.而非执 ...

  7. UI标签库专题十三:JEECG智能开发平台 ckfinder(ckfinder插件标签)

    1. ckfinder(ckfinder插件标签) 1.1. 參数 属性名 类型 描写叙述 是否必须 默认值 name string 属性名称 是 null value string 默认值 否 nu ...

  8. 机顶盒加密系统流程 ECM EMM CW SK

    随着数字视频广播(DVB)的发展.观众将面对数字电视节目的选择多.广播业因为投资成本增加,这是需要收取费用的用户观看. 有条件接收系统(Conditional Access System).它的主要功 ...

  9. 一个很好的用C#导出数据到Excel模板的方法

    /// <summary> /// 导数据到Excel模板 /// </summary> /// <param name="tab">要输出内容 ...

  10. PHP自学2——将用户提交表单存储到外部普通文件中

    在上一节中我们已经实现了将用户的订单信息提交到服务器端,然后服务器端将提交信息返回并显示到页面上.这一节将把上一节用户的订单信息保存到外部的普通文件中(即.txt文本文件中). 本节代码将用户提交的订 ...