2
votes

I'm using a MVC kendo helpers to display a grid, which has a remote datasource. Everything works as expected, until I try to apply filters to a couple of the grid fields that are dates.

The problem is that, as soon as I apply the filter, the kendo grid passes dates as DateTime to the server, however, dates in my domain model in the server are represented as DateTimeOffset, so server throws an exception saying there is no way to transform a DateTime to a DateTimeOffset.

So I'm looking for a workaround, so the client can send the filter in the correct way, so MVC builds DateTimeOffset.

Right now the client is sending the filter like this:

sort: page:1 pageSize:10 group: filter:Timestamp~gte~datetime'2015-02-10T00-00-00'

I guess instead of:Timestamp~gte~datetime'2015-02-10T00-00-00' it should be something like: Timestamp~gte~datetimeoffset'2015-02-10T00-00-00'

Thank you in advance!

1

1 Answers

0
votes

You have several options.

  • Create custom model binder/type converter on the server that will parse the incoming date into a DateTimeoOffset

  • Define your own parameterMap function inside the transport of the dataSource which will prepare the values into the right format. Or use the built-in function to handle most of the work and finally do your things

  • The top most easiest way imo is to use the data function of the update operation to send additional data. Sure you will create one more field for payload but you won't need to handle the whole parsing for rest arguments. Inside the data function you should have access to the model that is being sent to the server so you can easily add one more field there in the proper format.

If you wonder What the format for DateTimeOffset is it is something like:

yyyy-MM-ddTHH:mm:ss+00:00