2016-04-08 15 views
0

SharePoint Online 2013サイトでは、さまざまな部門のレポートが表示されます。すべての部門には異なるグループがあり、そのグループには他のグループファイルが表示されないように許可が割り当てられています。私はJAVA SCRIPTとAJAXを使ってギャラリーからファイルを取得しています。自分のページでJavaScriptを使用すると、クライアントアプリケーションでドキュメントを開くことができず、ユーザーがダウンロードするよりもオンラインでオフィスで開くことができます。とにかくユーザーはそれをクリックしてファイルをダウンロードします。私は図書館の設定に行き、既定値を変更してクライアントアプリケーションでも開いて、サイトコレクションや機能を変更しましたが、依然としてSharePointはクライアントアプリケーションではなくオンラインでファイルを開きます。私たちは、私がこれをテストするために手に環境を持っていませんでした2013年SharePointオンライン2013からOfficeクライアントでMicrosoft Officeファイルを開くことができません

(function() { 


    // Create object that have the context information about the field that we want to change it's output render 
    var galleryContext = {}; 
    galleryContext.Templates = {}; 


    galleryContext.Templates.Header = "<div class='gallery'>"; 
    galleryContext.Templates.Footer = "</div><div class='gallerydocs'></div>"; 


    // This line of code tell TemplateManager that we want to change all HTML for item row render 
    galleryContext.Templates.Item = galleryTemplate; 

    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(galleryContext); 

})(); 

// This function provides the rendering logic 
function galleryTemplate(ctx) { 
    var icon = ctx.CurrentItem["GalleryIcon"]; 
    var src = ctx.CurrentItem["FileRef"]; 
    var name = ctx.CurrentItem["Title"]; 
    var subtitle =ctx.CurrentItem["SubTitle"]; 
    var bgcolor = ctx.CurrentItem["BackgroundColor"]; 
    var fontcolor = ctx.CurrentItem["FontColor"]; 

    //var description = ctx.CurrentItem["Description"]; 
// console.log(JSON.stringify(ctx.CurrentItem["GalleryIcon"])); 
    // Return whole item html 
    return "<div onclick='javascript:getGalleryDocs("+'"'+ src + '"' +", "+'"'+ bgcolor + '"' +", "+'"'+ subtitle + '"' +", "+'"'+ fontcolor + '"' +", "+'"'+ name + '"' +")'><div class='galleryblock' style='background-color:" + bgcolor + ";color:"+ fontcolor+"' >"+name +"<br/><br/><p>"+subtitle +"</p></div></div>"; 
} 


function getGalleryDocs(folder , bgcolor, subtitle ,fontcolor , name) 
{ 

$.ajax({ 
     url: _spPageContextInfo.siteAbsoluteUrl + "/_api/web/GetFolderByServerRelativeUrl('"+folder+"')/files?$orderby=Title", 
     method: "GET", 
     headers: { "Accept": "application/json; odata=verbose" }, 
     success: function (data) { 
     var html="<div class='gallerynav'><span><a href='javascript:goback();'>BILLING REPORTS</a><span> <i class='fa fa-caret-right' ></i><span>"+name+"</span></div><div class='galleryblock' style='float:none;background-color:" + bgcolor + ";color:"+ fontcolor+"' >"+name +"<br/><br/><p>"+subtitle +"</p></div><span></span>"; 
     var results = data.d.results; 
     //console.log(JSON.stringify(results.length)); 
     html+= "<ul class='gallerylinks'>"; 
     if(results.length > 0) 
     { 
      for(i=0 ; i< results.length ; i++) 
      { 
       var item = results[i]; 
       html+= "<li><a href='" + item.LinkingUrl + "' target='_blank'>"+item.Title+"&nbsp;&nbsp;<i class='fa fa-external-link'></i></a></li>"; 
      } 
     } 
     else 
     { 
      html+="&nbsp;&nbsp;&nbsp;THERE ARE NO DOCUMENTS IN THIS GALLERY" 
     } 
     html+="<ul>" 
     //console.log(JSON.stringify(data)); 
     $(".gallery").hide(500); 
     $(".gallerydocs").html(html); 

     }, 
     error: function (data) { 
      $(".gallerydocs").html("You dont have permissions to view this folder!") 
     } 
     }); 
} 
function goback(){ 
$(".gallery").show(500); 
     $(".gallerydocs").html(""); 
} 

答えて

0

オンラインオフィス2010とSharePointを使用しているが、あなたのhrefのリンクとは何かになります。それは別々に構築する必要があります。以下の解決策がクライアントアプリケーションで開かれることを願っています。

完全なポストをhere

THisポストは

申し訳ありませんが、私がテストすることはできません直接ダウンロードするためのソリューションを提供しています見つけることができます

<a href="" 
    onclick="editDocumentWithProgID2('http://server/site/doclib/folder/Document.docx', 
    '', 
    'SharePoint.OpenDocuments', '0', 
    'http://server/site', '0')"> 
    This will open the file in edit mode 
</a> 

を試してみてください

幸運

乾杯 Truez

+0

私はそれらを読み取り専用または独自のデスクトップでダウンロードして、SharePointに保存されているマスターファイルに影響を与えない変更を加えることができます。 – James

+0

ファイルのダウンロード方法については、2番目のリンクを確認してください。もう一度HTMLを少し微調整します。 – Truezplaya

関連する問題