KendoDatasource request with datatype:webapi

3 posts, 0 answers
  1. sema
    sema avatar
    7 posts
    Member since:
    Jun 2015

    Posted 09 Nov 2017 Link to this post

    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. sema
    sema avatar
    7 posts
    Member since:
    Jun 2015

    Posted 09 Nov 2017 Link to this post

    Sample ss
  3. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    2153 posts

    Posted 10 Nov 2017 Link to this post

    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.
Back to Top