ASPxNavBar.GroupContentTemplate Property
Gets or sets a common template used for displaying the client region’s content of all groups within the navbar control.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v24.1.dll
NuGet Package: DevExpress.Web
Declaration
Property Value
Type | Default | Description |
---|---|---|
ITemplate | null | An object supporting the System.Web.UI.ITemplate interface which contains the template used for displaying the client regions of all groups within the navbar. |
Remarks
Use the GroupContentTemplate property to define a common content for the client regions of all groups within the current navbar control. A group’s client region is considered as an area where group items are displayed - it doesn’t involve the group’s header. The template created using the GroupContentTemplate property fills the entire client region of each group within the navbar.
The GroupContentTemplate property is useful when it is required to display a specific control within navbar groups. Placing a control onto the template container causes the control to be displayed within a group when the group is expanded.
Note that any style settings defined for the client regions of the groups via specific properties (such as the ASPxNavBar.GroupContentStyle or NavBarGroup.ContentStyle) are still in effect for the groups whose contents are specified using the GroupContentTemplate property.
The content of a particular group’s client region can be defined using the group’s NavBarGroup.ContentTemplate property.
Note
Once a template defined via the GroupContentTemplate property is created within a control, it is instantiated within a container object of the NavBarGroupTemplateContainer type. This container object exposes a set of specific properties to which the template’s child controls can be bound.
Example
When the ASPxNavBar is bound to XmlDataSource, the latter should suit the following structure:
<Root>
<Group Text ="Reports">
<Item Text =" ... " NavigateUrl="..." ImageUrl="..." />
</Group>
</Root>
In this case, XmlDataSource can retrieve and synchronize the Text, NavigateUrl and ImageUrl XML attributes with ASPxNavBar properties. However, in real applications, data seldom suits this structure. Most often, an XML schema contains several sub- nodes that describe some element. For instance:
<Menus>
<Menu text="abc1">
<ProductID>193</ProductID>
<ProductName>090 - Introduction</ProductName>
<PTName>Video</PTName>
</Menu>
</Menus>
XmlDataSource cannot parse such a schema. However, XmlDataSource allows specifying an XSLT file where you can define a transformation that will be applied to the specified DataFile. In this case, it is necessary to utilize the GroupContentTemplate. For example:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<Menus>
<xsl:for-each select="//Menus/*">
<Menu Text="{ProductName}" ProductID="{ProductID}">
</Menu>
</xsl:for-each>
</Menus>
</xsl:template>
</xsl:stylesheet>
<GroupContentTemplate>
ProductID:
<asp:Label ID="Label1" runat="server" Text='<%# DataBinder.Eval(Container.Group.DataItem, "ProductID") %>'></asp:Label>
</GroupContentTemplate>
You can learn more about XML transformation files from the following sources:
Using XSLT files with the new XMLDataSource control
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<Menus>
<xsl:for-each select="//Menus/*">
<Menu Text="{ProductName}" ProductID="{ProductID}" DateAdded="{DateAdded}" PCName="{PCName}">
</Menu>
</xsl:for-each>
</Menus>
</xsl:template>
</xsl:stylesheet>
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/App_Data/Lessons.xml"
XPath="//Menus/*" TransformFile="~/App_Data/Lessons.xsl"></asp:XmlDataSource>
<dx:ASPxNavBar ID="ASPxNavBar1" runat="server" ClientIDMode="AutoID" DataSourceID="XmlDataSource1">
<GroupContentTemplate>
ProductID:
<asp:Label ID="Label1" runat="server" Text='<%# DataBinder.Eval(Container.Group.DataItem, "ProductID") %>'></asp:Label><br />
DateAdded:
<asp:Label ID="Label2" runat="server" Text='<%# DataBinder.Eval(Container.Group.DataItem, "DateAdded") %>'></asp:Label><br />
PCName:
<asp:Label ID="Label3" runat="server" Text='<%# DataBinder.Eval(Container.Group.DataItem, "PCName") %>'></asp:Label><br />
</GroupContentTemplate>
<GroupDataFields TextField="Text" />
</dx:ASPxNavBar>
<Menus>
<Menu text="abc1">
<ProductID>193</ProductID>
<PLID>3</PLID>
<ProductName>090 - Introduction</ProductName>
<Description />
<DateAdded>2010-07-05T00:00:00-04:00</DateAdded>
<Scheduled>No</Scheduled>
<PTName>Video</PTName>
<PDName>On-Demand</PDName>
<PLName>lvl 1</PLName>
<LevelNumber>1</LevelNumber>
<PCName>Education</PCName>
</Menu>
<Menu text="abc2">
<ProductID>200</ProductID>
<PLID>3</PLID>
<ProductName>101 - Introduction to Investment Income</ProductName>
<Description />
<DateAdded>2010-07-21T00:00:00-04:00</DateAdded>
<Scheduled>No</Scheduled>
<PTName>Video</PTName>
<PDName>On-Demand</PDName>
<PLName>lvl 1</PLName>
<LevelNumber>1</LevelNumber>
<PCName>Education</PCName>
</Menu>
</Menus>