javascript - Kendo Grid: add new row with nested object stopped working -


i'm filling kendo data grid nested json way:

https://stackoverflow.com/a/24441318/535556

everything works fine until click on "add new row" button.

then receive console error message:

"uncaught typeerror: cannot read property 'street' of undefined "

i ask how format data obtain nested json object updated data?

many advice.

when add new row without having defined schema model datasource, object being created not yet have "address" field. column "address.street" attempting "street" field "address" field of new object undefined @ point, hence error.

the bad news schema model definition doesn't lend nested types. news can define "address" field defaultvalue of {} , grid editor should happy.

$("#mygrid").kendogridex({      ...      columns: [         { field: "address.street" },         { field: "address.city" },         { field: "address.state" },          ...      ],      datasource: new kendo.data.datasourceex({          ...          schema: {             model: {                 id: "id",                 fields: {                     address: { defaultvalue: {} },                 },             },         },          ...     }),  }); 

now when add new row, bound object's "address" field {}. "street", "city" , "state" fields of course undefined, parent object "address" defined won't see , error when accessing it's fields.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -