CAML Query在从Sharepoint 2010获取列表时无法放置RowLimit

时间:2016-07-25 12:02:44

标签: javascript sharepoint

**我是CAML查询的新手,下面的代码现在获取列表数据我想把行限制放在其中。任何帮助都会有很大的帮助。我尝试更改查询,但对查询的任何更改都不起作用 **

                        来自MycustomList的内容     

<body>
<table id="myDataTable" border =1 width="95%" align="center"  >
                        <tr align='left' bgcolor="lightBlue" >
                        <td><B>Image</B></td>
                        <td><B>Description</B></td>
                        </tr>
</table>

<SCRIPT type=text/javascript>
get() ;
function get()
{            
            var htmlTable='';        
            var method = "GetListItems";                 
            var webURL =  $().SPServices.SPGetCurrentSite() ;                  
            var list = "Success Story";                      
            var fieldsToRead = "<ViewFields Properties='True' />";
            var query = "<Query><OrderBy><FieldRef Name='ID'  Ascending='False' /></OrderBy></Query>"; 


            $().SPServices
            ({
                        operation: method,
                        async: false, 
                        webURL: "http://teamsites.danskenet.net/sites/dci/orgcbit/cbi/",
                        listName: list,
                        CAMLViewFields: fieldsToRead,
                        CAMLQuery: query,                                                                                     
                        completefunc: function (xData, Status)
                         {
                             $(xData.responseXML).SPFilterNode("z:row").each(function() 
                             {

                                  var Image = $(this).attr("ows_Image").split(",")[0];

                                  var Description  =  $(this).attr("ows_Description");

                        // Store data in variable once all data in stored append it to table
                                   htmlTable+="<tr align='middle'>" +
                                   "<td align='left'><img height="+200+" src="+Image+"></img></td>" +
                                   "<td align='left'>"+ Description+"</td>"  +  "</tr>";

                                   $("#myDataTable").append(htmlTable);

                               });
                       }
           });
};

</script>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

如果我理解正确,这是您的解决方案。 你的CAML查询应该是这样的

<QueryOptions>//You can use query options
      <RowLimit>2</RowLimit>
   </QueryOptions>
   <Where>
      <Eq>
         <FieldRef Name='Status' />
         <Value Type='Choice'>Approved</Value>
      </Eq>
   </Where>