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

KendoDatasource request with datatype:webapi

2 Answers 224 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Sema
Top achievements
Rank 1
Sema asked on 09 Nov 2017, 08:20 AM

I am trying to use KendoDataSource with datatype webapi.

Create request post DataSourceRequest and viewmodel to server but datasource request property not bind, viewmodel data passed
I can normally move the DataSourceRequest and viewmodel like this to the ajax call with type: "aspnetmvc-ajax" but when type:"webapi" not bind request property bind

Thanks a lot.

 

<a href="https://ibb.co/j5FT5w" rel="nofollow noreferrer">SS</a>

var dataSourceExperiences  = new kendo.data.DataSource({
            type: "webapi",              
            serverPaging: true,
            serverFiltering: true,
            serverSorting: true,
            page: 1,
            pageSize: 7,
            schema: {
                data: "Data",
                total: "Total",
                model: {
                    id: "Id",
                    fields: {
                        CompanyName: { type: "string" },
                        Description: { type: "string" },
                        WorkTypeName: { type: "string" },
                        PositionHeldId: { type: "number" },
                        PositionHeldName: { type: "string" },
                        WorkTypeId: { type: "number" },
                        StartDate: { type: "date" },
                        EndDate: { type: "date" },
                        Explanation: { type: "string" },
                        CountryId: { type: "number" },
                        CountryName: { type: "string" },
                        CityId: { type: "number" },
                        CityName: { type: "string" },
                        EmployeeId: { type: "number" },
                    }
                }
            },
            transport: {
                read: {
                    url: baseApiUrl + 'api/Experience/ReadExperience',                   
                    type: "GET",
                    beforeSend: function (req) {
                        req.setRequestHeader("Authorization", "Bearer " + '@Model');
                    },
                },
                create: {
                    url: baseApiUrl + "api/Experience/CreateExperience",
                    type: "GET",                     
                    beforeSend: function (req) {
                        req.setRequestHeader("Authorization", "Bearer " + '@Model');
                    },
                }                   
            },
       });
 var dataGrid = $("#dataGrid").kendoGrid({
        dataSource: dataSourceExperiences,
        autoBind: false,
        sortable: true,
        scrollable: true,
        columns: [
            {
            field: "PositionHeldName",
            title:"PositionHeldName",
            filterable: true
            },
            {
                field: "CompanyName",
                title: "CompanyName"
            },
            {
                field: "WorkTypeName",
                title: "WorkTypeName"
            },
            {
                field: "CountryName",
                title: "CountryName"
            },
            {
                field: "CityName",
                title: "CityName"
            },
         ],
        selectable: "row"
    }).data("kendoGrid");

2 Answers, 1 is accepted

Sort by
0
Sema
Top achievements
Rank 1
answered on 09 Nov 2017, 08:22 AM
Sample ss
0
Konstantin Dikov
Telerik team
answered on 10 Nov 2017, 09:38 AM
Hi Sema,

For others convenience, I will post the link to the HowTo example that I have shared in the ticket:

Best Regards,
Konstantin Dikov
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Data Source
Asked by
Sema
Top achievements
Rank 1
Answers by
Sema
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Share this question
or