2013-10-30 14 views
0

我有列的狀態和原因的Sharepoint使用SP.Camlquery()jQuery中

我用

<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> 

我只需要狀態欄是fetched.I需要camlquery和我的列表目標不知道在哪裏寫。

回答

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` 
相關問題