Using DataSourceResult with Kendo UI Grid

2 posts, 0 answers
  1. Nse
    Nse avatar
    12 posts
    Member since:
    Feb 2016

    Posted 27 Jul Link to this post

    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?

  2. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 01 Aug Link to this post

    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.
     
  3. Kendo UI is VS 2017 Ready
Back to Top