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

How to prevent odata type datasource from encoding the '$'

3 Answers 180 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Bob
Top achievements
Rank 1
Bob asked on 16 Jun 2015, 09:06 PM

I am using a grid with an odata datasource.

 When I enable serverSorting and serverFiltering it isn't working. For some reason the endpoint (Azure Mobile Service .net Backend) returns a bad request when the $'s are encoded.

For example, here is a request with the $ encoded:

GET /tables/members?%24inlinecount=allpages&%24top=50&%24orderby=memberNumber

For some reason, that returns bad requst: message=The query specified in the URI is not valid. Could not find a property named 'memberNumber' on type 'myapi.DataObjects.Members'.

But, if I take the same request from fillder into the composer and change it to:

GET /tables/members?%24inlinecount=allpages&%24top=50&$orderby=memberNumber 

I get a 200 response and the grid binds to the data no problem.

I tried to set processData to false, but that just sends like [object:object] on the Url.

Any idea how I can prevent the $'s from being encoded? Or, how I can turn them back to $, perhaps in the beforeRequest method?

 

 

 

3 Answers, 1 is accepted

Sort by
0
Accepted
Kiril Nikolov
Telerik team
answered on 18 Jun 2015, 02:45 PM
Hi,

By default the request is encoded, before it is send to the server, and this is fine, and you can see the same in our online demos as well:

http://demos.telerik.com/kendo-ui/grid/remote-data-binding

So I suppose it is some server configuration that is causing the issue, can you please take a look in that direction? It will also be helpful if you send us the Grid dataSource configuration. 

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Bob
Top achievements
Rank 1
answered on 18 Jun 2015, 05:08 PM

The backed is a .Net backend Azure Mobile Service. So, the mobile service packages pretty much control the odata implementaiton. I assume it is the same one that you get with Web API. 

I am using the anguar grid directive, I assume that doesn't change anything. The datasource is part of the gridOptions object I create in the controller:

 

dataSource: {
    type: 'odata',
    transport: {
        read: {
            url: constants.apiUrl + '/members',
            dataType: 'json',
            beforeSend: function (req) {
                req.setRequestHeader('X-ZUMO-AUTH', sessionStorage['X_ZUMO_AUTH']);
            }
        }
    },
    schema: {
        data: function (data) {
            return data.results;
        },
        total: function (data) {
            return data.count;
        },
        model: {
            fields: {
                memberNumber: { type: "string" },
                lastName: { type: "string" },
                firstName: { type: "string" },
                dateOfExpiry: { type: "date" }
            }
        }
    }
}

 

 

0
Bob
Top achievements
Rank 1
answered on 18 Jun 2015, 05:38 PM

OK... it looks like a serializer case issue. 

If the $ on filter is encoded it works when I use MemberNumber as the property name in the odata request.

However, without it encoded it works with both memberNumber and MemberNumber.

So, there must be something in the odata parser that is different if the $ is encoded vs not encoded.

I guess off the microsoft I go to figure out how to fix this.

 

 

 

Tags
Data Source
Asked by
Bob
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Bob
Top achievements
Rank 1
Share this question
or