How to re-use SharePoint standard buttons in your definitions |
SharePoint has great amount of standard buttons. And Fluent Ribbon API allows you to copy their appearance (but not functionality). This article describes, how it could be done.
Occasionaly you would like to replace the existing ribbon button with your own custom one, to change it's behavour. In this situation, RibbonCustomAction in conjuction with StandardButtonsLibrary class will definitely save your day.
For instance, consider you want to create a replacement for the standard "View properties" button on a list view page. The corresponding code will look like this:
var myViewPropertiesButton = ControlLibrary.StandardButtons.ListItem.Manage_ViewProperties("alert('My custom View properties button');"); var customAction = new RibbonCustomAction(); customAction.ReplaceControl(myViewPropertiesButton, SPRibbonIds.ListItem.Groups.Manage.ControlIds.ViewProperties, 40); customAction.Provision(properties.Feature.DefinitionId, );
Note |
---|
StandardButtonsLibrary functionality doesn't provide any javascript action for the buttons. By default, all these buttons will be dummy (do nothing). |
If you're working in localized SharePoint environment, you should provide additional parameter to the method, which returns the standard button definition.
For example, if you have German portal installed, you should use following code:
var myViewPropertiesButton = ControlLibrary.StandardButtons.ListItem.Manage_ViewProperties("alert('My custom View properties button');", 1031);