Problem when using DataSource filtering with OData and DateTimeOffset

3 posts, 1 answers
  1. Holger
    Holger avatar
    77 posts
    Member since:
    Nov 2012

    Posted 18 Mar 2014 Link to this post

    An OData error occurs when using DataSource filtering with OData and DateTimeOffset. The error is caused due to the following statement

    format = "datetime'{1:yyyy-MM-ddTHH:mm:ss}'";

    in the function toOdataFilter in the kendo.data.odata.js file where date values are formatted as datetime.

    When I try to overwrite the default behavior in parameterMap

    parameterMap: function (data, type) {
        var result = kendo.data.transports.odata.parameterMap(data, type);
     
        if (result.$filter) {
            result.$filter = result.$filter.replace('datetime', 'datetimeoffset');
        }
     
        return result;
    }

    it results in HTTP Status 400. Whereas when I overwrite the 'datetime' quote in the original source file with 'datetimeoffset' everything works fine.

    Is there any workarround available?

    Thanks
    Holger

  2. Answer
    Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 20 Mar 2014 Link to this post

    Hello Holger,

    The approach with the parameterMap function looks correct and at least when I tested it locally it was working as expected. Do you have other filters for properties of type DateTime in the filter? If yes, then you should use a more specific selector for the replace. If there are not any other filters then could you provide a sample project that demonstrates the problem?

    Regards,
    Daniel
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
  4. Holger
    Holger avatar
    77 posts
    Member since:
    Nov 2012

    Posted 21 Mar 2014 in reply to Daniel Link to this post

    Hello Daniel,

    While preparing a sample project I was able to fix the problem. I forgot to remove the '$format' parameter - which is not supported by ASP.NET Web Api - from the set of parameters.

    Sorry for wasting your time.

    Thanks,
    Holger
Back to Top