How to use DateTime Filter?

Mar 25, 2013 at 4:16 AM
Edited Mar 25, 2013 at 4:16 AM
Hello,

as title said, this is my code
columns.Add(x => x.StartDate)
        .Titled("Start Date")
        .Sortable(true)
        .Filterable(true)
        .Format("dd-MMM-yyyy");
x.StartDate is DateTime, but its just showing string filter, how to make it to datetime filter just like your online demo?

FYI: I downloaded gridmvc from nuget package

Thanks!
Coordinator
Mar 25, 2013 at 4:52 AM
Hi,

To render DatePicker control like on demo page, you need to register jqueryUi datepicker script - http://jqueryui.com/demos/datepicker/ on the grid page

If you want to render custom DateTime controls you need to create custom filter widget, for more infomation please see - Documentation
Apr 21, 2013 at 6:16 PM
Edited Apr 22, 2013 at 2:52 PM
Image
Your answer worked but my output is kinda messed up, what is causing this?
EDIT:
Nvm, I fixed the layout...

I do have another problem. When I use the jquery datapicker I can always click once.
For example if I want to skip 4 months is does the following:
  1. click the next month arrow
  2. it automatically closes the filter popup after 1 next so I have to press the filter
    button 4 times...
Is this normal?

Thanks in advance!
Jul 10, 2013 at 4:29 PM
I do have another problem. When I use the jquery datapicker I can always click once.
For example if I want to skip 4 months is does the following:
  1. click the next month arrow
  2. it automatically closes the filter popup after 1 next so I have to press the filter
    button 4 times...
I'm having the same problem, example is in the demo site: http://gridmvc.skyliver.ru/
  1. Click the date filter icon
  2. The date picker opens
  3. Click the right/next month arrow
  4. The date picker closes ** it shouldn't close
Are there any workarounds?
Coordinator
Jul 13, 2013 at 3:26 AM
Hi, amervitz. It's an intresting issue.

I am look at it and I couldn't fully understand why it occurs.
I guess it occurs due specific behaivor of jquery datepicker control, that rebuild layout and click event happens outside of grid filter popup box.

Now I can't say the solution for jquery datepicker. I will research this problem.
You can create custom filter widget with other datepicker control. See more about creating customer filter widgets - https://gridmvc.codeplex.com/wikipage?title=Creating%20custom%20filter%20widget&referringTitle=Documentation
Mar 4, 2014 at 12:29 AM
hi

This may be late, but you need bootstrap-datepicker.js to render this correctly.