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

Filter does not work on GridBoundColumn(DateTime Type) if non-datetime text entered into column filter box.

1 Answer 119 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Smruti Ranjan
Top achievements
Rank 1
Smruti Ranjan asked on 07 May 2012, 02:10 PM
I am having a RadGrid on my page.

This grid is having a GridBoundColumn of type "DateTime" with the CurrentFilterFunction="EqualTo" with in-place filter for the columns. My requirement is not to use the DatePicker icon to select date rather allow user to write text directly into filter through the column. But while trying with the filter functionality typing any non-datetime text into the column filter control and clicking enter postbacks the page but it does not filters, the same data remains there in the page, whereas it should filter and should show no data for any non-datetime entry into filter control.

Here is my RadGridBound column's source:-

<telerik:GridBoundColumn UniqueName="DOB" DataField="DOB" HeaderText="DOB"
                       CurrentFilterFunction="EqualTo" ShowFilterIcon="False" AutoPostBackOnFilter="True"
                       DataFormatString="{0:d}" DataType="System.DateTime">                       
                       <ItemStyle HorizontalAlign="Right" />
                       <HeaderStyle HorizontalAlign="Right" Width="100px" />
                       <FooterStyle HorizontalAlign="Right" />                       
                   </telerik:GridBoundColumn>

Can anybody have any idea for solving this issue.
Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Accepted
Vasil
Telerik team
answered on 10 May 2012, 08:15 AM
Hi Smruti,

When the text in DateInput is invalid, it server value is null. This is because the SelectedDate is of type DateTime? (nullable DateTime).
In this case the filter will not be applied, because it is the same as empty.

It is designed such way, because if we choose to filter with null value, then initially if you have CurrentFilterFunction set, and the same time the input is empty, no records will be displayed. Which would be still wrong.

As a workaround you can use custom filtering. Place a DateInput in the filter template. And on PostBack do filter, even if it is in invalid stage.

Regards,
Vasil
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Smruti Ranjan
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Share this question
or