GroupByHeader Property

SPView.GroupByHeader Property

Gets or sets the definition of the Group By header used in the view.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online

public string GroupByHeader { get; set; }

Property Value

Type: System.String
A Collaborative Application Markup Language (CAML) string that contains the header definition.

If you set values through the GroupByHeader property, you must use the Update method for changes to take effect in the database.

The following code example uses the GroupByHeader property to customize the font size, font color, and background color of the Group By header area in a view within a specified site of the current site collection.

SPSite oSiteCollection = SPContext.Current.Site;
using(SPWeb oWebsite = oSiteCollection.AllWebs["Website_Name"])
   SPList oList = oWebsite.Lists["List_Name"];
   SPView oView = oList.Views["View_Name"];

    oView.GroupByHeader = 
   "<HTML><![CDATA[<TBODY id=\"titl]]></HTML>" +
   "<GetVar Name=\"GroupByLevelString\" />" + 
   "<HTML><![CDATA[\"><TR STYLE=\"font-size:14pt;color:red\"]]></HTML>" 
   "<Switch><Expr><GetVar Name=\"GroupByIndent\" /></Expr>
      <Case Value=\"0\">" +
   "<HTML><![CDATA[ class=\"ms-gb\" ]]></HTML></Case><Default>" + 
   "<HTML><![CDATA[ class=\"ms-gb2\" ]]></HTML></Default></Switch>" + 
   "<HTML><![CDATA[><TD colspan=\"100\" nowrap BGCOLOR=\"white\">" + 
   "<img src=\"/_layouts/images/blank.gif\" alt=\"\" height=1 
      width=]]>" + 
   "</HTML><GetVar Name=\"GroupByIndent\" />" +
   "<HTML><![CDATA[><a href=\"javascript:\" 
      onclick=\"javascript:ExpCollGroup(']]></HTML>" + 
   "<GetVar Name=\"GroupByLevelString\" />
      <HTML><![CDATA[','img_]]></HTML>" +
   "<GetVar Name=\"GroupByLevelString\" />
      <HTML><![CDATA[');return false;\"><img id=\"img_]]></HTML>" + 
   "<GetVar Name=\"GroupByLevelString\" />
      <HTML><![CDATA[\" src=\"/_layouts/images/minus.gif\" 
      alt=\"]]></HTML>" +
      <HTML><![CDATA[\" border=\"0\"></a>&nbsp;]]></HTML>" + 
   "<GetVar Name=\"GroupByField\" HTMLEncode=\"TRUE\" />
      <HTML><![CDATA[ :&nbsp;]]></HTML>" + 
   "<GetVar Name=\"GroupByValue\" />
      <HTML><![CDATA[</TD></TR></TBODY>]]></HTML>" + 
   "<HTML><![CDATA[<TBODY id=\"tbod]]></HTML>
      <GetVar Name=\"GroupByLevelString\" HTMLEncode=\"TRUE\" />" + 
   "<HTML><![CDATA[_\">]]></HTML><SetVar Name=\"EvenRow\" 
      Scope=\"Request\" Value=\"0\" />" + 
   "<SetVar Name=\"OnlyOneItem\" Scope=\"Request\" Value=\"1\" />";

Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. For information about good coding practices, see Disposing Objects.

© 2016 Microsoft