Trying to get grid dataSource transport working with Web API

2 posts, 0 answers
  1. Robert
    Robert avatar
    27 posts
    Member since:
    Nov 2015

    Posted 26 Apr 2016 Link to this post

    Going a little insane here, trying to bake my own ajax call to reach web api controller method.

    Amongst many other efforts:

    transport: {
                    read: function (options) {
                        $.ajax({
                            url: "api/FlfProd/GetSchedList/",
                            data: {
                                data: JSON.stringify(options)
                            },
                            type: 'GET',
                            dataType: 'json',
                            contentType: 'application/json; charset=utf-8',
                            success: function (data, textStatus, xhr) {
                                //debugger;
                            },
                            error: function (xhr, textStatus, errorThrown) {
                                console.log('Error in Operation');
                            }
                        });
                    },
                    parameterMap: function (options, operation) {
                        if (operation.toString().toLowerCase() === 'read') {
                            return options;
                        }
                    }

     

    This reaches the web api, but only if I specify nothing in the controller method signature (i.e. no {} parameter in the Route).

    However, when it reaches the server, the parameters are all locked in a single string such as : [0]: {[data, {"data":{"take":10,"skip":0,"page":1,"pageSize":10}}]}.

    Using ordinary web service no such difficulty exists, but I want to complete moving to Web API and I frankly hate everything about MVC. Most examples such as Telerik's GridWebApiCrud are ancient and involve MVC. Plus they don't work anymore as far as I can tell.

    Really pulling my hair out on this one. Is anybody out there using $.ajax methods successfully with Web API controllers? At the back end I want to use Kendo DynamicLinq as I always have, but I need to be able to bake in the skip, take, sort and filter parameters and I just can't find a way to do it. Filling a grid from Web API that doesn't do any server-side paging is not difficult at all.

    Bob Graham

     

  2. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2895 posts

    Posted 28 Apr 2016 Link to this post

    Hello Robert,

    We have an example which demonstrates how to bind Kendo Grid to WebAPI backend.


    Regards,
    Alexander Valchev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top