Custom action to a callout in SharePoint 2013


During my POC, I was trying to add custom action to a callout same like, Share and follow.found easy way to do it with following script.

 SP.SOD.executeFunc("callout.js", "Callout", function () {  
  var itemCtx = {};  
  itemCtx.Templates = {};  
  itemCtx.BaseViewID = 'Callout';  
  // Define the list template type  
  itemCtx.ListTemplateType = 101;  
  itemCtx.Templates.Footer = function (itemCtx) {  
    
   return CalloutRenderFooterTemplate(itemCtx, AddCustomAction, true);  
  };  
  SPClientTemplates.TemplateManager.RegisterTemplateOverrides(itemCtx);  
 });  
 function AddCustomAction (renderCtx, calloutActionMenu) {     
  // Add custom action  
  calloutActionMenu.addAction (new CalloutAction ({  
   text: "Custom Action",  
   tooltip: 'This is your custom action',  
   onClickCallback: function() { console.log('Alert from custom action'); }  
  }));  
 }  




We are good to go!!

Comments

  1. Hi Anuja,

    I implemented you code in content editor webpart placed on allitems.aspx of document library. But i observed that, the custom action is not always shown up in callout. When i clear browser cache and revisit the document library page it shows up.

    Also, the code does not work in when compatibility mode of IE 10 is on.

    Please suggest.

    Regards,
    PSK

    ReplyDelete
  2. hi
    thnx for the reply.
    can you tell where will i put this code?
    so that i can get the action in all the document libraries of my site

    ReplyDelete
  3. Excellent!! I want to redirect one url on Custom Click Link. I need to send one dynamic ID with this URL. How I can send this ID in the onClickCallback function as a parameter? Can you please help me out?

    ReplyDelete

Post a Comment

Popular posts from this blog

Search Result Webpart,Filter result If QueryString is present in URL

SharePoint 2013 Workflow gets canceled automatically

Permission denied for "Add and Customize Pages" in Sharepoint Online