文件集主页:
我正在使用Angularjs和REST API来检索SharePoint 2013文档集主页上的文档以获得更多功能。如果我提供列表和文件夹名称(' AD%20Letters / Liquidity%20Risk%20Management'),下面的代码可以工作,但我有一个以上的文档集文件夹,需要动态获取列表和文件夹名称('" + ListName / FolderName +"')为每个文档集文件夹,以便它在文档集主页上显示文档和其他元数据。附上文档集主页如何显示的屏幕截图,其中包含以下代码,但仅针对我提供其名称的Liquidity Risk Management文件夹。有什么建议。
<script type="text/javascript">
var myAngApp = angular.module('SharePointAngApp', []);
myAngApp.controller('spCustomerController', function ($scope, $http) {
$http({
method: 'GET',
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/getfolderbyserverrelativeurl('AD%20Letters/Liquidity%20Risk%20Management')/files?$expand=ListItemAllFields/FieldValuesAsText
}).success(function (data, status, headers, config) {
$scope.customers = data.d.results;
}).error(function (data, status, headers, config) {
});
});
</script>
<h1> Policy Documents</h1>
<div ng-app="SharePointAngApp" class="row">
<div ng-controller="spCustomerController" class="span10">
<table class="table table-condensed table-hover">
<tr>
<th>ID</th>
<th>File Type</th>
<th>Title</th>
<th>Project Phases</th>
<th>Due Date for Comments</th>
<th>Policy Type</th>
<th>Author</th>
</tr>
<tr ng-repeat="customer in customers | orderBy:'ListItemAllFields.Development_x0020_Stage'">
<td>{{customer.ListItemAllFields.ID}}</td>
<td class="{{customer.ListItemAllFields.FieldValuesAsText.File_x005f_x0020_x005f_Type}}"></td>
<td><a href="{{customer.ServerRelativeUrl}}">{{customer.Name}}</a></td>
<td>{{customer.ListItemAllFields.Development_x0020_Stage}}</td>
<td>{{customer.ListItemAllFields.FieldValuesAsText.Date_x005f_x0020_x005f_for_x005f_x0020_x005f_Review}} </td>
<td>{{customer.ListItemAllFields.Type_x0020_of_x0020_Letter}}</td>
<td>{{customer.ListItemAllFields.FieldValuesAsText.Author}} </td>
</tr>
</table>
</div>
</div>
答案 0 :(得分:0)
我相信您想要并行ajax调用并结合所有结果?
var myAngApp = angular.module('SharePointAngApp', []);
myAngApp.controller('spCustomerController', function ($scope, $http) {
$q.all({
liquidityRiskManagement: $http({
method: 'GET',
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/getfolderbyserverrelativeurl('AD%20Letters/Liquidity%20Risk%20Management')/files?$expand=ListItemAllFields/FieldValuesAsText"
}),
anotherList: $http({
method: 'GET',
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/getfolderbyserverrelativeurl('AD%20Letters/Another%20List%')/files?$expand=ListItemAllFields/FieldValuesAsText"
})
}).then(function(results) {
var riskResult = results.liquidityRiskManagement.data;
var anotherResult = results.anotherList.data;
// You can combine/format data here
});
});
编辑:关于并行ajax调用的一个很好的答案:https://stackoverflow.com/a/24871403/6479268
答案 1 :(得分:0)
我想到了如何为那些可能受益的人做到这一点。我使用了可用的SharePoint GetUrlKeyValue
并抓取了RootFolder
,它可用作每个文档集的查询字符串(var listFolder = GetUrlKeyValue("RootFolder");
)
var listFolder = GetUrlKeyValue("RootFolder");
var url = "/_api/web/getfolderbyserverrelativeurl('"+listFolder+"')/files?$expand=ListItemAllFields/FieldValuesAsText"
现在,我在Docset主页上获取每个docset文件夹的文档/文件。