1 / 10

LH SharePoint SIG - Custom Actions

LH SharePoint SIG - Custom Actions. Custom Actions. A custom action represents a Server ribbon, menu, or link customization that a user can see. Custom actions can be bound to list type, content type, file type, or programmatic identifier (ProgID). Possible scopes: Farm: Yes

hiroko-boyd
Télécharger la présentation

LH SharePoint SIG - Custom Actions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. LH SharePoint SIG - Custom Actions

  2. Custom Actions A custom action represents a Server ribbon, menu, or link customization that a user can see. Custom actions can be bound to list type, content type, file type, or programmatic identifier (ProgID). Possible scopes: • Farm: Yes • Web Application: Yes • Site Collection: Yes • Web Site: Yes We will create a custom action associated with the ribbon for a particular content type at Site scope

  3. Getting Started • Our action will allow us to copy Wiki Pages from a Wiki Page Library to another named “Squirrel Wiki Pages” • Create new Visual Studio 2010 Empty SharePoint project • Add New Item – Empty Element – Squirrel Action • Rename Feature to Squirrel Action • Add CustomAction element to elements.xml • Add Layouts folder for image and add image • Deploy and Test This is a dumb Custom Action since it does not do anything. Lets put some meat on the bone…

  4. CustomAction Element • How did I determine RegistrationType and RegistrationId? • Go To Site Settings/ Site Content Types • Hover over “Wiki Page” and look at ctype param in the status bar • How did I determine Locations? • Default Custom Action Locations and IDs • 14 Hive/TEMPLATE/GLOBAL/XML/CMDUI.XML • How did I determine TemplateAlias? • 14 Hive/TEMPLATE/GLOBAL/XML/CMDUI.XML

  5. Smart Custom Action We will now implement some functionality by specifying some ECMAScript (javascript) in place of the “Hello Word” stuff that will utilize the SharePoint Foundation 2010 Managed Client Object Model The Client Object Model is a set of javascript namespaces and classes that closely mirror the .NET SharePoint Foundation classes and can be used client-side to interact with the SharePoint Object Model. This is done by packaging up a series of “commands” and sending them to the server. The communication is asynchronous and you must specify a completion routine to capture the “results”. The tricky part is knowing when to make the asynchronous calls.

  6. Smarter Custom Action Specifying all of the javascript inline is cumbersome and frankly unappealing We can specify a javascript file and get it on the page by a “ScriptLink” custom action One benefit is that it can be modified without reinstalling the feature. Another is that we can get intellisense for the Client Object Model in Visual Studio. Where would we be with intellisense and Google! Intellisense provided by lines /// <reference path="/_layouts/MicrosoftAjax.js"/> /// <reference path="/_layouts/SP.debug.js"/> At top of squirrel.js A third benefit is that we can debug the script

  7. Smarter Action Steps • Add Layouts folder and javascript file to folder • Replace CustomAction element • Add ScriptSrc Custom Action

  8. Action Handling by Delegate • The following technique allows handling the command “Server Side” • We will create a class inherited from WebControl and use it to handle the command • The control will be added to the AdditionalPageHead Delegate control • The CommandUIHandler will execute a postback that the control will handle • Replace the Custom Action element • Add the SquirrelControl class • Add reference to Microsoft.SharePoint, System.Web and System.WebExtensions • Add a Safe Controls entry

  9. Useful References Customizing and Extending the SharePoint 2010 Server Ribbon Server Ribbon XML Using the SharePoint Foundation 2010 Managed Client Object Model SPListTemplateType Enumeration

More Related