[英]Sharepoint 2013 document set homepage get documents with Rest API
Document Set Homepage: 文件集首页:
I am using Angularjs and REST API to retrieve the documents on my SharePoint 2013 document set homepage for additional functionaity. 我正在使用Angularjs和REST API来检索SharePoint 2013文档集主页上的文档,以实现其他功能。 The below code works if I provide the list and folder name ('AD%20Letters/Liquidity%20Risk%20Management'), but I have more then one document set folder and need to get the List and folder names dynamically ('"+ListName/FolderName+"') for each document set folder so it displays on the Document Set Home with the documents and other metadata. 如果我提供列表和文件夹名称('AD%20Letters / Liquidity%20Risk%20Management'),则下面的代码有效,但是我有一个以上的文档集文件夹,需要动态获取列表和文件夹名称('“ + ListName / FolderName +“'),以便每个文档集文件夹与文档和其他元数据一起显示在文档集主目录中。 Attaching a screenshot of how the Document set homepage appears with the below code but only for the Liquidity Risk Management folder that I provide the names for. 随附屏幕截图,显示带有以下代码的“文档集”主页的显示方式,但仅适用于我为其提供名称的“流动性风险管理”文件夹。 Any suggestions. 有什么建议么。
<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>
I believe you'd like to make parallel ajax calls and combine all the results? 我相信您想进行并行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
});
});
EDIT: a good answer on parallel ajax calls: https://stackoverflow.com/a/24871403/6479268 编辑:关于并行Ajax调用的好答案: https : //stackoverflow.com/a/24871403/6479268
I figured how to do this for those who might benefit. 我想出了如何为可能受益的人做到这一点。 I used the available SharePoint GetUrlKeyValue
and grabbed the RootFolder
which is available as a querystring for each document set ( var listFolder = GetUrlKeyValue("RootFolder");
) 我使用了可用的SharePoint GetUrlKeyValue
并获取了GetUrlKeyValue
,该RootFolder
可用作每个文档集的查询字符串( var listFolder = GetUrlKeyValue("RootFolder");
)
var listFolder = GetUrlKeyValue("RootFolder");
var url = "/_api/web/getfolderbyserverrelativeurl('"+listFolder+"')/files?$expand=ListItemAllFields/FieldValuesAsText"
Now I get documents/files for each docset folder on the Docset Homepage. 现在,我在Docset主页上获得了每个docset文件夹的文档/文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.