简体   繁体   English

Sharepoint 2013文档集主页使用Rest API获取文档

[英]Sharepoint 2013 document set homepage get documents with Rest API

Document Set Homepage: 文件集首页:

1

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.

相关问题 如何使用 Sharepoint 列表 2013 中的 REST API 调用按特定日期过滤器检索数据。 - How to retrieve data with filter by Particular date using REST API call in Sharepoint list 2013.? 针对TFS2013的REST API调用 - REST API call for TFS2013 Angular JS + SharePoint List + Rest API - Angular JS + SharePoint List + Rest API Angularjs Sharepoint Rest API显示所有列 - Angularjs Sharepoint Rest API to showing all columns 大型mongo文档的REST API设计 - REST API design for a large mongo document “无法获取未定义或空引用的属性&#39;替换&#39;” AngularJS Sharepoint 2013 IE9 Sharepoint Web部件分组 - “Unable to get property 'replace' of undefined or null reference” AngularJS Sharepoint 2013 IE9 Sharepoint web part grouped Angular Js + Rest API +共享点列表-验证和编辑不起作用 - Angular Js + Rest API + Sharepoint List - Validation and Edit not working Angular JS + Rest API + SharePoint列表-双向绑定不起作用 - Angular JS + Rest API + SharePoint List - two way binding is not working 如何使用Sharepoint Rest API过滤多行文本字段? - How to filter multiple line of text field using Sharepoint Rest API? SharePoint加载项[Office 365中的SharePoint托管应用程序] Rest api调用跨源资源共享错误? - SharePoint add-in [SharePoint hosted app in Office 365] Rest api call Cross Origin Resource Sharing error?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM