Filter using date in radgrid

2 posts, 0 answers
  1. Debashis Pyne
    Debashis Pyne avatar
    66 posts
    Member since:
    Apr 2010

    Posted 12 Oct 2010 Link to this post

    I have separate date and time field in 2 fields at database table. I am bounding it under ItemTemplate of a GridTemplateColumn . It is showing fine but can not be filtered by any means.

    <telerik:RadGrid ID="grdDiscussionList" Skin="WebBlue"
    runat="server" GridLines="None"
    AllowFilteringByColumn = "true"
    AllowPaging="True" PageSize="10"

    <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
    <MasterTableView DataKeyNames="Discussion_Id" CommandItemDisplay="Top" EditMode="PopUp">
    <CommandItemSettings ShowAddNewRecordButton="false"/>
    <EditFormSettings PopUpSettings-Modal="true" />

    <telerik:GridBoundColumn DataField="Discussion_Id" DataType="System.Int32"
    HeaderText="Discussion Id" ReadOnly="True" SortExpression="Discussion_Id"
    UniqueName="Discussion_Id" Visible="false" >


    <telerik:GridTemplateColumn UniqueName="Discussion_Date" HeaderText="Discussion date"
    SortExpression="Discussion_Date" ItemStyle-Width="100">
    <%# showDiscussionDate(Container.DataItem) %>&nbsp;<%# showDiscussionTime(Container.DataItem) %>
    <ClientSettings EnableRowHoverStyle="true"></ClientSettings>

    public string showDiscussionDate(object dataItem)
    string retDate = string.Empty;
    string inDate = string.Empty;
    inDate = DataBinder.Eval(dataItem, "discussion_date").ToString();
    retDate = clsUtility.returnDateFormat(inDate);
    return retDate;

    public string showDiscussionTime(object dataItem)
    string retTime = string.Empty;
    string inTime = string.Empty;
    inTime = DataBinder.Eval(dataItem, "Discussion_Time").ToString();
    //retTime = clsUtility.returnTimeFormat(inTime);
    retTime = inTime;
    return retTime;

    Any idea , how to resolve this problem?
  2. Marin
    Marin avatar
    1038 posts

    Posted 14 Oct 2010 Link to this post

    Hi Debashis Pyne,

    In order to allow filtering for GridTemplateColumn you need to do the following things:
    • 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.

    The last point is particularly important since it actually enables the grid to do a specific filtering on a field from the datasource. In your case you might set the DataField property to discussion_date or discussion_time fields from the data source. For more information on this subject please refer to the following help topic and live demo.
    Of course you can also create your custom filter using the filter template of the template column and handle the filtering logic yourself.

    All the best,
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft R3 2016 release webinar banner
Back to Top