Kendo grid filtering by DateTime

2 posts, 0 answers
  1. Matt
    Matt avatar
    1 posts
    Member since:
    Jul 2010

    Posted 29 Jul Link to this post

     I have to issues with Kendo grid filtering. I'm using Kendo 2015.2.902 version and installed Kendo.DynamicLinq

    First issue is related on parameters which I received from Kendo grid. Filter data are deserialized into Kendo Filter class in my controller action. After deseralization Value property became array of strings and ToDataSourceResult method throws exception: "Operator '>' incompatible with operand types 'DateTimeOffset' and 'String[]". It was happened for any filtering. I temporarily fixed by removing array and injecting string.


    Second issue happened after I "fixed" first one. Method ToDataSourceResult throws exception: "Operator '>' incompatible with operand types 'DateTimeOffset' and 'DateTimeOffset' ".

    I followed and implemented my controller action as explained. Also I implemented JsonNetValueProviderFactory as described here

    Do you know how can I fix that and is it because of different Kendo versions?

  2. Stefan
    Stefan avatar
    200 posts

    Posted 02 Aug Link to this post

    Hello Matt,

    I think the issue lies in the Filter.cs file and the way the dates are serialised. There is a thread in Stack Overflow addressing the same error that may be a good starting point:

    As one of our DevCraft Complete clients, you may take advantage of the way that the data is filtered and parsed server-side with the Kendo.Mvc.Extensions namespace, which is part of the Kendo.Mvc.dll.

    The Kendo.Mvc.Extensions namespace provides the DataSourceRequest object. The DataSourceRequest object needs to be decorated with the [DataSourceRequest] attribute to transport the Kendo UI Grid request information to the server in the correct format. Using this approach the data is returned to the Kendo UI Grid as correctly parsed JSON (grouped, filtered and sorted). 

    Instead of  public async Task<Kendo.DynamicLinq.DataSourceResult> Handle(Query query)
    use an ActionResult in combination with DаtaSourceRequest/ToDataSourceResult. The server controller will look similar to the code below:

    public ActionResult Handle([DataSourceRequest] DataSourceRequest request)
      var ordenes = _dbContext.OrdenesDist
      return this.Json(ordenes.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);

    More information on using the ToDataSourceResult() extension method is avaialble in the following article:

    Please have in mind that Kendo.DynamicLinq is an open source project, and it is supported only by the community.

    The Kendo UI Team will support you in finding the best solution for your scenario, however, if you wish to handle the server-side without the use of the Kendo.Mvc.Extensions, I can only guide you as far as the Kendo UI Grid request format is concerned as well as the server response format needed for the Kendo UI Grid binding to work.

    Finally, if you decide to keep the Kendo.DynamicLinq, I would recommend using the Kendo UI DataSource transport parameterMap property to its full potential. The Kendo UI Data Source parameterMap is executed before each request and can be used to modify the data in the format expected by the server. Documentation is available at:

    Telerik by Progress
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
Back to Top