Home > Customizations, SharePoint > Hide column header in a SharePoint list web part

Hide column header in a SharePoint list web part

December 10th, 2008 Ben Leave a comment Go to comments

I was working on a site today and I added a list web part to the site.  I wanted the information to be displayed in two columns so I created a new view using “Boxed, no labels” as the style for the view.  The only problems was the column headers that end up at the top that really don’t make any sense or line up with anything.

image

To remove these annoying headers I used a simple content editor web part.  Instead of using the rich text editor, open up the Source editor and enter the following three lines:

<style>
.ms-viewheadertr { display: none;}
</style>

Under Layout in the Content Editor Web Part check the “Hidden” check box so you’re web part wont’ be seen on your site and click OK.  The column headers will now be hidden from view.

image

This method can also be used to hide and/or change the look of other aspects of your SharePoint site without using SharePoint Designer or making any custom modifications.  Any change can easily be undone or changed by going into Page Edit mode and changing the source in the web part.

How to do the same thing in SharePoint 2010

Categories: Customizations, SharePoint Tags:
  1. Mike
    December 11th, 2008 at 09:17 | #1

    I think lines 1 and 3 should be replaced with tags.

    1.
    2. .ms-viewheadertr { display: none;}
    3.

  2. Mike
    December 11th, 2008 at 09:18 | #2

    Lines 1 and 3 should be replaced with style tags as opposed to script tags.. My first comment did not show up since I had them in tags.

  3. admin
    December 11th, 2008 at 11:45 | #3

    Thanks for catching my typo, that’s what I get for posting late at night :)

  4. Anita
    December 28th, 2008 at 18:01 | #4

    Any way to do the same for the a list accessed remotely.

    I was going to use Remote List Viewer but it uses a different property (http://www.kwizcom.com/ProductPage.asp?ProductID=595&ProductSubNodeID=596).

    The content query web part has a bug in moss that I can’t get around, where items are all displayed as “(blank)”. Drove me nuts for days and gave up.

    Anyone have solution to showing a list on a subsite and hiding column headings like above ?

  5. Shawn
    December 31st, 2008 at 11:53 | #5

    Thanks! This is exactly what I was looking for.

  6. January 1st, 2009 at 12:01 | #6

    Nice Blog! Thanks for the information

  7. Carmen
    January 9th, 2009 at 08:26 | #7

    THANK YOU!!!! It is exactly what I needed too!!!!

  8. hazarder
    January 27th, 2009 at 03:02 | #8

    I usually don’t comment other people’s blogs but this is really a great workaround.

    Thx!

  9. Suzanne
    January 27th, 2009 at 08:24 | #9

    Awesome, thanks! I love easy solutions :)

  10. Catherine
    February 6th, 2009 at 11:13 | #10

    THANK YOU!!!!!

  11. Kim
    February 6th, 2009 at 14:09 | #11

    Does this work in Sharepoint 2003? I need to remove those annoying headers, but can’t get this to work, any idea what I am doing wrong? TIA

  12. admin
    February 6th, 2009 at 14:59 | #12

    I’m honestly not sure. They may have changed the class name for the headers, you can find the class name using the IE developer toolbar. I know the method works in 2003 as it has been used to remove the quick launch. I started working with SharePoint in beta 1 of 2007, so I don’t have a ton of 2003 experience. I’ll see what I can find, or if anyone else has tried this with 2003, feel free to post your comments.

  13. Kim
    February 6th, 2009 at 15:40 | #13

    @Kim
    The class is .ms-vh2 in 2003 and it worked great! Thanks so much for the reply.

  14. Eric
    February 26th, 2009 at 11:09 | #14

    Great idea.

    Question, how do I do this selectively for only chosen webparts, while allowing other webparts to display the column headers.

  15. March 3rd, 2009 at 22:25 | #15

    Awesome – thanks for sharing!

  16. Holger
    March 4th, 2009 at 02:15 | #16

    Great blog!

    Is there any possibility to apply the hiding of column headers to a specific Web Part on the selected page instead of hiding all column labels of all lists on that page?

    Cheers,
    Holger

  17. Anonymous
    March 10th, 2009 at 13:48 | #17

    Thanks for this!

  18. admin
    March 10th, 2009 at 14:06 | #18

    Eric and Holger,
    I’ve been trying to think of a way to apply this to just one web part on a page. Using the method I mentioned in the post, I can’t think of a way to apply it to single web part. You may have to use some other method. I will continue to research this and think about it and let you know if I come up with something.

    If anyone else has any ideas or suggestions on how to do this feel free to post it and I’ll make sure it gets out. Sorry I don’t have a better answer at this time.
    Ben

  19. Vegard
    March 17th, 2009 at 02:49 | #19

    Hi.
    If you want to remove the column header on only one webpart on the page:
    1. Find this code:
    TR class=”ms-viewheadertr” VALIGN=TOP
    2. Then insert the display:none code like this:
    TR class=”ms-viewheadertr” style=”display:none” VALIGN=TOP

    Then it will only apply to the webpart you are editing.
    (if you open your page in sharepoint designer, the webpart code is the code that are marked red and black. This is often a lot of code, so is best to search(ctrl+f) for “ms-viewheadertr” ).

    Vegard, Norway.

  20. Susan
    April 3rd, 2009 at 08:38 | #20

    Hey

    Great blog!!! Its exactly what we have been looking for!!
    Thank you

  21. shell
    April 16th, 2009 at 18:27 | #21

    you are godsend! have been googling this up for sooooo many days already. thanks a lot!

  22. April 24th, 2009 at 09:44 | #22

    SUHWEEEEEEEEEEETTT!!! I was just trying to figure out how to do this but didn’t want to do it across the entire site collection. Perfect targeted solution for our public pages. Thanks!

  23. kashti
    April 24th, 2009 at 22:05 | #23

    Hey extremely nice suggestion….mind blowing!!!
    By any chance do you know how to do the same in preview pane style…
    please help.

  24. Vicki
    April 27th, 2009 at 03:17 | #24

    That’s really helped a newbie – thank you!!

  25. Mark
    April 29th, 2009 at 10:51 | #25

    I want to keep the column heading, but change the background to transparent. I can’t seem to find the style that controls the background. Ideas?
    Thanks

  26. Phong Tat
    April 30th, 2009 at 14:13 | #26

    Hi,

    How did you go from list web part to content editor web part? There are some steps missing. Did you leave the same list web part on the page then added the content editor web part with the 3 lines of code, which effectively hid all of the columns on all of the web parts on that page?

    Please walk us newbies through what you did step by step. Thanks!

  27. admin
    May 11th, 2009 at 22:06 | #27

    Here are the steps:
    1. Add the list web part
    2. Add a content editor web part on the same page
    3. Edit the Web Part Properties of the content editor web part
    4. Used HTML Editor (not rich text) on the content editor web part
    5. Add the three lines of code listed in the post
    6. Click Apply, OK
    7. This will hide everything of class .ms-viewheadertr on that particular page

    Hope that helps, let me know if something still isn’t clear

  28. Regi
    June 20th, 2009 at 04:17 | #28

    Great!!!!!Its exactly what we have been looking for!!
    Thanks

  29. Dalunda
    July 30th, 2009 at 22:40 | #29

    Great tip. Been looking for something like this. Anyone know if there is a way to hide just a single column in a web part? I cannot remove it from the view completely because it is used for a connection between two web parts – but I just don’t want to show it (always felt it looked ugly to have the filtering columns displayed in both the providing and receiving web parts).

    Thx for the post.

  30. joshsisk
    August 25th, 2009 at 12:55 | #30

    Great tip! This was very helpful and gave me some good ideas for other workarounds, I didn’t realize that hidden web parts could still interact in this way. Thanks!

  31. August 31st, 2009 at 14:43 | #31

    Is there a way to use this tip (which is AWESOME BTW) to target a specific web part? For example, just a links list.

    Thanks again for the tip and more importantly, sharing it with the community.

    E.

  32. September 12th, 2009 at 08:19 | #32

    I haven’t yet found a way to target a single web part. If I find a way to apply it to only a single web part I will definitely post an update. If anyone else has found a way to apply it to single web part on a page feel free to post.

    Ben

  33. October 5th, 2009 at 14:28 | #33

    Let me add my thanks for this solution. Yes, single web-part targeting would be nice. Sometimes the column headings actually serve a practical purpose such as providing a useful albeit hidden sort / filter.

  34. Naresh
    October 7th, 2009 at 10:03 | #34

    Hi Vegard,

    your suggestion to edit the webpart in designer works.. great..Thanks.. and this is working for a single webpart on a page.
    many thanks.

  35. Naresh
    October 7th, 2009 at 10:04 | #35

    Hi All,

    is there any tweak that we can fix the width of the individual columns in a webpart..
    Thanks.

  36. October 14th, 2009 at 12:45 | #36

    Hi
    Yeah, hope my suggestion works. It works great for me :-) And yes it works on a single webpart :-)

  37. October 20th, 2009 at 18:25 | #37

    I tried the code and it worked, but I permanently lost my quick launch bar. How do I get it back? Deleting the web part doesn’t do it. Any help would be appreciated.

  38. October 21st, 2009 at 05:40 | #38

    Hello,

    I created the content editor web part as per the above, but along with the headers to my list columns, it removed my quick launch. Deleting the content editor web part brings back my column headers but not my quick launch. Any ideas on how to get it back? Any help is greatly appreciated.

  39. Joke V.
    December 9th, 2009 at 06:23 | #39

    Great workaround !
    Any idea how to do this in SPS 2010?

  40. December 11th, 2009 at 04:02 | #40

    you’re a life saver! thanks :)

  41. admin
    December 16th, 2009 at 16:24 | #41

    @Joke V.

    Joke V.,
    That’s a great question. I haven’t tried this in SharePoint 2010 yet. I have it installed in VM, unfortunately, the VM is on my computer in the office right now (I thought I had it on my laptop). I’ll work on the solution for SharePoint 2010 and post an update as soon as I have one.

  42. nicole
    January 16th, 2010 at 15:49 | #42

    I searched everywhere!!
    This worked perfectly!!
    AWESOME!!

  43. Joke V.
    March 8th, 2010 at 07:16 | #43

    @admin
    In SPS 2010, you can just add your lines of code within your wiki editor (which is now standard). In editing mode place your cursor inline and go to Editing Tools->Format Text->Markup->HTML->Edit HTML Source. Here you can just add your style changes

  44. James H
    March 26th, 2010 at 04:41 | #44

    After spending the whole of this morning trying to hide column headers on just one web part, I have finally got it, with help from this page and http://wimdeboel.wordpress.com/2009/02/22/style-webparts-differently/.

    Bascially, change the style to:

    #MSOZoneCell_WebPartWPQx .ms-viewheadertr { display: none;}

    and replace x with the unique number for your webpart. You can fin this in the source of the page.

    J

  45. admin
    March 26th, 2010 at 05:13 | #45

    James, thanks for sharing that reference!

  46. Catherine Wright
    June 9th, 2010 at 14:34 | #46

    This worked great for me. It was quick and easy. I used it on a reporting page where I have several list views with condensed groupings. It looks so much better without column headers. Thanks for the great tip!

  47. scott
    August 20th, 2010 at 06:42 | #47

    I’ve been working with SP for two years. This was a total eureka moment. Mind blown. SO SIMPLE. Muchos gracias.

  1. No trackbacks yet.