The Summary Row feature of WebDataGrid is available in WebHierarchicalDataGrid. The behavior allows adding standard summaries (Count; Sum; Average; Min; Max) as well as custom ones.
Each band in WebHierarchicalDataGrid can be assigned a Summary Row behavior. You can set the EnableInheritance property of a band to enable child bands to inherit the setting. This allows you to customize summary row behavior in each band of data. For example, if you want summaries for all bands in WebHierarchicalDataGrid, just enable the SummaryRow behavior at the root level and set EnableInheritance to True. If you want to disable the behavior for a specific child band, disable the behavior for that specific band.
When enabled, the behavior adds a summary button to each header. When the button is pressed, a drop-down with available summaries appears.
Enabling Summary Row
<ig:WebHierarchicalDataGrid ID="WebHierarchicalDataGrid1" runat="server" DataSourceID="WebHierarchicalDataSource1"
Height="400px" Width="750px" DataKeyFields="ProductID" >
<Bands>
<ig:Band Height="100" DataMember="AccessDataSource1_Orders" DataKeyFields="OrderID">
<Behaviors>
<ig:SummaryRow>
<ColumnSummaries>
<ig:ColumnSummaryInfo ColumnKey="Quantity">
<Summaries>
<ig:Summary SummaryType="Sum"></ig:Summary>
<ig:Summary SummaryType="Max"></ig:Summary>
</Summaries>
</ig:ColumnSummaryInfo>
</ColumnSummaries>
</ig:SummaryRow>
</Behaviors>
</ig:Band>
</Bands>
<Behaviors>
<ig:SummaryRow EnableInheritance="true">
<ColumnSummaries>
<ig:ColumnSummaryInfo ColumnKey="UnitPrice">
<Summaries>
<ig:Summary SummaryType="Average"></ig:Summary>
</Summaries>
</ig:ColumnSummaryInfo>
</ColumnSummaries>
</ig:SummaryRow>
</Behaviors>
</ig:WebHierarchicalDataGrid>
protected void WebHierarchicalDataGrid1_InitializeBand(object sender, BandEventArgs e)
{
if (e.Band.Key == "Products")
{
e.Band.Behaviors.CreateBehavior<SummaryRow>();
e.Band.Behaviors.SummaryRow.EnableInheritance = true;
ColumnSummaryInfo unitPriceSummary = new ColumnSummaryInfo();
unitPriceSummary.ColumnKey = "UnitPrice";
unitPriceSummary.Summaries.Add(SummaryType.Average);
e.Band.Behaviors.SummaryRow.ColumnSummaries.Add(unitPriceSummary);
this.WebHierarchicalDataGrid1.RefreshBehaviors();
}
else if (e.Band.Key == "Orders")
{
e.Band.Behaviors.CreateBehavior<SummaryRow>();
e.Band.Behaviors.SummaryRow.EnableInheritance = true;
ColumnSummaryInfo quantitySummary = new ColumnSummaryInfo();
quantitySummary.ColumnKey = "Quantity";
quantitySummary.Summaries.Add(SummaryType.Sum);
quantitySummary.Summaries.Add(SummaryType.Max);
e.Band.Behaviors.SummaryRow.ColumnSummaries.Add(quantitySummary);
this.WebHierarchicalDataGrid1.RefreshBehaviors();
}
}