ASP.NET MVC 4 New Web API and oData

9 posts, 0 answers
  1. Dave Whiting
    Dave Whiting avatar
    41 posts
    Member since:
    Jan 2007

    Posted 21 Feb 2012 Link to this post

    Hi,

    With the recent release of ASP.NET Web API I was hoping that KendoUI would be a a perfect match and allow the wiring up of the Kendo grid to the new APIControllers. 

    I can see the correct oData API calls being made by the Grid and the .NET Web API controller responds with the correct number of json records and the correct page but this is never rendered in the grid. Do you know if the new ASP.NET Web API oData responses work?

    Hope you can help or show an example of this working because if it does its going be a really elegant and simple implementation.

    Example can be seen here : http://www.asp.net/web-api/overview/web-api-routing-and-actions/video-paging-and-querying 


    Thanks
    Mark
  2. Dave Whiting
    Dave Whiting avatar
    41 posts
    Member since:
    Jan 2007

    Posted 21 Feb 2012 Link to this post

    Having researched this further it would appear that the ASP.NET Web API provides the ability for basic oData Query Syntax ($top, $skip etc.) to be used against the API but it only returns JSON and no additional oData information.

    I'll use a standard JSON datasource and manage the paging queries within the API myself.

    Thanks
    Mark
  3. Kendo UI is VS 2017 Ready
  4. John
    John avatar
    1 posts
    Member since:
    Oct 2012

    Posted 29 Feb 2012 Link to this post

    Does Kendo UI work with asp.net web api with OData?  I cant get it to render any results..  Anyone have success with these two?
  5. Jean-Pascal van der Endt
    Jean-Pascal van der Endt avatar
    48 posts
    Member since:
    Jul 2010

    Posted 06 Mar 2012 Link to this post

    I'd be interested to see an example of this as well. More precisely: consuming an ASP.NET Web API in a grid, asking the server to provide paged results. I'm guessing the latter should be done using oData query parameters, as Mark said previously.

    The Kendo UI Datasource documentation seems rather concise about these things. I hope that plenty of examples will become available soon. Thanks guys.

    EDIT: Just to clarify some more. Obviously a standard ASP.NET Web API can respond to oData parameters, but typically the results will be returned as straightforward JSON. Of course, the grid needs something else to enable paging, and it expects this format:

    jQuery17108768166687720499_1331051022528(
    {
        "d" :
        {
            "results" : [ { array with my objects here} ],
            "__count" : "830"
         }
    })

    Has anyone succeeded in getting an ASP.NET Web API to return these results?
  6. Vesselin Obreshkov
    Vesselin Obreshkov avatar
    81 posts
    Member since:
    Jan 2010

    Posted 06 Mar 2012 Link to this post

    The Kendo DataSource doesn't seem to work with the Web API that ships with MVC 4 out of the box. I too started playing around with the new bits recently and was just coming here to look for a solution to the exact same problem - no data showing in my grid (even though I can see the correct data coming in using the Chrome Dev tools).

    If you change the dataSource type to 'json' it will show you the results but obviously nothing else will work.

    Hope we see an update soon that fixes this and makes the DataSource work with the new Web API out of the box.
  7. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 07 Mar 2012 Link to this post

    Hi,

    Please my reply in this thread.

    Kind regards,
    Atanas Korchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  8. Jesse
    Jesse avatar
    12 posts
    Member since:
    Jul 2012

    Posted 29 Jun 2012 Link to this post

    Not sure if this has been solved yet. I've had success linking up the autocomplete and ListView with web api. Initially I as well couldn't get any results. In order to get it working I was required to create a Jsonp media Type formatter and change the dataType to jsonp. The paging is working in the ListView control, but I can not speak for the grid as I have not tried that yet.

    So my autocomplete looks like so

      $('#autocompleteSearchInput').kendoAutoComplete({
                    minLength:1,
                    dataTextField:dataText,
                    dataSource:new kendo.data.DataSource({
                        pageSize:100,
                        transport:{
                            read:{
                                url:"http://localhost:8181/api/values
                                dataType:"jsonp"
                            }
                        }
                    })
                });

    The implementation for the jsonp media type formatter can be found here. I found the last post to be the easiest to implement
    http://stackoverflow.com/questions/9421312/jsonp-with-asp-net-web-api 

  9. Oscar
    Oscar avatar
    3 posts
    Member since:
    Aug 2011

    Posted 05 Aug 2012 Link to this post

    Hello

    I spent 3 days trying to bind the amazing KendoUI MVC wrapper to WebAPI Controllers.  after many hours of Chrome dev tools exterminating the data calls  I never got the grid to show data.  then i found this great tutorial
    http://www.kendoui.com/blogs/teamblog/posts/12-07-26/hello_kendo_ui_part_2_ndash_grid_crud.aspx

    Unfortunately after using the techniques presented on the tutorial,  I was still not able to get data into the KendoUI Grid (with the wrapper).

    Is good to know that I am not the only one having issues with this feature.

    Regards
  10. Burke
    Burke avatar
    41 posts
    Member since:
    Jun 2009

    Posted 20 Nov 2012 Link to this post

    Oscar

    I am going to be covering this shortly.  In the meantime, please check this code sample here for a grid bound to WebAPI using the MVC Wrappers.

    http://www.kendoui.com/code-library/mvc/grid/binding-to-a-web-apicontroller.aspx
Back to Top
Kendo UI is VS 2017 Ready