views:

25

answers:

1

Hi,

In SharePoint 2010, I have a custom list "Clients" on a site. On the home page of the site, I have added a Clients List Web Part. When I access the home page in a browser and click anywhere in that list, it displays the "List Tool" ribbon group which has "Items" and "List" ribbons. I do NOT want these ribbons at all when clicking on the list. How do I achieve this? Should I disable the click event on the list so these ribbons do NOT appear? How do I disable the click event on the list? Or What should I do to hide these ribbons when clicking on the list?

Basically I want it to behave same as content query web part. In content query web part, if you click anywhere in it, it doesn't show up any extra ribbons. I want the same behavior with list web part.

Thanks Hitesh

A: 

One approach would be to follow the tutorial outlined in this blog post: Remove actions from the ribbon: SharePoint 2010

The end result is a UserControl that you can place on any page and "trim" (i.e. hide) certain portions of the Ribbon: entire tabs, or individual groups or buttons on the ribbon.

If you follow the prescribed solution from the blog, then you would add the following lines in your Page_Load event:

SPRibbon ribbon = SPRibbon.GetCurrent(this.Page);
if (ribbon != null) {
  ribbon.TrimById( SPRibbon.ListTabId );
  ribbon.TrimById( SPRibbon.ListItemTabId );
}

Additional ribbon element IDs can be found at:

Of course, the downside to using this approach is that the particular ribbon elements you hide are hard-coded in the UserControl. To get around this, I used the UserControl as a basis to create a Web Part that allows you to define which ribbon elements to hide via a property. It works great and is generic enough to be applicable to many different scenarios.

CBono