CamlQuery examples SharePoint 2010
Some examples how can use SPquery or caml query in SharePoint 2010 Client Object model.
var site;
var context;
var list;
var collListItem;
context = new SP.ClientContext.get_current();
site = context.get_web();
context.load(site);
list = site.get_lists().getByTitle('MyList');
context.load(list);
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml(' ');
collListItem = list.getItems(camlQuery);
context.load(collListItem);
context.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
function onQuerySucceeded(sender, args) {
alert("Request succeeded. " + args.Message + "\n" + args.StackTrace);
}
function onQueryFailed(sender, args) {
alert("Request failed. " + args.Message + "\n" + args.StackTrace);
}
var site;
var context;
var list;
var collListItem;
context = new SP.ClientContext.get_current();
site = context.get_web();
context.load(site);
list = site.get_lists().getByTitle('MyList');
context.load(list);
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml('
collListItem = list.getItems(camlQuery);
context.load(collListItem);
context.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
function onQuerySucceeded(sender, args) {
alert("Request succeeded. " + args.Message + "\n" + args.StackTrace);
}
function onQueryFailed(sender, args) {
alert("Request failed. " + args.Message + "\n" + args.StackTrace);
}
0 comments:
Post a Comment