有没有办法在给定节点下的Quick Launch中添加NavigationNode而不是仅使用Sharepoint Rest API作为子节点?

问题描述 投票:0回答:1

有没有办法使用SharePoint Rest API在给定节点(而不是孩子)下的快速启动中添加导航节点

sharepoint sharepoint-online
1个回答
0
投票

示例代码供您参考:

<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.js"></script>

    <script type="text/javascript">  
            $(document).ready(function ($) {  

                $("#createQuickLaunch").click(function () { createQuickLaunch() });  

            });  
            //Create a Quicklaunch Navigation  
            function createQuickLaunch() {  
                var endPointUrl = _spPageContextInfo.webAbsoluteUrl + "/_api/web/navigation/QuickLaunch";  
                var headers = {  
                    "accept": "application/json;odata=verbose",  
                    "content-Type": "application/json;odata=verbose",  
                    "X-RequestDigest": jQuery("#__REQUESTDIGEST").val()  
                }  
                var call = jQuery.ajax({  
                    url: endPointUrl,  
                    type: "POST",  
                    data: JSON.stringify({  
                        "__metadata": { type: "SP.NavigationNode" },  
                        'IsExternal': true,  
                        'Title': "Bing",  
                        'Url': "http://www.bing.com"  
                    }),  
                    headers: headers  
                });  
                call.done(successHandler);  
                call.fail(failureHandler);  
            }  
            function successHandler(data, textStatus, jqXHR) {  
                SP.UI.Notify.addNotification("Navigation created Successully", false);  
            }  
            function failureHandler(errorMessage) {  
                alert("Request Failed: unable to Navigation: " + JSON.stringify(errorMessage));  
            }  
        </script>  

        <input type="button" title="createQuickLaunch" value="createQuickLaunch" id="createQuickLaunch"/>

enter image description here

参考:

Add Quick Launch Link To SharePoint 2013 Site Using REST API

© www.soinside.com 2019 - 2024. All rights reserved.