{"id":1814,"date":"2017-06-21T17:15:03","date_gmt":"2017-06-21T15:15:03","guid":{"rendered":"https:\/\/blog.kodono.info\/wordpress\/?p=1814"},"modified":"2017-06-21T17:15:03","modified_gmt":"2017-06-21T15:15:03","slug":"adding-a-custom-action-to-a-callout-in-sharepoint-2013","status":"publish","type":"post","link":"https:\/\/blog.kodono.info\/wordpress\/2017\/06\/21\/adding-a-custom-action-to-a-callout-in-sharepoint-2013\/","title":{"rendered":"Adding a custom action to a callout in SharePoint 2013"},"content":{"rendered":"<p>This <a href=\"https:\/\/www.eliostruyf.com\/adding-a-custom-action-to-a-callout-in-sharepoint-2013\/\">article<\/a> has been VERY useful. But I wanted something lightly different: I wanted to add a custom action, but also have the &#8220;EDIT&#8221; button (but not the &#8220;SHARE&#8221;), and to use the current item info for my custom action.<\/p>\n<p>Here is the result:<\/p>\n<pre class=\"brush:javascript\">\r\n\/\/ source: https:\/\/www.eliostruyf.com\/adding-a-custom-action-to-a-callout-in-sharepoint-2013\/\r\n\/\/ add a special callout action for our library\r\nSP.SOD.executeFunc(\"callout.js\", \"Callout\", function () {\r\n  var itemCtx = {};\r\n  itemCtx.Templates = {};\r\n  itemCtx.BaseViewID = 'Callout';\r\n  \/\/ Define the list template type\r\n  itemCtx.ListTemplateType = 101;\r\n  itemCtx.Templates.Footer = function (itemCtx) {\r\n    \/\/ context, custom action function, show the ECB menu (boolean)\r\n    return CalloutRenderFooterTemplate(itemCtx, AddCustomAction, true);\r\n  };\r\n  SPClientTemplates.TemplateManager.RegisterTemplateOverrides(itemCtx);\r\n});\r\n\r\nfunction AddCustomAction (renderCtx, calloutActionMenu) {\r\n  var itemIndex = renderCtx.CurrentItemIdx\r\n  \/\/ Add your custom action\r\n  calloutActionMenu.addAction(new CalloutAction ({\r\n    text: \"Custom Action\",\r\n    tooltip: 'This is your custom action',\r\n    onClickCallback: function() {\r\n      \/\/ all the data related to your item are into `renderCtx.ListData.Row[itemIndex]`\r\n      console.log('Callback from custom action');\r\n    }\r\n  }));\r\n  \/\/ re-add EDIT action\r\n  calloutActionMenu.addAction(new CalloutAction ({\r\n    text: \"Edit\",\r\n    onClickCallback: function(event) {\r\n      \/\/ use the default action we have when clicking on the filename into the library\r\n      \/\/ or call the EditForm if it's a list item and not a library\r\n      DispEx(this, event,'TRUE','FALSE','FALSE','SharePoint.OpenDocuments.3','1','SharePoint.OpenDocuments','','1https:\/\/your.sharepoint.com\/_layouts\/15\/WopiFrame.aspx?sourcedoc='+renderCtx.ListData.Row[itemIndex].FileRef+'&#038;action=default','','1','0','0','0x7fffffffffffffff')\r\n    }\r\n  }));\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This article has been VERY useful. But I wanted something lightly different: I wanted to add a custom action, but also have the &#8220;EDIT&#8221; button (but not the &#8220;SHARE&#8221;), and to use the current item info for my custom action. Here is the result: \/\/ source: https:\/\/www.eliostruyf.com\/adding-a-custom-action-to-a-callout-in-sharepoint-2013\/ \/\/ add a special callout action for our [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","hide_page_title":"","footnotes":""},"categories":[170,13,33],"tags":[153,123,24,152,158,117],"class_list":["post-1814","post","type-post","status-publish","format-standard","hentry","category-english","category-niveau-intermediaire","category-programmation","tag-astuce","tag-english","tag-javascript","tag-niveau-intermediaire","tag-programmation","tag-sharepoint"],"_links":{"self":[{"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/posts\/1814","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/comments?post=1814"}],"version-history":[{"count":1,"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/posts\/1814\/revisions"}],"predecessor-version":[{"id":1815,"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/posts\/1814\/revisions\/1815"}],"wp:attachment":[{"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/media?parent=1814"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/categories?post=1814"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/tags?post=1814"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}