TelerikDeveloper.com

TelerikDeveloper.com

sgray128 5/29/2014 4:04:00 PM

ASP.NET - RadGrid Grouping and Sorting

This example will show how to code grouping in the ASP.NET RadGrid Control                            


 

<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False"  AllowMultiRowSelection="true"
    CssClass="grid" AllowPaging="True" PageSize="100" Width="950px"
    ShowGroupPanel="True">
    <ClientSettings AllowDragToGroup="True"  >
        <Selecting AllowRowSelect="True"   />
    </ClientSettings>
    <MasterTableView DataKeyNames="sopnumbe" GroupsDefaultExpanded="false">
        <SortExpressions>
            <telerik:GridSortExpression FieldName="PctComplete" SortOrder="descending" />
        </SortExpressions>
        <GroupByExpressions>
            <telerik:GridGroupByExpression>
                <SelectFields>
                    <telerik:GridGroupByField HeaderText="PO" FieldName="cstponbr" ></telerik:GridGroupByField>
                    <telerik:GridGroupByField HeaderText="Master" FieldName="MSTRNUMB" ></telerik:GridGroupByField>
                    <telerik:GridGroupByField  HeaderText="Pct Complete" FieldName="pctComplete" FormatString="{0:P}"></telerik:GridGroupByField>
                    <telerik:GridGroupByField HeaderText="PO Total" FieldName="curCustPOTotal" FormatString="{0:N2}"></telerik:GridGroupByField>
                    <telerik:GridGroupByField HeaderText="INV Total" FieldName="DocAmntTotal" FormatString="{0:N2}" ></telerik:GridGroupByField>
                </SelectFields>
                <GroupByFields >
                    <telerik:GridGroupByField FieldName="PctComplete" SortOrder="descending" />
                    <telerik:GridGroupByField FieldName="cstponbr"  ></telerik:GridGroupByField>
                </GroupByFields>
            </telerik:GridGroupByExpression>
        </GroupByExpressions>
        <Columns>
            <telerik:GridClientSelectColumn></telerik:GridClientSelectColumn>
            <telerik:GridBoundColumn DataField="cstponbr" HeaderText="Customer PO"></telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="MSTRNUMB" HeaderText="Master"></telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="SOPNUMBE" HeaderText="Order"></telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Docdate" HeaderText="Doc Date"  DataFormatString="{0:MM/dd}"></telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="DocAmnt" HeaderText="Doc Amnt" DataFormatString="{0:N2}"></telerik:GridBoundColumn>
 
            <telerik:GridBoundColumn DataField="Lot" HeaderText="Lot"></telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="vchrSubdivisionName" HeaderText="Subdivision"></telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>