Friday, July 09, 2010

Default Values on Ribbons CommandAction SharePoint 2010

When you are configuring the Ribbons for SharePoint 2010, you will need to customize your Elements.XML file, there you can create new Ribbon options, you also need to associate some actions to this new options, normally this command can be use to call Client OM JavaScript or to redirect to pages, but when you redirect you can also add some Default parameters will help you work on the server side code, and make the changes you need.


Example:
< command="CustomCommand" commandaction="javascript:RediectPage('{SiteUrl}/_layouts/CustomPage.aspx?List={ListId}&ID={SelectedItemId}');">
Here the msdn Article "http://msdn.microsoft.com/en-us/library/ff458385.aspx"
CommandAction- A script statement to execute when this handler is invoked. SharePoint Foundation calls the eval method, passing in the value of this attribute.
The value of the attribute can contain substitution tokens that will be transformed at rendering. The following tokens are recognized:
  • {ItemId} – ID (GUID) taken from the list view.
  • {ItemUrl} – Web-relative URL of the list item (Url).
  • {RecurrenceId} – ID of a recurrent item (RecurrenceID).
  • {SiteUrl} – The fully qualified URL to the site (Url).
  • {ListId} – ID (GUID) of the list (ID).
  • {ListUrlDir} – Server-relative URL of the site plus the list's folder.
  • {Source} – Fully qualified request URL.
  • {SelectedListId} – ID (GUID) of the list that is currently selected from a list view.
  • {SelectedItemId} – ID of the item that is currently selected from the list view.
For a SharePoint App that manage your ribbons can recomend the following link
SharePoint App Processlynx Custom Action and Ribbon Manager Launch
for the demo version in Office Store you can access the following link:
Processlynx Custom Action And Ribbon Manager Demo

Project Example:
Link CustomAction Project

Excellent articles about the Ribbons:
Customizing and Extending the SharePoint 2010 Server Ribbon
http://msdn.microsoft.com/en-us/library/gg552606.aspx
Work with the SharePoint 2010 Ribbon User Interface
http://msdn.microsoft.com/en-us/library/ff630938.aspx
How to: Modify the User Interface Using Custom Actions
http://msdn.microsoft.com/en-us/library/ms473643.aspx
How to: Add Actions to the User Interface
http://msdn.microsoft.com/en-us/library/ms473643%28v=office.12%29.aspx
Custom Action Definition Schema
http://msdn.microsoft.com/en-us/library/ms465980.aspx
Module 10: Creating Dialogs and Ribbon Controls for SharePoint 2010
http://msdn.microsoft.com/en-us/sharepoint/ee513157
Adding a Custom Action to a SharePoint 2010 Display Form for List Items
http://msdn.microsoft.com/en-us/library/hh500259.aspx
Programmatically add ribbon custom action to an existing list
http://sp365.co.uk/2011/09/programmatically-add-ribbon-custom-action-to-an-existing-list/
SharePoint Ribbon Visual Studio 2010 Template
http://archive.msdn.microsoft.com/vsixforsp/Release/ProjectReleases.aspx?ReleaseId=4177
SharePoint 2010 Site Actions Menu
http://www.codeproject.com/KB/sharepoint/SiteAction.aspx
Replacing a Button on the Server Ribbon for a Site Collection 
http://msdn.microsoft.com/en-us/library/ff407221.aspx
Developing Page Components for the Server Ribbon
http://msdn.microsoft.com/en-us/library/ff407303.aspx 
Creating a Custom Web Part with a Contextual Tab
http://msdn.microsoft.com/en-us/library/ff407578.aspx 
If you need to define the Custom actions locations you can use the following ID
Default Custom Action Locations and IDs 
http://msdn.microsoft.com/en-us/library/bb802730.aspx

How to hide Ribbons Controls:
Ribbons controls can be hide using code and associating the Controls ID of the Ribbons by code.

All the Ribbons Control ID reference are in the path:
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\GLOBAL\xml\CMDUI.XML"
example:
SPRibbon ribbon = SPRibbon.GetCurrent(this.Page);
ribbon.TrimById("Ribbon.Documents.New.NewDocument");

List of control ID for the Ribbons
http://msdn.microsoft.com/en-us/library/ee537543%28v=office.14%29.aspx

or you can use XML to configure the Button
Removing a Button from the Server Ribbon
http://msdn.microsoft.com/en-us/library/ff408060.aspx

<-- Updated 12 December 2011 -->

Post a Comment