REST API を使用して SharePoint リストの個別の列データを取得する方法は? ループせずにそれを達成する方法はありますか?
ありがとう!
REST API を使用して SharePoint リストの個別の列データを取得する方法は? ループせずにそれを達成する方法はありますか?
ありがとう!
Use OData query operations in SharePoint REST requestsによると、このような操作grouping
はサポートされていません。
解決策は、JSON の結果が SharePoint REST サービスから返された後にグループ化を適用することです。
function groupBy(items,propertyName)
{
var result = [];
$.each(items, function(index, item) {
if ($.inArray(item[propertyName], result)==-1) {
result.push(item[propertyName]);
}
});
return result;
}
var catalog = { products: [
{ category: "Food & Dining"},
{ category: "Techonology"},
{ category: "Retail & Apparel"},
{ category: "Retail & Apparel"}
]};
var categoryNames = groupBy(catalog.products, 'category'); //get distinct categories
console.log(categoryNames);
SharePoint REST API を介してリスト アイテムを取得するために、次の関数が使用されているとします。
function getListItems(url, listname, query, complete, failure) {
$.ajax({
url: url + "/_api/web/lists/getbytitle('" + listname + "')/items" + query,
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
success: function (data) {
complete(data.d);
},
error: function (data) {
failure(data);
}
});
}
次に、次の例は、個別のタスク名を出力する方法を示しています。
getListItems('https://tenant.sharepoint.com/project','Tasks','?select=Title',
function(items){
var taskNames = groupBy(items,'Title');
console.log(taskNames);
},
function(error){
console.log(JSON.stringify(error));
}
);
私が理解していることから、あなたは http:///_vti_bin/Lists.asmx について話していると思います。
はい、単純な SQL を使用してデータをクエリできるはずです - Distinct を選択してください...
ユーザー Web サービスにも同じ概念を使用しています。ただし、それはあなたにとっての単なるリードです。
参照: http://msdn.microsoft.com/en-us/library/office/ms429658(v=office.14).aspx