关于Metadata Client Object Model 的一些操作
一、查询指定的Termset及子项
- <script type="text/javascript" src="/Style%20Library/aaaa/Scripts/jquery-1.11.1.min.js" language="javascript"></script>
- <script type="text/javascript">RegisterSod("sp.taxonomy.js", "\u002f_layouts\u002f15\u002fsp.taxonomy.js?rev=l0dFB37050OQxbmrgu6z7Q\u00253D\u00253D");</script>
- <script type="text/javascript">
- $(document).ready(function () {
- var scriptbase = _spPageContextInfo.webServerRelativeUrl + "_layouts/15/";
- $.getScript(scriptbase + "SP.Runtime.js",
- function () {
- $.getScript(scriptbase + "SP.js", function () {
- $.getScript(scriptbase + "SP.Taxonomy.js", execOperation);
- });
- }
- );
- });
- function execOperation() {
- //Current Context
- var context = SP.ClientContext.get_current();
- //Current Taxonomy Session
- var taxSession = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);
- //Term Stores
- var termStores = taxSession.get_termStores();
- //Name of the Term Store from which to get the Terms.
- var termStore = termStores.getByName("IdeaTracker_MMS");
- //GUID of Term Set from which to get the Terms.
- var termSet = termStore.getTermSet("bcf031d3-7eb2-433a-b5ff-b92398758431");
- var terms = termSet.getAllTerms();
- context.load(terms);
- context.executeQueryAsync(function () {
- var termEnumerator = terms.getEnumerator();
- var termList = "Terms: \n";
- while (termEnumerator.moveNext()) {
- var currentTerm = termEnumerator.get_current();
- termList += currentTerm.get_name() + "\n";
- }
- alert(termList);
- }, function (sender, args) {
- console.log(args.get_message());
- });
- }
- </script>
二、创建Term Group
- <script type="text/javascript">
- $(document).ready(function () {
- var scriptbase = _spPageContextInfo.webServerRelativeUrl + "_layouts/15/";
- $.getScript(scriptbase + "SP.Runtime.js",
- function () {
- $.getScript(scriptbase + "SP.js", function () {
- $.getScript(scriptbase + "SP.Taxonomy.js", execOperation);
- });
- }
- );
- });
- function execOperation() {
- //Current Context
- var context = SP.ClientContext.get_current();
- //Current Taxonomy Session
- var taxSession = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);
- //Term Stores
- var termStores = taxSession.get_termStores();
- //Term Store under which to create the group.
- var termStore = termStores.getByName("Taxonomy_Dmxzz8tIBzk8wNVKQpJ+xA==");
- //New Group with name and new GUID
- var newGroup = termStore.createGroup("New Group Name", "b300304a-1693-4629-a1c0-dff7bda644ff");
- context.load(newGroup);
- context.executeQueryAsync(function () {
- console.log(newGroup.get_name());
- }, function (sender, args) {
- console.log(args.get_message());
- });
- }
- </script>
三、创建Term Set
- <script type="text/javascript">
- $(document).ready(function () {
- var scriptbase = _spPageContextInfo.webServerRelativeUrl + "_layouts/15/";
- $.getScript(scriptbase + "SP.Runtime.js",
- function () {
- $.getScript(scriptbase + "SP.js", function () {
- $.getScript(scriptbase + "SP.Taxonomy.js", execOperation);
- });
- }
- );
- });
- function execOperation() {
- //Current Context
- var context = SP.ClientContext.get_current();
- //Current Taxonomy Session
- var taxSession = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);
- //Term Stores
- var termStores = taxSession.get_termStores();
- //Term Store under which to create the Term Set.
- var termStore = termStores.getByName("Taxonomy_Dmxzz8tIBzk8wNVKQpJ+xA==");
- //Get group by GUID
- var peopleGroup = termStore.getGroup("97eaa7b8-9778-4f61-acb3-7f47abba13c3");
- //Create New Term Set in Group with Name, New GUID and LCID
- var newTermSet = peopleGroup.createTermSet("New TermSet Name", "49dac247-d315-4065-8718-e8c3f50e7dcd", 1033);
- context.load(newTermSet);
- context.executeQueryAsync(function () {
- console.log(newTermSet.get_name());
- }, function (sender, args) {
- console.log(args.get_message());
- });
- }
- </script>
四、创建Term
- <script type="text/javascript">
- function execOperation() {
- //Current Context
- var context = SP.ClientContext.get_current();
- //Current Taxonomy Session
- var taxSession = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);
- //Term Stores
- var termStores = taxSession.get_termStores();
- //Term Store under which to create the term.
- var termStore = termStores.getByName("Taxonomy_Dmxzz8tIBzk8wNVKQpJ+xA==");
- //Term Set under which to create the term.
- var termSet = termStore.getTermSet("b49f64b3-4722-4336-9a5c-56c326b344d4");
- //Name of the term, LCID and a new GUID for the term.
- var newTerm = termSet.createTerm("India", 1033, "b49f64b3-4722-4336-9a5c-56c326b344a9");
- //newTerm.set_isAvailableForTagging(true);
- context.load(newTerm);
- context.executeQueryAsync(function () {
- alert("Term Created: " + newTerm.get_name());
- }, function (sender, args) {
- console.log(args.get_message());
- });
- }
- </script>
五、获取单一值的字段
- <script type="text/javascript">
- function execOperation() {
- var context = SP.ClientContext.get_current();
- var list = context.get_web().get_lists().getByTitle('TaxonomyCustomList');
- var listItem = list.getItemById(1);
- context.load(listItem);
- context.executeQueryAsync(function () {
- //Single Value Taxonomy Column
- var label = listItem.get_item("MyTaxColumn").get_label();
- //Term GUID
- var termGUID = listItem.get_item("MyTaxColumn").get_termGuid();
- //Type ID
- var typeID = listItem.get_item("MyTaxColumn").get_typeId();
- //WSS ID
- var wssID = listItem.get_item("MyTaxColumn").get_wssId();
- }, function (sender, args) {
- console.log(args.get_message());
- });
- }
- </script>
六、获取多选值的字段
- <script type="text/javascript">
- function execOperation() {
- var context = SP.ClientContext.get_current();
- var list = context.get_web().get_lists().getByTitle('TaxonomyCustomList');
- var listItem = list.getItemById(1);
- context.load(listItem);
- context.executeQueryAsync(function () {
- //Multivalue Taxonomy Column
- var taxEnumerator = listItem.get_item("MyTaxColumn").getEnumerator();
- while (taxEnumerator.moveNext()) {
- //Label
- var currentTerm = taxEnumerator.get_current();
- //Label
- var label = currentTerm.get_label();
- //Term GUID
- var termGUID = currentTerm.get_termGuid();
- //Type ID
- var typeID = currentTerm.get_typeId();
- //WSS ID
- var wssID = currentTerm.get_wssId();
- }
- }, function (sender, args) {
- console.log(args.get_message());
- });
- }
- </script>
关于Metadata Client Object Model 的一些操作的更多相关文章
- SharePoint Client Object Model API 介绍以及工作原理解析
CSOM和ServerAPI 的对比 SharePoint从2010开始引入了Client Object Model的API(后文中用CSOM来代替),从名字来看,我们可以简单的看出,该API是面向客 ...
- 解决在使用client object model的时候报“object does not belong to a list”错误
在查看别人代码的时候,发现了个有意思的问题,使用client object model将一个文件check in 我使用的是如下语句获取file Microsoft.SharePoint.Client ...
- 关于SharePoint 的Client object model该何时load和execut query的一点自己的看法
很多人在用client object model的时候,不知道何时或者该不该load,今天看到一个观点描述这个问题,觉得很有道理,和大家分享.那就是写client object model就像写sql ...
- SharePoint 2010 匿名用户调用Client Object Model访问列表项
最近有个小需求,在门户首页上加个通知公告的版块,新闻来源是列表项,需要有垂直滚动的效果. 第一个想法就是通过SharePoint的Client Object Model获取列表数据再加上JQuery来 ...
- c# sharepoint client object model 客户端如何创建中英文站点
c# sharepoint client object model 客户端如何创建中英文站点 ClientContext ClientValidate = tools.GetContext(Onlin ...
- 在C#开发中如何使用Client Object Model客户端代码获得SharePoint 网站、列表的权限情况
自从人类学会了使用火,烤制的方式替代了人类的消化系统部分功能,从此人类的消化系统更加简单,加速了人脑的进化:自从SharePoint 2010开始有了Client Side Object Model ...
- 记一个使用Client Object Model上传文件的小例子
1. 新建一个C#的Console project. 2. 给project 添加reference: Microsoft.SharePoint.Client Microsoft.SharePoint ...
- [SharePoint]javascript client object model 获取lookup 类型的field的值,包括user类型(单人或者多人)的值。how to get the multiple user type/lookup type field value by Javascript client object model
1. how to get value var context = new SP.ClientContext.get_current(); var web = context.get_web(); v ...
- DHTML Object Model&DHTML&DOM
DHTML Object Model:DHTML对象模型,利用DHTML Object Model可以单独操作页面上的对象,每个HTML标记通过它的ID和NAME属性被操纵,每个对象都具有自己的属性. ...
随机推荐
- OC和C++的区别
C++语言特点: 1.在C语言的基础上进行扩充和完善,使C++兼容了C语言的面向过程特点,又成为了一种面向对象的程序设计语言: 2.可以使用抽象数据类型进行基于对象的编程: 3.可以使用多继承.多态进 ...
- C++ string头文件
转载自https://blog.csdn.net/superna666/article/details/52809007/ 作者 zhenzhenjiajia888 标准c++中string类函数介绍 ...
- c++ 指针数组,输入4个季度的花费,计算出总花费
#include <iostream> #include <array> #include <string> const int Seasons = 4; cons ...
- Linux基础学习-LVM逻辑卷管理遇到的问题
LVM学习逻辑卷管理创建逻辑卷遇到的问题 1 实验环境 系统 内核 发行版本 CentOS 2.6.32-754.2.1.el6.x86_64 CentOS release 6.10 (Final) ...
- 拓展jQuery的serialize(),将form表单转化为json对象
jQuery 的 serialize() 方法经常会报 Uncaught TypeError: JSON.serializeObject is not a function 的错误, 原装的方法真的一 ...
- vue_music:封装scroll.vue组件
在项目中经常用到滚动,结合Better-scroll封装了sroll.vue组件参考链接:https://ustbhuangyi.github.io...http://www.imooc.com/ar ...
- Vue表单输入绑定
<h3>基础用法</h3> <p>你可以用<strong>v-model</strong>指令在表单input,textarea以及sele ...
- 剑指Offer(书):顺时针打印数组
题目:输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字,例如,如果输入如下4 X 4矩阵: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 则依次打印出数字1 ...
- 《鸟哥的Linux私房菜》学习笔记(1)——文件与目录
在Linux中,任何设备都是文件,不仅如此,连数据通信的接口也有专门的文件负责.可以说,一切皆文件,目录也是一种文件,是路径映射.因此,文件系统是Linux的基础. 一.文件与目录管理命令 1.ls( ...
- HBase0.94.2-cdh4.2.0需求评估测试报告1.0之二
Hbase 配置文件: hbase-site.xml <configuration> <property> <name>hbase.cluster.distribu ...