New to Telerik UI for ASP.NET AJAX? Start a free 30-day trial
Aligning Items in GroupHeader
Sometimes it is necessary to align an item in the GroupHeader of the grid, so that it is positioned beneath a given column cell. For example, let us assume that we have a grid with four columns - "ProductID", "ProductName", "UnitPrice" and "UnitsInStock". Then, if the user groups on the "UnitPrice" column, it will be positioned in the left-most part of the group header. In some situations, however, it is visually more intuitive to position this item beneath the "UnitPrice" column header cell. The code below demonstrates one similar setup, along with the code required to handle this logic.
ASP.NET
<telerik:RadGrid RenderMode="Lightweight" ShowGroupPanel="true" AutoGenerateColumns="false" ID="RadGrid1"
DataSourceID="SqlDataSource1" AllowFilteringByColumn="True" AllowSorting="True"
ShowFooter="True" runat="server" GridLines="None" AllowPaging="true" OnItemCreated="RadGrid1_ItemCreated">
<PagerStyle Mode="NextPrevAndNumeric" />
<MasterTableView AllowMultiColumnSorting="true">
<Columns>
<telerik:GridBoundColumn DataField="ProductID" HeaderText="Product
ID">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ProductName" HeaderText="Product
name" SortExpression="ProductName" UniqueName="ProductName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="UnitPrice" UniqueName="UnitPrice" HeaderText="Unit price">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="UnitsInStock" HeaderText="Units in
stock">
</telerik:GridBoundColumn>
</Columns>
<GroupByExpressions>
<telerik:GridGroupByExpression>
<GroupByFields>
<telerik:GridGroupByField FieldName="UnitPrice" />
</GroupByFields>
<SelectFields>
<telerik:GridGroupByField FieldName="UnitPrice" HeaderText="Unit price" />
</SelectFields>
</telerik:GridGroupByExpression>
</GroupByExpressions>
</MasterTableView>
<ClientSettings AllowDragToGroup="true" />
</telerik:RadGrid>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT * FROM Products Where UnitPrice > 9.50">
</asp:SqlDataSource>