Reputation: 1662
give a JSON data like this
{ name: { firstname: 'First Name', lastname: 'Last Name' } }
How can I load this data into ExtJS form field?
First Name: [ First Name ]
Last Name: [ Last Name ]
UPDATE:
after using this technique I arrived at second challenge when post my change back to the server Ext generate json in this format
{ "firstname": "New first name", "lastname": "New last name"}
// instead of
{ "name": { "firstname": "...", "lastname": "..."} }
is it expected behavior or is there anyway I can tell Ext to serialize the object back to the nest form, regards.
P.S: my Edit.js taking from Ext MVC application guide http://localhost/extjs/docs/index.html#!/guide/application_architecture
Upvotes: 1
Views: 1470
Reputation: 13917
I suggest you map this into two separate fields in your model definition:
Ext.define("Person", {
extend: "Ext.data.Model",
fields: [
{name: "firstname", mapping: "name.firstname"},
{name: "lastname", mapping: "name.lastname"}
]
});
Upvotes: 3