Wednesday, 8 November 2017

Document Preview using restapi


1)Need to put this link in page

<iframe id="GBTpreviewframe" width="100%" height="800px"></iframe>


//getting document url from document library//

function geturl()
{
$.ajax({
        url: siteurl + "/_api/web/lists/getbytitle('" + Listname+ "')/items?$select=EncodedAbsUrl&$expand=File",
        method: "GET",
        headers: { "Accept": "application/json; odata=verbose" },
        success: function (data) {
           success(data.d.results);   
        },
        error: function (data) {
        debugger;
            failure(data);           
        }       
    });

}
function GBTgetListItemsForApproverssuccess(arrayname)
{
htmltable+= '<a onclick=GBTDocumentpreview("'+arrayname.EncodedAbsUrl+'")></a>;

}
function GBTDocumentpreview(url)
{
document.getElementById("GBTpreviewframe").setAttribute("src", url);
}

No comments:

Post a Comment

How to get the value from web.config(if any value assign as static Key)

Web.Config File:   <appSettings>     <add key="DomainName" value="PW" />     </appSettings> Cl...