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

Trying to get grid dataSource transport working with Web API

1 Answer 649 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 26 Apr 2016, 07:20 PM

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

 

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 28 Apr 2016, 09:36 AM
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!
 
Tags
Grid
Asked by
Robert
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or