Telerik Radgrid Filter Column

Telerik Radgrid  Filter Column  

Radgrid provide a predefined properties called  AllowFilteringByColumn.
By Using this we can filter radgrid content easily without doing too much extra work.

 Step 1:Design web from .aspx page

  <div>
            <br />
            <asp:ScriptManager ID="ss" runat="server">
            </asp:ScriptManager>
            <telerik:RadGrid ID="RadGrid1" runat="server" CellSpacing="0" PageSize="8" Width="50%" PagerStyle-AlwaysVisible="true"
                GridLines="None" AutoGenerateColumns="false"
                OnNeedDataSource="RadGrid1_NeedDataSource" AllowFilteringByColumn="true">
                <HeaderStyle HorizontalAlign="Left" />
                <MasterTableView DataKeyNames="name" AutoGenerateColumns="false">
                    <NoRecordsTemplate>No records found.</NoRecordsTemplate>
                    <Columns>
                        <telerik:GridBoundColumn HeaderText="Name" DataField="Name" />
                        <telerik:GridBoundColumn HeaderText="Amount" DataField="Amount" />
                        <telerik:GridBoundColumn HeaderText="Phone" DataField="Phone" />
                    </Columns>
                </MasterTableView>
            </telerik:RadGrid>
        </div>


Step 2:Logic on .Cs page

    protected void RadGrid1_NeedDataSource(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", "32", "95802*2452");
        dt.Rows.Add("Vineet", "10.2", "88022564***");


        dt.Rows.Add("Kandy", "0.12", "8802***2564");
        dt.Rows.Add("Sam", "12", "545502*2544");
        dt.Rows.Add("Izhar", "215", "95802*2452");
        dt.Rows.Add("Vineet", "11.00", "88022564***");
        dt.Rows.Add("Kandy", "0.12", "8802***2564");
        dt.Rows.Add("Sam", "12", "545502*2544");
        dt.Rows.Add("Izhar", "215", "95802*2452");
        dt.Rows.Add("Vineet", "11.00", "88022564***");
        dt.Rows.Add("Kandy", "0.12", "8802***2564");
        dt.Rows.Add("Sam", "12", "545502*2544");
        dt.Rows.Add("Izhar", "215", "95802*2452");
        dt.Rows.Add("Vineet", "11.00", "88022564***");

        RadGrid1.DataSource = dt;
        // rad_grd_ComponentDrillThorugh.DataBind();

    }

 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