johLife 发表于 2012-12-29 11:21:28

SPServices Document Library 查询某个文档

<div id="cnblogs_post_body">
使用jquery.SPServices查询文档库里的某一个文档,需要设置CAMLQueryOptions属性,<ViewAttributes Scope="RecursiveAll" />才能查询出来,取值的时候需要使用SPFilterNode("z:row")

<div class="cnblogs_code">      $().SPServices({            operation: "GetListItems",            async: false,            listName: "Test Documents",            CAMLQuery: "<Query><Where><Eq><FieldRef Name='ID' /><Value Type='Counter'>" +strID+ "</Value></Eq></Where></Query>",            CAMLQueryOptions:'<QueryOptions><ViewAttributes Scope="RecursiveAll" /></QueryOptions>',            CAMLRowLimit: 1,            CAMLViewFields: "<ViewFields><FieldRef Name='YourField' /><FieldRef Name='ID' /></ViewFields>",            completefunc: function(xData, Status) {                $(xData.responseXML).SPFilterNode("z:row").each(function(i) {                  if($(this).attr("ows_YourField")!='' && $(this).attr("ows_YourField") != null && $(this).attr("ows_YourField") != 'undefined'){                        YourField = $(this).attr("ows_YourField");                  }                });            }      });
页: [1]
查看完整版本: SPServices Document Library 查询某个文档