Radgrid data Grouping.

Radgrid  data Grouping.


Step 1: Design web form .aspx page

  <div>
            <asp:ScriptManager ID="ss" runat="server"></asp:ScriptManager>
            <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" OnNeedDataSource="RadGrid1_NeedDataSource1" Width="50%"
                GridLines="None" PageSize="10" ShowGroupPanel="True">
                <MasterTableView TableLayout="Fixed" AutoGenerateColumns="true">
                    <GroupByExpressions>
                        <telerik:GridGroupByExpression>
                            <SelectFields>
                                <telerik:GridGroupByField FieldAlias="NAME" FieldName="NAME" FormatString="{0:D}"
                                   ></telerik:GridGroupByField>
                                <telerik:GridGroupByField FieldAlias="Amount" FieldName="Amount" FormatString="{0:D}"
                                   ></telerik:GridGroupByField>
                            </SelectFields>
                            <GroupByFields>
                                <telerik:GridGroupByField FieldName="NAME" SortOrder="Descending"></telerik:GridGroupByField>
                                <telerik:GridGroupByField FieldName="Amount" SortOrder="Descending"></telerik:GridGroupByField>
                            </GroupByFields>
                        </telerik:GridGroupByExpression>
                    </GroupByExpressions>
                    <Columns>
                    </Columns>
                </MasterTableView>

                <HeaderStyle Width="100px"></HeaderStyle>
                <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
            </telerik:RadGrid>

        </div>

Step 2:Logic on .Cs page


protected void RadGrid1_NeedDataSource1(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
        DataTable dt = new DataTable();
        dt.Columns.Add("Name");
        dt.Columns.Add("Amount");
        dt.Columns.Add("Phone");


        dt.Rows.Add("Kandy", "12", "8802***2564");
        dt.Rows.Add("Sam", "25", "545502*2544");
        dt.Rows.Add("Izhar", "2", "95802*2452");
        dt.Rows.Add("Vineet", "585", "88022564***");
        dt.Rows.Add("Kandy", "12", "8802***2564");
        dt.Rows.Add("Sam", "25", "545502*2544");
        dt.Rows.Add("Izhar", "32", "95802*2452");
        dt.Rows.Add("Vineet", "10.2", "88022564***");
        dt.Rows.Add("Kandy", "12", "8802***2564");
        dt.Rows.Add("Sam", "25", "545502*2544");
        dt.Rows.Add("Izhar", "32", "95802*2452");
        dt.Rows.Add("Vineet", "10.2", "88022564***");




        RadGrid1.DataSource = dt;
     }

It will look like :-




Comments

Popular posts from this blog

Create and save QR code in asp.net with C#

Change text of RadGrid Header Dynamically

Telerik Radwindow Open on Button Click