- Published on
Kendo Grid: cannot read property data of undefined
- Authors
- Name
- Steve McNiven
- @stevemcniven
I’m posting this because I wasn’t able to find the answer by googling. It seems it’s a fairly generic error that can mean a bunch of things, but this solved it for me.
Scenario
Kendo Grid, bound to remote datasource trying to enable CRUD.
When does it happen: Edit->Update
Error
Uncaught TypeError: Cannot read property 'data' of undefined
at init.setup (Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=ctl16_TSM&compress=2&_TSM_CombinedScripts_=%3b%3bT…:28)
at init.create (Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=ctl16_TSM&compress=2&_TSM_CombinedScripts_=%3b%3bT…:28)
at Object.<anonymous> (Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=ctl16_TSM&compress=2&_TSM_CombinedScripts_=%3b%3bT…:28)
at Function.Deferred (ScriptResource.axd?d=OfhH2xFGzDSYc0LaAaaOD08yz4IMU64J5fBMHu0-Lz13cohNhivVQFfhqawUAIMaGh_RVi-P3FmRXW…:2)
at init._promise (Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=ctl16_TSM&compress=2&_TSM_CombinedScripts_=%3b%3bT…:28)
at init._send (Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=ctl16_TSM&compress=2&_TSM_CombinedScripts_=%3b%3bT…:28)
at init.sync (Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=ctl16_TSM&compress=2&_TSM_CombinedScripts_=%3b%3bT…:28)
at init.saveRow (Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=ctl16_TSM&compress=2&_TSM_CombinedScripts_=%3b%3bT…:50)
at init._editUpdateClick (Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=ctl16_TSM&compress=2&_TSM_CombinedScripts_=%3b%3bT…:50)
at HTMLAnchorElement.d (ScriptResource.axd?d=OfhH2xFGzDSYc0LaAaaOD08yz4IMU64J5fBMHu0-Lz13cohNhivVQFfhqawUAIMaGh_RVi-P3FmRXW…:2)
Resolution
Was quite simple actually, my Datasource schema didn’t define the “id” property
schema: {
model: {
id: "UserId",
otherprop: "something"
}
}
Note to kendo guys
Would be nicer if the error messages were more specific, or I guess would be nicer if there were error messages not just js crashes. This error could really be a bunch of things.