kendo grid Uncaught TypeError: Cannot read property 'slice' of undefined

4.9k views Asked by At

Fairly new to it and trying to use paging with kendo datagrid (2.2015) Had it working without paging but paging requires the total record count be returned in the data so I changed the json result from the web service to look like this:

{
  "total":98,
  "data":[
    {"ID":164,"Name":"ABRAHAM, ALBERTA","Phone":"(111) 222-7240","Row":1},
    {"ID":173,"Name":"ABRAHAM, SERENA","Phone":"(111) 222-4067","Row":2},
    {"ID":213,"Name":"ADAMS, RONNIE","Phone":"(111) 222-0273","Row":3},
    {"ID":151,"Name":"ADDISON, RAYMOND \u0026 SUE","Phone":"111-222-6252","Row":4},
    {"ID":175,"Name":"ALEXANDER, FRANKLIN","Phone":"(111) 222-6839","Row":5}
  ]
}

page size is 5 and defined in the datasource which is here:

Search.clientDataSource = new kendo.data.DataSource({
    transport: {
        read: {
            url: myUrl,
            dataType: "json",
            type: "get"
        }
    },
    pageSize: 5,
    serverPaging: "true",
    schema: {
        total: "total",
        data: "data"
    }
});

The above as far as I can tell is 'by the book' and matches all I've read on the subject.

(The comments below may be red herring) When I had it working without paging the data was returned in an unnamed array and in the schema I used this:

schema: {
        data: function (response) {
            var obj = JSON.parse(response);
            return obj;
        }
    }

which worked but I have never seen any examples of it being done this way, I assumed it was because the array returned was unnamed, all examples showed the schema using the data: "data" where data is the name of the array. If I used this on my unnamed array I got the slice error, again I assumed this was because there was no data array to slice up.

So now that I've cleaned up all that why is my paging supported data throwing this error?

0

There are 0 answers