Grid Date Range Filter default values

3 posts, 1 answers
  1. Geoff
    Geoff avatar
    53 posts
    Member since:
    Aug 2012

    Posted 15 Nov 2013 Link to this post

    Hello,
        Using the excellent demos available, I have implemented a date range filter for my Grid. I also needed to setup a default filter range for when the page loads which I have done in the codebehind with:

     

    Me.RadGrid1.MasterTableView.FilterExpression = "(([LogDate] >= '01/01/2012') AND ([LogDate] <= '31/12/2013'))"

     

    I would really like to be able to display these default filter values in the date range picker boxes in the Grid. Is this possible?

    Regards

    Geoff

  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 15 Nov 2013 Link to this post

    Hi Geoff,

    I guess you want to set the CurrentFilterValue property of the column. You could set both dates separated by a white-space character like shown below:

    C#:
    protected void RadGrid1_PreRender(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            RadGrid1.MasterTableView.FilterExpression =(( LogDate>= '01/01/2012') AND(LogDate<= '31/12/2013'))";
            GridColumn column = RadGrid1.MasterTableView.GetColumnSafe("LogDate");
            column.CurrentFilterFunction = GridKnownFunction.Contains;
            column.CurrentFilterValue = "01/01/2012 31/12/2013";
            RadGrid1.MasterTableView.Rebind();
        }
    }

    Thanks,
    Princy
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Geoff
    Geoff avatar
    53 posts
    Member since:
    Aug 2012

    Posted 15 Nov 2013 Link to this post

    Once again, thank you Princy you were spot on. That works great.
Back to Top