Filtering on Date Only

6 posts, 0 answers
  1. Rayne
    Rayne avatar
    261 posts
    Member since:
    Sep 2010

    Posted 09 Feb 2015 Link to this post

    I've read the documentation that explains how to filter on the Date value only from here:
    http://docs.telerik.com/devtools/wpf/controls/radgridview/filtering/how-to/howto-filter-date-value

    But my grid is using auto-generated columns. How do I get this work when I'm not declaring each individual column?
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 10 Feb 2015 Link to this post

    Hi,

    As your columns are auto generated, you could subscribe for RadGridView's AutoGeneratingColumn event and apply any additional setting needed.

    Regards,
    Dimitrina
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. Rayne
    Rayne avatar
    261 posts
    Member since:
    Sep 2010

    Posted 10 Feb 2015 in reply to Dimitrina Link to this post

    I'm already subscribed to that event for some other stuff.

    I even have a check for the col data type so that dates are formatted to display the date only. But I'm unsure how to get the FieldName.Date into the FilterMemberPath so that it filters on Date only.
  4. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 12 Feb 2015 Link to this post

    Hi,

    You need to set the FilterMemberPath similarly to how you do so in xaml. Does it not work for you?

    Regards,
    Dimitrina
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  5. Rayne
    Rayne avatar
    261 posts
    Member since:
    Sep 2010

    Posted 12 Feb 2015 in reply to Dimitrina Link to this post

    No. I haven't gotten it to work. I'm a bit stuck on how to identify the correct piece of data so that I can assign it to FilterMemberPath.

    Here is a sample of my code, which is located in the AutoGeneratingColumn event handler:

    var col = e.Column as GridViewDataColumn;
    if (col.DataType == typeof(decimal?))
         col.DataFormatString = "{0:F4}";
    else if (col.DataType == typeof (DateTime))
    {
        col.DataFormatString = "{0:d}";
        //add code here to filter on Date portion of DateTime
    }
  6. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 13 Feb 2015 Link to this post

    Hi,

    You can set the FilterMemberPath based on the corresponding DataMemberBinding path.
    For example, having your existing code you should add a line like:
    col.FilterMemberPath = col.DataMemberBinding.Path.Path + ".Date";


    Regards,
    Dimitrina
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top