Adaugare Custom actions in ribbon


Pentru element nou adaugat se face un Elements.xml cu

<?xml version="1.0" encoding="utf-8"?>

<Elements xmlns="http://schemas.microsoft.com/sharepoint/"&gt;

<CustomAction Id="Ribbon.TBPR.Nou.RibbonTest"

Location="CommandUI.Ribbon.ListView" –EditForm, NewForm, DisplayForm

RegistrationType="List"

RegistrationId="106" –vezi enum aici

Title="Ribbon Test"

Rights=" ViewListItems" –toate din enum SPBasePermisions ManageLists

RequireSiteAdministrator="True" – numai ptr admini

Sequence="101"> –fara multiplu de 10 sau 100

<CommandUIExtension>

<CommandUIDefinitions>

<CommandUIDefinition Location="Ribbon.Calendar.Events.New.Controls._children">

<Button Id="Ribbon.TBPR.Nou.RibbonTest"

Alt="Buton de test"

Sequence="101" – fara multiplu de 10 sau 100

Command="Test_Button"

LabelText="Buton de test"

Image32by32="/_layouts/Images/RibbonItem/calendar32-add.png" –nu uita nume folder

Image16by16="/_layouts/Images/RibbonItem/calendar16-add.png"

TemplateAlias="o1"/>

</CommandUIDefinition>

</CommandUIDefinitions>

<CommandUIHandlers>

<CommandUIHandler Command="Test_Button" CommandAction="javascript:alert(‘Sunt un test’);" />

</CommandUIHandlers>

</CommandUIExtension>

</CustomAction>

</Elements>

Pentru replace buton la CommandUIDefinition Location="Ribbon.Calendar.Events.New.numebuton” iar la buton fara Sequence

Pentru Hide se foloseste

< HideCustomAction

Id="HideNewMenu"

Location="Microsoft.SharePoint.StandardMenu"

GroupId="NewMenu"

HideActionId="NewMenu" >

< /HideCustomAction >

Din cod

using (SPSite site = new SPSite("http://intranet.contoso.com&quot;))

{

using (SPWeb web = site.RootWeb)

{

SPUserCustomAction action = web.UserCustomActions.Add();

action.Location = "EditControlBlock";

action.RegistrationType = SPUserCustomActionRegistrationType.FileType;

action.RegistrationId = "docx";

action.Title = "Custom Edit Command For Documents";

action.Description = "Custom Edit Command for Documents";

action.Url = "{ListUrlDir}/forms/editform.aspx?Source={Source}";

action.Update();

web.Update();

site.Close();

}

}

Anunțuri

Lasă un răspuns

Completează mai jos detaliile tale sau dă clic pe un icon pentru a te autentifica:

Logo WordPress.com

Comentezi folosind contul tău WordPress.com. Dezautentificare / Schimbă )

Poză Twitter

Comentezi folosind contul tău Twitter. Dezautentificare / Schimbă )

Fotografie Facebook

Comentezi folosind contul tău Facebook. Dezautentificare / Schimbă )

Fotografie Google+

Comentezi folosind contul tău Google+. Dezautentificare / Schimbă )

Conectare la %s