在该文章中,我将介绍如何使用TaxonomyWebTaggingControl控件, 首先我相信您已经在SharePoint Managed Metadata Service里定义Term Sets,如果没有,请先定义您的Term Sets(可以参考该文章how to create metadata column), 该控件能帮助我们显示/设置各种Terms。

  其次我们需要了解Managed Metadata的结构,请看以下图,您可以清晰地看到每一个结构(Term Store -> Group -> Term Set -> Terms),接下来我们进入主题, 该如何使用TaxonomyWebTaggingControl 控件绑定这些数据呢,在该案例中我们绑定Product Type Group的所有数据。

  根据以下步骤:

  1. 在我们的设计页面中定义注册Microsoft.SharePoint.Taxonomy控件
<%@ Register TagPrefix="Taxonomy" Namespace="Microsoft.SharePoint.Taxonomy" Assembly="Microsoft.SharePoint.Taxonomy, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

  2.  在内容部分添加TaxonomyWebTaggingControl控件

<Taxonomy:TaxonomyWebTaggingControl ID="twtc_productType" runat="server"></Taxonomy:TaxonomyWebTaggingControl>

  3.  在后台绑定数据(从Managed Metadata Service中获取Group的数据)

  

 using Microsoft.SharePoint;
using Microsoft.SharePoint.Taxonomy; /// <summary>
/// TaxonomyWebTaggingControl Bind
/// </summary>
/// <param name="productTypeControl">TaxonomyWebTaggingControl Control</param>
public static void ProductTypeBind(TaxonomyWebTaggingControl productTypeControl)
{
// Open the site
using (SPSite site = new SPSite(SPContext.Current.Web.Url))
{
using (SPWeb web = site.OpenWeb())
{
TaxonomySession session = new TaxonomySession(site);
// Get the Term Store node from Managed Metadata Service
TermStore termStore = null;
if (session.TermStores != null && session.TermStores.Count > )
{
termStore = session.TermStores["Managed Metadata Service"]; //if you a custom meta service you should change name.
}
if (termStore != null)
{
//Guid anchorId = new Guid();
Group group = termStore.Groups["Product Type"]; // Get the Group node from Managed Metadata Service
productTypeControl.SspId.Add(termStore.Id); // do it for all termsets
foreach (TermSet item in group.TermSets)
{
productTypeControl.TermSetId.Add(item.Id); // Add the Term
/* This could be achieved by setting AnchorId property for TaxonomyWebTaggingControl control that allows to specify ID of parent Term for any valid value in control.
foreach (Term term in item.Terms)
{
if (term.Name == ManagedMetadataType.TermName)
{
anchorId = term.Id;
break;
}
} */
} //productTypeControl.AnchorId = anchorId;
productTypeControl.GroupId = group.Id;
productTypeControl.IsAddTerms = false;
}
}
}
}

  以上代码将可以获取Product Type(defined by GB/T 13702-1992)节点的数据, 可以查看一下效果图

  有些朋友会问是否可以根据Term 节点作为父节点显示?对于该问题的回答是可以, 比如我想以All为父节点,我们仅仅通过该控件中的AnchorId属性,将All的id赋值给AnchorId即可,留心的朋友会发现在以上代码中注释部分就是实现该功能

  

  如果有大牛认为有更好的idea, 请提供您宝贵的建议供大家学习,谢谢

SharePoint 2013 如何使用TaxonomyWebTaggingControl 控件的更多相关文章

  1. sharepoint 2010 列表数据分页控件介绍 pagination UserControl

    转:http://blog.csdn.net/chenxinxian/article/details/8714391 这里主要是介绍下最近开发的一个sharepoint列表或者文档库的分页控件,并且把 ...

  2. SharePoint 2007 页面及用户控件

    页面: <%@ Assembly Name="HP.EUSM.Self-ServiceUpgradeQuota.SPCustomAction, Version=1.0.0.0, Cul ...

  3. SharePoint 2010 master page 控件介绍(1)

    转:http://blog.csdn.net/lgm97/article/details/6409204 以下所有的内容都是根据Randy Drisgill (MVP SharePoint Serve ...

  4. Sharepoint2013:日期控件报错

    1 问题 1> 在sharepoint中的,日期控件(DateTimeControl),日期过滤控件(Date Filter)和SPListViewFilter等包含日期组件的控件,在特定情况下 ...

  5. SharePoint 2013 新功能探索 之 标注控件

    SharePoint 2013 引入了新的UI,同时也跟进了网络潮流,把应用最广泛的标注控件也引入到了SharePoint,先看两个应用    以上是两个开发当中经常会用到,下面就介绍一下如何开发相同 ...

  6. sharepoint 2013 附件控件FileUpload怎样检验是否为图片的方法

    记录一下关于附件控件FileUpload怎样检验是否为图片的方法: function checkImg() { var fileObj =document.getElementById('<%= ...

  7. SharePoint 中用户控件的开发及应用

    1.新建解决方案以及SharePoint项目,步骤比较简单略过,然后映射CONTROLTEMPLATES文件夹,在里面添加用户控件(仅场解决方案),如下图: 2.解决方案结构,如下图: 简单介绍一下, ...

  8. 2013 duilib入门简明教程 -- 自绘控件 (15)

        在[2013 duilib入门简明教程 -- 复杂控件介绍 (13)]中虽然介绍了界面设计器上的所有控件,但是还有一些控件并没有被放到界面设计器上,还有一些常用控件duilib并没有提供(比如 ...

  9. Dynamic CRM 2013学习笔记(八)过滤查找控件 (类似省市联动)

    我们经常要实现类似省市联动一样的功能,常见的就是二个查找控件,一个选择了省后,另一个市的查找控件就自动过滤了,只显示当前省下的市,而不是所有的市.当然这是最简单的,实际工作中还有更复杂的功能要通过过滤 ...

随机推荐

  1. 深入解析Java中volatile关键字的作用

    转(http://m.jb51.net/article/41185.htm)Java语言是支持多线程的,为了解决线程并发的问题,在语言内部引入了 同步块 和 volatile 关键字机制 在java线 ...

  2. SuperSocket使用demo

    using System;using System.Collections.Generic;using System.Linq;using System.Text;using SuperSocket. ...

  3. 移动开发框架,第【一】弹:QuoJs 官方文档(汉化版)

    作者:一只猿 原文地址: http://www.92ez.com 转载请注明出处,谢谢 帮助说明 如果您认为QuoJS只是一个触摸事件管理器,那你就错了,它是一个功能丰富的类库,无需第三方JavaSc ...

  4. 在LaTeX里插入全页的pdf 分类: LaTex 2015-02-04 17:20 142人阅读 评论(0) 收藏

    要帮女友排版毕业论文,需要插入封面,省时省力的方法就是把学校给的Word封面保存成PDF然后插入到Latex文档中. 首先添加下面的宏: \usepackage[final]{pdfpages} 然后 ...

  5. [RxJS] Combination operator: zip

    CombineLatest and withLatestFrom are both AND-style combination operators. In this lesson, we will l ...

  6. [AngularJS + Unit Testing] Testing Directive's controller with bindToController, controllerAs and isolate scope

    <div> <h2>{{vm.userInfo.number}} - {{vm.userInfo.name}}</h2> </div> 'use str ...

  7. 微信公众号支付流程(Node实现)

    前言 花费了一天时间,调通了微信公众号支付.作下记录,方便以后再次填坑.先声明,微信公众号支付,不同于微信H5支付,这点在本文结束时再详细说明. 微信配置 设置测试目录 在微信公众平台设置,栏目见下图 ...

  8. sql 语句总结

    sql 语句的总结: 下面是个统计  from_userid 字段相同的数数量有多少在用num参数来接收,这个数值: select *,count(*)  as num from invitation ...

  9. node里如何查看浏览器信息

    'use strict'; let http = require(`http`); http.createServer((req, res) => { console.log(req.heade ...

  10. 我的网站终于连续一星期,ip数1000以上了

    相信每个程序员都有一个站长梦,我也是如此.说来惭愧,从2015年4月份开始,我投入了50块的域名费用,50块的空间费用,现在才回本. 由于终于从百度联盟的手里赚了一百块,按耐不住的菜鸟之冲动,于是决定 ...