New to Telerik UI for ASP.NET AJAXStart a free 30-day trial

Filter Template and Custom Columns

Filtering is automatically supported for Template columns.To allow filtering in template columns, you need only do the following:

  • Set the AllowFilteringByColumn property of the grid or table view to True. This is needed to enable filtering.

  • Ensure that the AllowFiltering property of the template column is True (this is the default value).

  • Set the DataField property of the template column to the field you want to use for filtering.

ASP.NET
<telerik:GridTemplateColumn DataField="Country" HeaderText="Country">
    <HeaderStyle Width="30%" />
    <ItemTemplate>
        <img src='Img/<%# Eval("Country") %>.gif' alt="" style="vertical-align: middle; margin-right: 7px;" />
        <%# Eval("Country")%>
    </ItemTemplate>
</telerik:GridTemplateColumn>

If you would like to support filtering for GridTemplateColumns programmatically or for your custom columns which extend built-in grid column, you can extend the default GridColumnName class (part of the Telerik RadGrid object model) and add a textbox control to it. Thus you will be able to filter the GridColumnName values exactly the same way as with other Telerik RadGrid column types.

Here is how this can be done with column which extends GridTemplateColumn:

ASP.NET
<%@ Register TagPrefix="custom" Namespace="<MyApplicationNamespace>" Assembly="<MyApplicationAssembly>" %>
<telerik:RadGrid RenderMode="Lightweight" ID="RadGrid1" AllowPaging="True" AutoGenerateColumns="False" AllowFilteringByColumn="True"
   runat="server">
   <MasterTableView>
       <Columns>
           <custom:MyCustomFilteringColumn DataField="Country" HeaderText="Country">
               <ItemTemplate><%# Eval("Country") %></ItemTemplate>
           </custom:MyCustomFilteringColumn>            
       </Columns>
   </MasterTableView>
</telerik:RadGrid>
Not finding the help you need?
Contact Support