1. <script type="text/javascript">
  2. // <![CDATA[
  3.  
  4. var chongdianbaId;
  5. var elm = document.getElementById("idAttachmentsTable");
  6. var elmAttachmentRow = document.getElementById("idAttachmentsRow");
  7. if ((elm == null || elm.rows.length == 0) && (elmAttachmentRow!=null)){
  8. elmAttachmentRow.style.display='none';
  9. }else{
  10. var attachmenturl = GetAttachmentsUrl().split(";")[0];
  11. chongdianbaId = attachmenturl.split("/")[7];
  12. ExecuteOrDelayUntilScriptLoaded(GetChongDianBaName,"SP.js");
  13. }
  14. //获取附件url地址集合
  15. function GetAttachmentsUrl(){
  16. var urls;
  17. var locUrl = window.location.href;
  18. if (locUrl.indexOf("doccenter/Lists/List1/DispForm.aspx") != -1){
  19. var td = elm.getElementsByTagName("td");
  20. var len = td.length;
  21. for (i = 0; i < len; i++) {
  22. var a = td[i].getElementsByTagName("a")
  23. urls += a[0].href + ";";
  24. }
  25. }
  26. return urls;
  27. }
  28. //获取充电吧标题
  29. var chongdianbaName;
  30. var chongdianba;
  31. function GetChongDianBaName() {
  32. var ctx = new SP.ClientContext.get_current();
  33. var web = ctx.get_web();
  34. var list = web.get_lists().getByTitle("充电吧");
  35. var camlQuery = new SP.CamlQuery();
  36. camlQuery.set_viewXml('<View><Query><Where><Contains><FieldRef Name=\'ID\'/>' + '<Value Type=\'Counter\'>'+ chongdianbaId + '</Value></Contains></Where></Query><RowLimit>10</RowLimit></View>');
  37. this.chongdianba = list.getItems(camlQuery);
  38. ctx.load(this.chongdianba, "Include(Title)");
  39. ctx.executeQueryAsync(Function.createDelegate(this,this.onSuccess0),Function.createDelegate(this,this.onFailed0));
  40. }
  41. function onSuccess0(sender, args) {
  42. var count = 0;
  43.  
  44. var listEnumerator = this.chongdianba.getEnumerator();
  45. while (listEnumerator.moveNext()) {
  46. count = count + 1;
  47. var currentItem = listEnumerator.get_current();
  48. chongdianbaName += currentItem.get_item('Title').toString();
  49. }
  50. chongdianbaName = chongdianbaName.replace('undefined','');
  51. alert(chongdianbaName);
  52. ExecuteOrDelayUntilScriptLoaded(GetAttachmentFolderName,"SP.js");
  53. }
  54. function onFailed0(sender, args) {
  55. alert('failed. Message:' + args.get_message());
  56. }
  57. //获取KnowledgeLibrary内容
  58. var folderName;
  59. var knowledgeLibrary;
  60. function GetAttachmentFolderName() {
  61. var ctx = new SP.ClientContext("/");
  62. var web = ctx.get_web();
  63. var list = web.get_lists().getByTitle("KnowledgeLibrary");
  64. var camlQuery = new SP.CamlQuery();
  65. camlQuery.set_viewXml('<View><Query><Where><Contains><FieldRef Name=\'Title\'/>' + '<Value Type=\'Text\'>'+ chongdianbaName + '</Value></Contains></Where></Query><RowLimit>10</RowLimit></View>');
  66. this.knowledgeLibrary = list.getItems(camlQuery);
  67. ctx.load(this.knowledgeLibrary, "Include(dtAttachmentFolderName,dtAttachmentListName)");
  68. ctx.executeQueryAsync(Function.createDelegate(this,this.onSuccess),Function.createDelegate(this,this.onFailed));
  69. }
  70. function onSuccess(sender, args) {
  71. var count = 0;
  72.  
  73. var listEnumerator = this.knowledgeLibrary.getEnumerator();
  74. while (listEnumerator.moveNext()) {
  75. count = count + 1;
  76. var currentItem = listEnumerator.get_current();
  77. folderName += currentItem.get_item('dtAttachmentFolderName').toString();
  78. }
  79. folderName = folderName.replace('undefined','')
  80. alert(folderName);
  81. ExecuteOrDelayUntilScriptLoaded(GetAttachmentItemID,"SP.js");
  82. }
  83. function onFailed(sender, args) {
  84. alert('failed. Message:' + args.get_message());
  85. }
  86. //获取附件id
  87. var attachmentFiles;
  88. var attachmentIDs;
  89. function GetAttachmentItemID() {
  90. var ctx = new SP.ClientContext("/");
  91. var web = ctx.get_web();
  92. var attachmentFolder = web.getFolderByServerRelativeUrl('/DentsuDocumentLibraryAttachments/' + folderName);
  93. this.attachmentFiles = attachmentFolder.get_files();
  94. ctx.load(this.attachmentFiles);
  95. ctx.executeQueryAsync(Function.createDelegate(this,this.onSuccess1),Function.createDelegate(this,this.onFailed1));
  96. }
  97. function onSuccess1(sender, args) {
  98. var listEnumerator = this.attachmentFiles.getEnumerator();
  99. while (listEnumerator.moveNext()) {
  100. var currentItem = listEnumerator.get_current();
  101. attachmentIDs += currentItem.get_item('ID').toString() + ';';
  102. }
  103. alert(attachmentIDs);
  104. }
  105. function onFailed1(sender, args) {
  106. alert('failed. Message:' + args.get_message());
  107. }

  

jsom sharepoint 2010 循环获取多个list的item值的更多相关文章

  1. sharepoint 2010 中获取system账号的真实账号

    在使用sharepoint的时候有的时候需要在后台获取当前登录用户的登录名,一般的时候使用SPContext.Current.Web.CurrentUser就可以了,但是有一个特殊的用“系统账户”,获 ...

  2. selenium,统计某分支下有多少个同类子分支的方法(用于循环获取同类型子分支属性值)

    利用selenium自动化统计微博阅读数 查看微博阅读数的元素路径 微博列表中第一条微博的元素路径“//*[@id="Pl_Official_MyProfileFeed__20"] ...

  3. python 3.6闭包+循环获取出字典中所有的值并保存在list中

    def list_test(): list1=[] def list_all_dict(a): #检测字段类型 if isinstance(a,dict): for x in range(len(a) ...

  4. SharePoint 2010 获取当前用户的权限

    转:http://blog.csdn.net/sygwin_net/article/details/6790500 操作环境:SharePoint 2010 关于SharePoint 的权限架构,具体 ...

  5. 在 SharePoint 2010 中访问数据

    转:http://blog.banysky.net/?p=81001 数据访问的关键方法有哪些? | 使用查询类 | 使用 SPQuery | 使用 SPSiteDataQuery | 使用 LINQ ...

  6. 在SharePoint 2010中,如何找回丢失的服务账号(Service Account)密码

    背景信息: 通常在SharePoint环境中我们会使用很多的服务账号来运行各种不同的服务,尤其在企业环境中,由于权限管理条例严格,这些服务账号更是只能多不能少.面对如此多的服务账号,各个企业都会有自己 ...

  7. SharePoint 2010商业智能组件

    Microsoft Office SharePoint Server (MOSS) 2007中,就已经提供了很多支持商业智能的能力.其中主要的组件包含Excel Services, Reporting ...

  8. SharePoint 2010 文档管理之过期归档工具

    前言:使用过SharePoint的人都知道,SharePoint对于操作是便捷的,但是对于数据量承载却是不令人满意的,这样,就要求我们需要更加合理的使用,规范大家的使用规则和习惯,所以,定期清理不必要 ...

  9. SharePoint 2010 最佳实践学习总结------第1章 SharePoint Foundation开发基础

    ----前言 这段时间项目出在验收阶段,不是很忙,就潜心把SharePoint学一下,不求有多深刻,初衷只是先入门再说.后续会发布一系列的学习总结.主要学习的书籍为<SharePoint2010 ...

随机推荐

  1. Android 软件开发之如何使用Eclipse Debug调试程序详解及Eclipse常用快捷键(转)

    1.在程序中添加一个断点如果所示:在Eclipse中添加了一个程序断点 在Eclipse中一共有三种添加断点的方法 第一种: 在红框区域右键出现菜单后点击第一项 Toggle Breakpoint 将 ...

  2. Windows Azure Cloud Service (47) 修改Cloud Service时区

    <Windows Azure Platform 系列文章目录> 本文介绍内容适合于Azure Global和Azure China 我们在使用Cloud Service的时候,会发现默认的 ...

  3. SQL Server安全(3/11):主体和安全对象(Principals and Securables)

    在保密你的服务器和数据,防备当前复杂的攻击,SQL Server有你需要的一切.但在你能有效使用这些安全功能前,你需要理解你面对的威胁和一些基本的安全概念.这篇文章提供了基础,因此你可以对SQL Se ...

  4. html5和css3的常用参考网

    当我们使用HTML5, CSS3,甚至Bootstrap设计网站的时候,有些方面是必须考虑的,比如字体大小,标题大小,行间距,每行字数,字体,颜色,背景图片和文字的搭 配,图标,留白和布局...... ...

  5. C#序列化s实体类成Xml,去除空格、换行符以及命名空间

    序列化实体类成为一个干净的Xml,不带空格.换行符以及命名空间 /// <summary> /// 序列化成XML /// </summary> /// <typepar ...

  6. 瀑布式开发、迭代开发、敏捷开发、XP与SCRUM的区别

    瀑布式开发.迭代开发,区别[都属于,生命周期模型]         两者都是一种开发模式,就像设计模式一样,考虑的角度不一样,个人感觉谈不到取代一说.         传统的瀑布式开发,也就是从需求到 ...

  7. 开始MS SQL Server 2016之旅

    下班前一刻,把MS SQL Server 2016安装好,国庆回来之后,就可以学习之旅......

  8. Winform混合式开发框架的特点总结

    Winform混合式开发框架,是一种支持分布式部署的应用模式,支持直接连接数据库,访问远程WCF服务,访问远程Web API服务等服务的综合性框架,根据不同的需求采用不同的数据接口,是一个适应性很广的 ...

  9. .net的垃圾回收机制简述

    .如何理解.net中的垃圾回收机制. .NET Framework 的垃圾回收器管理应用程序的内存分配和释放.每次您使用 new 运算符创建对象时,运行库都从托管堆为该对象分配内存.只要托管堆中有地址 ...

  10. MVC的路径查找顺序

    使用MVC的朋友们,知道MVC的funny之处. 但是如果出现路径找不到,请记住以下的页面路径寻找顺序. http://www.cnblogs.com/sosoft/ 首先,知道你的Controlle ...