Skip to main content
A newer version of this page is available. .
Tab

ASPxNavBar.GroupDataFields Property

Provides access to properties allowing you to specify data fields (attributes of xml elements) from which group settings of a bound NavBar should be obtained.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v19.1.dll

Declaration

public NavBarGroupDataFields GroupDataFields { get; }

Property Value

Type Description
NavBarGroupDataFields

A NavBarGroupDataFields object that contains the required mapping properties.

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

XSLT - Transformation

<?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>
See Also