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

Problem when using DataSource filtering with OData and DateTimeOffset

2 Answers 155 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Holger
Top achievements
Rank 1
Holger asked on 18 Mar 2014, 12:23 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 20 Mar 2014, 01:55 PM
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!
 
0
Holger
Top achievements
Rank 1
answered on 21 Mar 2014, 11:10 AM
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
Tags
Data Source
Asked by
Holger
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Holger
Top achievements
Rank 1
Share this question
or