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

Kendo UI Grid get Cannot read property 'data' of undefined on some cases

1 Answer 1471 Views
Grid
This is a migrated thread and some comments may be shown as answers.
toga
Top achievements
Rank 1
toga asked on 03 Feb 2016, 05:16 PM

Hi I have a kendo Grid that is bound to this kendo.Data.DataSource object:

 

var viewDataSource = new kendo.data.DataSource({
transport:{

read: { url: "xxx", datatype: "json", type: "GET"},
update: {url: "YYY",datatype: "json",type: "POST"},
parameterMap: function (options, operation) {           if (operation !== "read" && options) {return { models: kendo.stringify(options) };}}},
schema: {model: {
id: "divisionID",
fields: { divisionID: {type: 'number'},name: { type: 'string' },available: { type: 'boolean'},countryISOCode: { type: 'string'}}
}}});

 

The data source is bound to kendo grid 

$("#Grid").kendoGrid({
dataSource: viewDataSource,
editable: "inline",
editable: true,
scrollable: true,
toolbar: ["save", "cancel"],
sortable: {mode: "single",allowUnsort: true},
columns: [
                      { field: 'name', title: 'Division Name' },
                      { field: 'available', title: 'Available'},
                      { field: 'countryISOCode', title: 'Negotiation Country'}
  ]

}

 I follow the standard practice to define the data source and when I head save it give me an error " Cannot read property 'data' of undefined".

 

I am able to get around this problem by changing the definition of my model for the ID field from 'number' to 'string', if I do that then the Grid save will actually hit my POST url address.

 

I want to know if Kendo Grid suppose to support "Number" data type for ID or not ? Why do I care? Because on database we usually auto increment column and that tends to be number. My workaround would be converting this value from number to string on the repository layer. Its just bizarre.

 

Thanks!

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 08 Feb 2016, 07:45 AM

Hello toga,

 

Indeed, the number type is supported and it is actually recommended when used as ID field. Thus, there should be other cause for the error you have described. However, I'm not able to tell from the given description. Thus, you should consider providing a small runnable sample which demonstrate the issue you are facing.

 

Regards,
Rosen
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
toga
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or