Back to Devexpress

GridViewTemplates.GroupRowContent Property

aspnet-devexpress-dot-web-dot-gridviewtemplates-3d819444.md

latest4.4 KB
Original Source

GridViewTemplates.GroupRowContent Property

Specifies a template to display the group row content.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
[DefaultValue(null)]
public virtual ITemplate GroupRowContent { get; set; }
vb
<DefaultValue(Nothing)>
Public Overridable Property GroupRowContent As ITemplate

Property Value

TypeDefaultDescription
ITemplatenull

An object that implements the ITemplate interface.

|

Remarks

When you specify the GroupRowContent property, the control creates a template within a container object of the GridViewGroupRowTemplateContainer type.

Refer to the Create Templates topic for information on how to create templates for the Grid View control’s elements.

View Example: How to select/deselect all rows in a group when Grid View data is grouped by one columnView Example: How to display group summary in group headers

Example

In the example below, the group row content template contains ASPxCheckBox to expand/collapse grid groups.

aspx
<dx:ASPxGridView ID="ASPxGridView1" runat="server" ClientInstanceName="grid" AutoGenerateColumns="False">
    <Settings ShowGroupButtons="False" ShowGroupPanel="True" />
    <Columns>
        <dx:GridViewDataTextColumn FieldName="ProductID" ReadOnly="True" VisibleIndex="0">
            <EditFormSettings Visible="False" />
        </dx:GridViewDataTextColumn>
        <dx:GridViewDataTextColumn FieldName="ProductName" VisibleIndex="1" />
        <dx:GridViewDataTextColumn FieldName="CategoryID" VisibleIndex="2" GroupIndex="0"
            SortIndex="0" SortOrder="Ascending" />
        <dx:GridViewDataTextColumn FieldName="UnitPrice" VisibleIndex="3" />
        <dx:GridViewDataTextColumn FieldName="UnitsInStock" VisibleIndex="4" />
    </Columns>
    <Templates>
        <GroupRowContent>
            <dx:ASPxCheckBox ID="ASPxCheckBox1" runat="server" OnInit="ASPxCheckBox1_Init" />
            <%# Container.GroupText + Container.KeyValue%>
        </GroupRowContent>
    </Templates>
</dx:ASPxGridView>
javascript
function ExpandCollapse(sender, index) {
    if (sender.GetChecked())
        grid.ExpandRow(index);
    else
        grid.CollapseRow(index);
}
csharp
protected void ASPxCheckBox1_Init(object sender, EventArgs e) {
    ASPxCheckBox cb = sender as ASPxCheckBox;
    GridViewGroupRowTemplateContainer container = cb.NamingContainer as GridViewGroupRowTemplateContainer;
    if (ASPxGridView1.IsRowExpanded(container.VisibleIndex))
        cb.Checked = true;
    cb.ClientSideEvents.CheckedChanged = string.Format("function (s, e) {{ ExpandCollapse(s, {0}); }}", container.VisibleIndex);
}
vb
Protected Sub ASPxCheckBox1_Init(ByVal sender As Object, ByVal e As EventArgs)
    Dim cb As ASPxCheckBox = TryCast(sender, ASPxCheckBox)
    Dim container As GridViewGroupRowTemplateContainer = TryCast(cb.NamingContainer, GridViewGroupRowTemplateContainer)
    If ASPxGridView1.IsRowExpanded(container.VisibleIndex) Then
        cb.Checked = True
    End If
    cb.ClientSideEvents.CheckedChanged = String.Format("function (s, e) {{ ExpandCollapse(s, {0}); }}", container.VisibleIndex)
End Sub

See Also

GridViewTemplates Class

GridViewTemplates Members

DevExpress.Web Namespace