This is a migrated thread and some comments may be shown as answers.

Grid Date Range Filter default values

2 Answers 73 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Geoff
Top achievements
Rank 1
Geoff asked on 15 Nov 2013, 11:36 AM
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 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 1
answered on 15 Nov 2013, 12:09 PM
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
0
Geoff
Top achievements
Rank 1
answered on 15 Nov 2013, 02:22 PM
Once again, thank you Princy you were spot on. That works great.
Tags
Grid
Asked by
Geoff
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Geoff
Top achievements
Rank 1
Share this question
or