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

[Solved] Filtering by date column

7 Answers 152 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Matt
Top achievements
Rank 1
Matt asked on 27 Feb 2012, 09:24 PM
Within the grid, is it possible to filter a DateTime type field on only the date part?  If I enter (or select) or select 2/22/2012, it won't select it unless the time also matches.  Is it possible to only do the date?

Thanks,
Matt

7 Answers, 1 is accepted

Sort by
0
Dadv
Top achievements
Rank 1
answered on 28 Feb 2012, 02:45 PM
hi,

What are you using? custom binding (ajax or server) ?
0
Matt
Top achievements
Rank 1
answered on 28 Feb 2012, 04:11 PM
I'm just binding it to the [View] Model, not using  AJAX or anything.
0
Dadv
Top achievements
Rank 1
answered on 28 Feb 2012, 04:49 PM
If you use the inbuilt filter i don't know how to mach the clue because you send the column value.

But if you use some custom binding, you could intercept the filter date request, and change it like you want.
0
Atanas Korchev
Telerik team
answered on 07 Mar 2012, 04:30 PM
Hi,

 This can be achieved if you are using server binding. You need to bind to the Date property of your DateTime object:

columns.Bound(o => o.OrderDate.Date);

 If you are using ajax binding however you need to implement custom binding as shown in this example.

Kind regards,
Atanas Korchev
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 Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
0
Matt
Top achievements
Rank 1
answered on 07 Mar 2012, 04:37 PM
Hello,
When I do that, I get the following error when I try to filter on that column:

The specified type member 'Date' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.


Thanks,
0
Atanas Korchev
Telerik team
answered on 07 Mar 2012, 05:33 PM
Hello,

 This seems to be a limitation of Linq to Entities (it works without a problem when using Linq to SQL). In that case your only option is to implement custom binding.

Regards,
Atanas Korchev
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 Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
0
Alex Smitt
Top achievements
Rank 1
answered on 03 Jul 2012, 08:16 PM
Instead of binding columns.Bound(o => o.OrderDate.Date);

try columns.Bound(o => o.OrderDate);



Tags
Grid
Asked by
Matt
Top achievements
Rank 1
Answers by
Dadv
Top achievements
Rank 1
Matt
Top achievements
Rank 1
Atanas Korchev
Telerik team
Alex Smitt
Top achievements
Rank 1
Share this question
or