Search code examples
jsonkendo-uikendo-gridkendo-datasource

Why doesn't Kendo Datasource transmit the "take" parameter?


This is my code:

var dataSource = new kendo.data.DataSource({
    transport: {
        read: {
            url: getMembersUrl,
            dataType: "json",
            type: "get"
        }
    },
    serverPaging: true,
    pageSize: 2,
    schema: {
        data: "Data",
        total: "Total",
    }
});

When I call read on the datasource, it doesn't send the pagesize or take (I tried both) as part of the request. I am really scratching my head on this one.


Solution

  • Your code works fine and it sends take as expected. If you run:

    var dataSource = new kendo.data.DataSource({
        transport: {
            read: {
                url: "fake",
                dataType: "json",
                type: "get"
            }
        },
        serverPaging: true,
        pageSize: 2,
        schema: {
            data: "Data",
            total: "Total",
        }
    });
    

    And define a button and a handler for triggering the read:

    <button id="read" class="k-button">Read</button>
    
    $("#read").on("click", function() {
        console.log("About to fetch data");
        dataSource.fetch();
    });
    

    As here : http://jsfiddle.net/OnaBai/34qe4oks/

    You will see in the browser console that it actually sends the request:

    enter image description here

    If you don't see the request is very likely because you are not actually reading from the DataSource (remember that the Grid DataSource is read when the Grid finishes its initialization)