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

Using DataSourceResult with Kendo UI Grid

1 Answer 275 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nse
Top achievements
Rank 1
Nse asked on 28 Jul 2016, 12:28 AM

I'm attempting to use the Kendo UI DataSourceResult with my Kendo UI Grid using the code found here.

I'm not using ASP.NET MVC, but rather VB.NET with ASP.NET Web Forms and Web API on the backend. I understand how the DataSourceResult object works, however I'm having trouble figuring out the lines of code at lines 19-21. Here is the code in C#:

DataSourceRequest request = JsonConvert.DeserializeObject<DataSourceRequest>(
// The request is in the format GET api/products?{take:10,skip:0} and ParseQueryString treats it as a key without value
requestMessage.RequestUri.ParseQueryString().GetKey(0));

and the code equivalent in VB.NET:

' The request is in the format GET api/products?{take:10,skip:0} and ParseQueryString treats it as a key without value
Dim request As DataSourceRequest = JsonConvert.DeserializeObject(Of DataSourceRequest)(requestMessage.RequestUri.ParseQueryString().GetKey(0))

Whenever I execute the code I get a System.ArgumentOutOfRangeException. Debugging the code the requestMessage.RequestUri.ParseQueryString().GetKey(0) returns "take" which is what I'd expect, as that's the key of the first parameter. Using Fiddle I can see that the Grid sends the RequestUri of "http://localhost:53786/api/object/4?take=20&skip=0&page=1&pageSize=20". What do I need to do to get the code working correctly with my Grid and API?

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 01 Aug 2016, 07:26 AM

Hello Nse,

 

In the sample you have referred to, the data send by the DataSource is serialized into a single parameter as JSON string. This is why it is deserialized in the way you have described. Therefore, in order to use the approach in question, you will need to make sure that the parameterMap is set to stringify the send data.

 

Regards,
Rosen
Telerik by Progress
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
Tags
Grid
Asked by
Nse
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or