4

Is it possible to hide the header row, displaying column headers, for a specific view on a SharePoint 2010 publishing page? We've used this CSS to hide the column headings, but this is all or nothing; in other words, we can't hide and show the column header for an individual view:

tr.ms-viewheadertr{
  display:none;
}

In addition, setting a TR's display to none has other issues: IE7 can't handle display:table-row when you need to show the column again; you have to use display:inline-block for that one browser and the table-row for modern browsers. Plus, this technique affects all of the views on the page rather than the specific one we need to handle.

Anyone know of a way to hide/show the column headings from the web part editor or some cleaner solution? Thanks.

1
  • Possible solution using jQuery and CEWP: $("table[summary*='List name']").each(function(){ $(this).find("tr:eq(0)").show(); });, from here: code-journey.com/2011/…
    – Alex C
    Oct 19, 2011 at 9:00

3 Answers 3

4

You can add the following to an .xsl file and link to it in the "Miscellaneous" options when you edit the web part. By doing it this way, you can reuse the same style sheet over and over.

This xsl basically overrides a couple of templates located in the "vwstyles.xsl" file, and removes the lines that add the header.

(This code works in production, but I may not have replicated it properly in this forum, so please test first.)

<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" 
                xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" 
                xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" 
                xmlns:asp="http://schemas.microsoft.com/ASPNET/20" 
                xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" 
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
                xmlns:msxsl="urn:schemas-microsoft-com:xslt" 
                xmlns:SharePoint="Microsoft.SharePoint.WebControls" 
                xmlns:ddwrt2="urn:frontpage:internal" 
                xmlns:o="urn:schemas-microsoft-com:office:office">
   <xsl:include href="/_layouts/xsl/main.xsl"/>
   <xsl:include href="/_layouts/xsl/internal.xsl"/> 
   <xsl:template  match="View" mode="full">
      <xsl:apply-templates select="." mode="RenderView" />
      <xsl:apply-templates mode="footer" select="." />
   </xsl:template>
   <!-- Boxed and Boxed No Labels -->
   <!-- Issues Boxed and Boxed No Labels -->
   <xsl:template  match="View[ViewStyle=/@ID='12' or ViewStyle=/@ID='13' or ViewStyle=/@ID='18' or ViewStyle=/@ID='19']" mode="full">
      <xsl:apply-templates select="." mode="RenderView" />
   </xsl:template>
</xsl:stylesheet>
2

Treat the views as DVWP, since they are XSLT List Views (XLV) then you can go in and edit them in SharePoint designer and remove the header for a specific column.

1
  • Could you expound on this? What do you mean by "Treat the views as DVWP"?
    – Alan M
    May 9, 2014 at 18:03
-1

You can also add CEWP and below css class,

table[summary*='List name'] tr:first-child
{
    display:none;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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