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

RadGrid and Date Filter

2 Answers 72 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jako
Top achievements
Rank 1
Jako asked on 08 Oct 2013, 12:07 PM
Hi there
I am applying a filter in a radGrid on pre_Render, its works great, but when I add a date field, it doesn't bring any results.

Here is a example of what I am doing:
DateTime startDate = DateTime.Parse("2013-10-01");
uxBookOrderGrid.MasterTableView.FilterExpression = "(([StatusDescription] LIKE \'%Approved%\') AND ([TimeStamp] >= '" + startDate.ToString("g") + "'))";
uxBookOrderGrid.Rebind();
and the aspx
<telerik:GridDateTimeColumn  DataFormatString="{0:g}" DataType="System.DateTime" FilterControlWidth="90%" HeaderText="Date" DataField="TimeStamp" UniqueName="TimeStamp" />
It works great without the [TimeStamp] filter.

Any idea why this is not working?

Thank you.

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 08 Oct 2013, 12:17 PM
Hi,

Please try the sample code snippet it works fine at my end.If this doesn't help,please provide your full code snippet.

ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" AllowFilteringByColumn="true" EnableLinqExpressions="false" OnPreRender="RadGrid1_PreRender">
     <MasterTableView>
        <Columns>
           <telerik:GridBoundColumn UniqueName="OrderID" DataField="OrderID" HeaderText="OrderID" />
           <telerik:GridBoundColumn DataField="ShipCountry" HeaderText="ShipCountry" UniqueName="ShipCountry" />
          <telerik:GridDateTimeColumn DataFormatString="{0:g}" DataType="System.DateTime" FilterControlWidth="90%"  HeaderText="OrderDate" DataField="OrderDate" UniqueName="OrderDate" />
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

C#:
protected void RadGrid1_PreRender(object sender, EventArgs e)
    {
        DateTime startDate = DateTime.Parse("2013-07-06");
        RadGrid1.MasterTableView.FilterExpression = "((ShipCountry LIKE \'%Brazil%\') AND (OrderDate >= '" + startDate.ToString("g") + "'))";
        RadGrid1.Rebind();
    }

Thanks,
Princy
0
Jako
Top achievements
Rank 1
answered on 08 Oct 2013, 12:28 PM
Hi Princy

Seems I had a extra bracket in my code that was causing the filter to fail...

Thanks.
Tags
Grid
Asked by
Jako
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Jako
Top achievements
Rank 1
Share this question
or