Adding Item to ECB (Edit control Block) menu
Add Item in Ellipsis menu.
Steps
Step1:
Edit List Page and Add Script Editor web part.
Step2:
Add this Script to Script editor web part
<script type="text/javascript">
function Custom_AddDocLibMenuItems(m, ctx)
{
var strDisplayText = "Publish to Market Research"; //Menu Item Text
var strAction = "alert('Hello World')"; //Menu item action
var strImagePath = ""; //Menu item Image path
// Add our new menu item
CAMOpt(m, strDisplayText, strAction, strImagePath);
// add a separator to the menu
CAMSep(m);
// false means that the standard menu items should also be rendered
return false;
}
</script>
Add Item in ECB Menu
Step1:
Edit List Page and Add Script Editor web part.
Step2:
Add this Script to Script editor web part
<script type="text/javascript">
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) {
// context, custom action function, show the ECB menu (boolean)
return CalloutRenderFooterTemplate(itemCtx, AddCustomAction, true);
};
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(itemCtx);
});
function AddCustomAction (renderCtx, calloutActionMenu) {
// Add your custom action
calloutActionMenu.addAction (new CalloutAction ({
text: "Custom Action",
tooltip: 'This is your custom action',
onClickCallback: function() { console.log('Callback from custom action'); }
}));
// Show the default document library actions
CalloutOnPostRenderTemplate(renderCtx, calloutActionMenu);
// Show the follow action
calloutActionMenu.addAction(new CalloutAction({
text: Strings.STS.L_CalloutFollowAction,
tooltip: Strings.STS.L_CalloutFollowAction_Tooltip,
onClickCallback: function (calloutActionClickEvent, calloutAction) {
var callout = GetCalloutFromRenderCtx(renderCtx);
if (!(typeof(callout) === 'undefined' || callout === null))
callout.close();
SP.SOD.executeFunc('followingcommon.js', 'FollowSelectedDocument', function() { FollowSelectedDocument(renderCtx); });
}
}));
}
</script>
Reference Link
http://www.eliostruyf.com/adding-a-custom-action-to-a-callout-in-sharepoint-2013/
Comments
Post a Comment