All about the SharePoint ribbon

Post on 14-May-2015

3,782 views 2 download

Tags:

description

Developers guide for customizing the SharePoint 2010 server ribbon. Code sample is embeded in the power point, so download to get it!

transcript

All about the SharePoint

RibbonShai Petel

MCT, VP R&Dshai@kwizcom.com

WARNING!

There will be extensive visual studio use throughout this presentation!

Topics

• Introducing the Ribbon• SPRibbon Architecture• Customizing the SPRibbon

Introducing the Ribbon

• Office ribbon: File menu and quick access toolbar:

• SharePoint ribbon: Site Actions menu, Navigate Up and Edit page quick access buttons

Introducing the RibbonCommon tabs

• The “Browse” tab

• The “Page” tab

Introducing the RibbonCommon tabs

• The “Items” tab

• The “List” tab

Introducing the RibbonCommon tabs

• “On demand” functionality with contextual tabs

Introducing the RibbonCommon tabs

• Context-sensitive operations with controls status

Topics

• Introducing the Ribbon• SPRibbon Architecture• Customizing the SPRibbon

SPRibbon ArchitectureObjects Hierarchy

Ribbon

Tabs

Tab *

Contextual Tabs

Contextual Group

*

Tab *

SPRibbon ArchitectureObjects Hierarchy

Tab Groups Group * Controls

Control*

SPRibbon ArchitectureObjects Hierarchy

Objects are defined in XML or in JSON.

Example:TEMPLATE\GLOBAL\XML\CMDUI.XML

(Humans prefer XML…)

SPRibbon ArchitectureRibbon Communication

PageManager

CommandDispatcher

PageComponent

•One per page•Registers all PageComponent objects

•Handles PageComponent objects and the commands they can handle

•When a command is received, the CommandDispatcher recieves it and passes it to all PageComponent objects that can handle it.

•ECMAScript Object•Handle commands passed by the CommandDispatcher

•Use ECMAScript to register an instance of your PageComponent with the PageManager. Only then it can respond to commands defined in the ribbon XML

• (* Can be declared inline with the ribbon controls XML)

Topics

• Introducing the Ribbon• SPRibbon Architecture• Customizing the SPRibbon

Customizing the SPRibbonGeneral info

• Declaring controls• Handling commands• Associating your ribbon tabs

Customizing the SPRibbonGeneral info

• Declaring controls– Declare Ribbon controls in feature XML– Injext XML to SPRibbon using

ribbon.RegisterDataExtension• Handling commands• Associating your ribbon tabs

Customizing the SPRibbonGeneral info

• Declaring controls• Handling commands

– Declare command handlers inline in the XML– Register a PageComponent to handle more

complex commands (such as lazy load)• Associating your ribbon tabs

Customizing the SPRibbonGeneral info

• Declaring controls• Handling commands• Associating your ribbon tabs

– Associate with a list template or content type– Use code to bring un-associated tabs to view– Associate web part with contextual group tabs

CUSTOMIZING THE SPRIBBON

Code + demo(See demo script in README.txt inside VS project)

MyServerRibbon 2010-07-13.zip

Nice to know…

• Use JS objects to avoid conflicts• The ribbon shows informative formatting

errors 9 times out of 10

Nice to know…

• Some controls cannot be large / medium / small. Checkbox cannot be large.

• If you inject to existing node (_children) you can only inject one child at a time. Create CommandUIDefinition for each injection.

• Documentation error: group template and template alias are not optional!

Nice to know…

• SPRibbon in not accessible from sandboxed code!

• Dispatch command manually: SP.Ribbon.PageManager.get_instance().get_commandDispatcher().executeCommand(Commands.CommandIds.ApplicationStateChanged, null);

Topics

• Introducing the Ribbon• SPRibbon Architecture• Customizing the SPRibbon

See also

• Server Ribbon visual studio extensibility project: http://code.msdn.microsoft.com/vsixforsp

• PageComponent more info:http://msdn.microsoft.com/en-us/library/bb383792.aspx

• Shai's Blog:http://kwizcom.blogspot.com

• Chris O'Brien ribbon blog (Beta!) can be found here: http://www.sharepointnutsandbolts.com/2010/01/customizing- ribbon-part-1-creating-tabs.html

• MSDN How-To Webpart with contextual ribbon: http://msdn.microsoft.com/en-us/library/ff407578.aspx

Questions?

=2B |! 2B ? FullTrust:Sandbox;