Hi,
I have this .JSON file.
id:1,
phone:
{
characteristic: 21,
number_part1: 21,
number_part2: 54
}
I have a model customer:
Code:
Ext.define('MyApp.model.customer', {
extend: 'Ext.data.Model',
uses: [
'MyApp.model.phone'
],
fields: [
{
name: 'id',
{
name: 'phone'
}
],
hasOne: {
model: 'MyApp.model.phone'
}
});
and a model phone:
Code:
Ext.define('MyApp.model.phone', {
extend: 'Ext.data.Model',
fields: [
{
name: 'characteristic'
},
{
name: 'number_part1'
},
{
name: 'number_part2'
}
]
});
I created a form with 4 text fields. I am trying to fill them with the values from the JSON. Using this code at the launch:
var customers = Ext.getStore('s_customers');
customers.filter(1, queryString.cid);
var customer = customers.getAt(0);
Ext.getCmp('personaldetailsForm').getForm().loadRecord(customer);
alert(customer.get('phone').characteristic); //This correctly shows the alert with the value 21
The problem is that only the text field with id is correctly filled. The others won't work. How do I have to bind the other text fields with data from the model? Is ok to use "name: 'phone.characteristic'"? The relationship that I've created is wrong?
{
xtype: 'textfield',
flex: 1,
margin: '0 10 0 0',
name: 'phone.characteristic'
}
Thanks in advance.