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

'Invalid slice method' error in kendo.all.js

2 Answers 55 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Al
Top achievements
Rank 1
Iron
Iron
Veteran
Al asked on 28 Nov 2018, 09:45 AM

I get the error attached in kendo.all.js and the error event doesn't even fire,what am i doing wrong?

 

var dataSource = new kendo.data.DataSource({
    transport: {
        read: {
            url: "helper.php?action=data",
            dataType: "json"
        }
    },
    schema: {
        data: "zzz"
    }
});
 
dataSource.bind("error", function(e) {
    alert('error');
});
 
dataSource.fetch(function() {
    alert('fetch complete');
});

the helper returns this json:

 

{"zzz":{"items":[{"type":"button","text":"Test"}]}}


I have tried with and without the schema set as per suggestions seen on the web - please help?

2 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 28 Nov 2018, 12:03 PM
Hi Al,

The following article explains the most common reason for this problem: https://docs.telerik.com/kendo-ui/troubleshoot/troubleshooting-common-issues#widget-throws-the-eslice-is-not-a-function-error. Said shorty, the object that holds the data must be an array, and in the provided example its an object literal instead of an array.

You'd need something like this:

{"zzz":["items":[{"type":"button","text":"Test"}]]}


Regards,
Marin Bratanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Al
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 28 Nov 2018, 12:26 PM

Thanks Marin, I found the following to work:

{"zzz":[{"items":[{"type":"button","text":"Test"}]}]}
Tags
Data Source
Asked by
Al
Top achievements
Rank 1
Iron
Iron
Veteran
Answers by
Marin Bratanov
Telerik team
Al
Top achievements
Rank 1
Iron
Iron
Veteran
Share this question
or