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

[Solved] Grid date time model parameter.

1 Answer 21 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jason
Top achievements
Rank 1
Jason asked on 18 Oct 2011, 03:52 PM
Hey folks,

Got a weird behaviour that I think might be a bug but could just be me!

I have a model with a 'ReceivedDate' property which is used to control the amount of data a grid displays (i.e. show orders after dd/mm/yyyy).  The 'ReceivedDate' takes advantage of MVC's culture so automagically displays the correct format, model binding converts the date using the 'CurrentUICulture' in the controller.

Seems to work OK so far, my GET request looks like this:

    ~/orders?receivedSince=01/09/2011 00:00&ordersGrid-orderBy=DateTime-desc&etc

The issue comes about when sorting (or performing any action)  on the grid.  The grid appears to consume the model parameters and includes them in the GET request.  The grid does not appear to obey the current UI culture for the model property.  For example, the entered date is '01/09/2011' which in en-GB is the 1st of September, 2011.  When sorting (or some other action) the grid tries to GET:

    ~/orders?receivedSince=09/01/2011 00:00&ordersGrid-orderBy=DateTime-asc&etc

Which is waaaay back in January; it always puts the month first.  Hmm.  Any ideas?

FWIW globalization in the web.config is:

    <globalization uiCulture="auto" culture="auto" />

But it doesn't seem to make any difference to the grid.  Telerik MVC version is 712, currently the free one (in the process of buying).

1 Answer, 1 is accepted

Sort by
0
Jason
Top achievements
Rank 1
answered on 19 Oct 2011, 03:41 PM
I gave up trying to figure this one out -- there's a difference between Invariant and the current UI culture, something which MVC seems to do OK and I understand.  But obviously I can't code around it depending on culture; it should just map automatically which it does when I don't try and be clever about it.  I was trying to restore the grid state (but also include the date) which I used some of the Telerik library code for.

Problem (mostly) sorted.  Thanks for reading.

 - Jason
Tags
General Discussions
Asked by
Jason
Top achievements
Rank 1
Answers by
Jason
Top achievements
Rank 1
Share this question
or