Amit Jog
Amit Jog

Reputation: 111

Kendo Grid fetching Remote Data using POST

I am having a Kendo UI Grid, which fetches data from Remote URL, However the type used is POST instead of GET (This is a requirement).

I am using HTML, JQUery, WEB API stack

data to send is basically a form post values converted to json object

    var oDs = new kendo.data.DataSource({
    type: "odata",
                   transport: {
                       read: ajaxUrl,
                       type: "POST",
                       dataType: "jsonp",
                       contentType: "application/json; charset=utf-8",
                       data: JSON.stringify(dataToSend)
                   },
                   schema: {
                       model: {
                           id: "userid",
                           fields: {
                               userid: { type: "string" },
                               username: { type: "string" },
                               age: { type: "string" },
                               email: { type: "string" },
                               status: { type: "string" }
                           }
                       }
                   },
                   pageSize: 20,
                   serverPaging: true,
                   serverSorting: true,
                   serverFiltering: true
               });
$("#gridResult").kendoGrid({
                    dataSource: oDs,
                    total: oDs.view().length,
                columns: [
                        { field: "userid", title: "User ID" },
                        { field: "username", title: "User Name" },
                        { field: "age", title: "Age" },
                        { field: "email", title: "Email" },
                        { field: "status", title: "Status" },
                    ],
                    noRecords: {
                        template: "No results found."
                    },
                }); 

I am getting "Failed to load resource: the server responded with a status of 405 (Method Not Allowed)" error. The Web API Controller Method is developed using HTTPPOST as HTTP Verb. If I fetch the data separately using ajax call and assign that data to the kendo ui grid data then It works. The problem here is then it is everything as Client side. There are records running into 10000+ and it is bogging the system down. I want Paging and filter to be server side with data being fetched with POST instead of GET. Please guide me. Your help is appreciated in advanced.

Upvotes: 0

Views: 3337

Answers (1)

dimodi
dimodi

Reputation: 4139

The DataSource configuration has a type:"odata" setting applied. This enforces a GET request type. Please remove the dataSource type to achieve the desired result. You may need to set schema.data and schema.total, depending on the exact server response structure.

http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-schema.data

http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-schema.total

Upvotes: 1

Related Questions