SP へClientContext.loadQuery 方法 (sp.js)
イベントの受信に使用されるアセンブリの厳密な名前を指定します。
**適用対象:**apps for SharePoint | SharePoint Foundation 2013 | SharePoint Server 2013
SP.ClientContext.loadQuery(clientObjectCollection, exp)
パラメーター
clientObjectCollection
SP.ClientObjectCollection
コレクションを指定します。exp
String
、省略可能な式の文字列の結果を絞り込む。
戻り値
ArrayList
注釈
loadQueryメソッドは、 SP.ClientRuntimeContextオブジェクトから継承されます。
例
次の例では、"Include"式文字列でloadQueryメソッドを使用する方法を示します。
function retrieveSpecificListPropertiesToCollection(siteUrl) {
var clientContext = new SP.ClientContext(siteUrl);
var oWebsite = clientContext.get_web();
var collList = oWebsite.get_lists();
this.listInfoCollection = clientContext.loadQuery(collList, 'Include(Title, Id)');
clientContext.executeQueryAsync(
Function.createDelegate(this, this.onQuerySucceeded),
Function.createDelegate(this, this.onQueryFailed)
);
}
function onQuerySucceeded() {
var listInfo = '';
for (var i = 0; i < this.listInfoCollection.length; i++) {
var oList = this.listInfoCollection[i];
listInfo += 'Title: ' + oList.get_title() +
' ID: ' + oList.get_id().toString();
}
alert(listInfo.toString());
}
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() +
'\n' + args.get_stackTrace());
}