Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a view item form which contains a custom WebPart for displaying that item. I have no issue with that but the ribbon for the display form looks weird: It contains lots of options that don't apply for the item.

Here is what I mean:

View tab:

enter image description here

Page tab:

enter image description here

I am doing no customization at all to the ribbon; it just appears like that.

What might trigger this?

share|improve this question
    
I guess that just comes from the base your webpart is build on. Kind of out-of-the-box features with this type of webpart. Did you build this custom WebPart by using a blank one and adding functionality? Did you try different ootb webParts? Did they look different? –  Shegit Brahm Feb 10 '12 at 15:07
    
@Shegit Brahm : I see where you are going... I'm extending a DataFormWebPart; If I use a classic ListFormWebPart for example (can't extend that as it's sealed) I get a normal ribbon. I guess ListFormWebPart is doing something to the ribbon. Will have to check that out... –  JohnDoDo Feb 10 '12 at 15:37
add comment

1 Answer

up vote 1 down vote accepted

Managed to remove the buttons from the WebPart. I've stuck this in the WebPart:

protected override void OnInit(EventArgs e)
        {
            Ribbon currentRibbon = SPRibbon.GetCurrent(this.Page);
            foreach (string rid in litsOfRibbonIdsToExclude)
            {
                currentRibbon.TrimById(rid);
            }
}

with litsOfRibbonIdsToExclude an array with "Ribbon.ListForm.Display.Manage.ApproveReject", "Ribbon.ListForm.Display.Manage.CheckIn", "Ribbon.ListForm.Display.Manage.CheckOut", ......

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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