0

I have a list with 3 custom content types. The customer has requested that instead of browsing to the ribbon to enter New Form for these content types, additional New Item buttons should be available on the list view.

Only idea which comes to my mind would be to add JSLink and craft those buttons from HTML. Any better suggestions?

0

EDIT: Sorry, I missed the part that the customer doesn't want to navigate to the Ribbon. Yes, in that case the best thing would be HTML+JS.

A better way would be to have a custom action with code behind which would create buttons dynamically based on available content types in that list.

Basically, you start with a custom action:

<CustomAction 
  Id="DMS.Lists.HideButtonCustomAction" 
  Location="CommandUI.Ribbon" 
  RegistrationType="List"
  RegistrationId="1005590"
  ControlAssembly="$SharePoint.Project.AssemblyFullName$"
  ControlClass="DMS.Lists.CustomNewButtons"> 
</CustomAction>

(Change RegistrationId to your list template id and ControllClass to your custom class).

Add a class which inherits a "Control" class. Then you handle the OnLoad event of the custom action:

protected override void OnLoad(EventArgs e)
{
    base.OnLoad(e);
    this.Visible = false;

    SPRibbon ribbon = SPRibbon.GetCurrent(this.Page);
    AddNewButtons(ribbon);
}

Your AddNewButtons should check the content types used in that list and generate Ribbon buttons programmatically. Take a look at this article - http://www.sharepointnutsandbolts.com/2010/01/customizing-ribbon-part-1-creating-tabs.html for more information.

This guys here: http://www.projectserver2010blog.com/2010/01/sharepoint-2010-ribbon-customization.html has a decent article as well as an example code.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.