Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Download button on context menu for SharePoint lib

$
0
0

Hi Team,

I need to add download button directly on context menu, please help

I tried the following code 

SP.SOD.executeFunc("callout.js", "Callout", function() {
    var itemCtx = {};
    itemCtx.Templates = {};
    itemCtx.BaseViewID = 'Callout';
    //The template type of 101 is a document library
    itemCtx.ListTemplateType = 101;
    itemCtx.Templates.Footer = function(itemCtx) {
        //Override the footer of the hover card with your custom function.
        return CalloutRenderFooterTemplate(itemCtx, AddCustomAction, true);
    };
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(itemCtx);
});

function AddCustomAction(renderCtx, calloutActionMenu) {
    //Action you want to add to the footer

    calloutActionMenu.addAction(new CalloutAction({
        text: "View Properties",
        tooltip: 'View the properties of this document',
        onClickCallback: function() {
            //Determine the source of the list so you can navigate back to it.
            var listSource = _spPageContextInfo.serverRequestPath;
            //Make sure to append the ID to the URL so the item renders properly.
            window.location = renderCtx.displayFormUrl + "&ID=" + renderCtx.CurrentItem.ID + "&Source=" + listSource;
        }
    }))

    calloutActionMenu.addAction(new CalloutAction({
        text: "Edit Properties",
        tooltip: 'Edit the properties of this document',
        onClickCallback: function() {
            //Determine the source of the list so you can navigate back to it.
            var listSource = _spPageContextInfo.serverRequestPath;
            window.location = renderCtx.editFormUrl + "&ID=" + renderCtx.CurrentItem.ID + "&Source=" + listSource;
        }
    }));

    //Display the default document library actions
    CalloutOnPostRenderTemplate(renderCtx, calloutActionMenu);
} 

This works like a charm, but I am unable to figure out the code to download a copy in call back function

calloutActionMenu.addAction(new CalloutAction({
        text: "Download",
        tooltip: 'Download document',
        onClickCallback: function() {
        //what code to call here ???
        }
    }));

Please let me know how to handle this scenario


Thanks in Advance, Jiniv Thakkar


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>