0

我有一个包含 STATUS 和 Reason 列的目标列表

我用了

  <script language="ecmascript" type="text/ecmascript">


     ExecuteOrDelayUntilScriptLoaded(ViewItem, "sp.js");
function ViewItem()
 {
 var context = new SP.ClientContext.get_current();
 var web = context.get_web();
  var list = web.get_lists().getByTitle('Objectives');

 var query = SP.CamlQuery.createAllItemsQuery();
 allItems = list.getItems(query);
  context.load(allItems, 'Include(STATUS)');
                                   context.executeQueryAsync(
         Function.createDelegate(this, this.success),          Function.createDelegate     
    (this, this.failed));
       }

           </script>

我只需要获取状态列。我需要 camlquery,但我不知道在哪里写。

4

1 回答 1

4

请参考下面的代码片段,它可能对您有所帮助

enter code here

 function viewItem() {
    var clientContext = new SP.ClientContext.get_current();
    var web = clientContext.get_web();
    var list = web.get_lists().getByTitle("Sample");
    var camlQuery = new SP.CamlQuery();
    var q = '<View><Query><Where><Eq><FieldRef Name="ID" /><Value Type="Text">10</Value></Eq></Where></Query></View>';
    camlQuery.set_viewXml(q);
    this.listItems = list.getItems(camlQuery);
    clientContext.load(listItems, 'Include(Status,othercolumns)');
    clientContext.executeQueryAsync(Function.createDelegate(this, onItemsLoadSuccess), Function.createDelegate(this, onQueryFailed));
}
function onItemsLoadSuccess(sender, args) {
}

function onQueryFailed(sender, args) {
}`enter code here`  
于 2013-10-30T09:34:49.873 回答