PDA

View Full Version : Show data from 2 different classes



vidalkk
2 Oct 2013, 4:30 AM
Hi everyone,

I need a help to "show data from two different classes on the same form.

These are the models I have:

Ext.define('TAT.model.User', {
extend: 'Ext.data.Model',
fields: ['id', 'name', 'lastname', 'account']
});

Ext.define('TAT.model.Account', {
extend: 'Ext.data.Model',
fields: ['id', 'email']
});

How can I do to show the user details and account details on the same form.

If you see below code, you will understand what I mean.

Ext.define('TAT.view.user.Edit', {
extend: 'Ext.form.Panel',
alias: 'widget.useredit',
config: {
ui: 'light',
items: [
{
xtype: 'titlebar',
docked: 'top',
title: 'Edit User'
},
{
xtype: 'textfield',
label: 'Id',
name: 'id',
hidden: true,
visible: false,
labelWidth: '50%',
required: true
},
{
xtype: 'textfield',
label: 'Name',
name: 'name',
labelWidth: '50%',
required: true
},
{
xtype: 'textfield',
label: 'Email',
name: 'account.email', <===============
labelWidth: '50%',
required: true
},
{
xtype: 'toolbar',
docked: 'bottom',
items: [{
xtype: 'button',
margin: 10,
align: 'left',
ui: 'confirm',
action: 'save',
text: 'Save'
},
{
xtype: 'spacer'
},
{
xtype: 'button',
margin: 10,
align: 'right',
ui: 'decline',
action: 'cancel',
text: 'Cancel'
}]
}]
}
});

Will appreciate if you can help me to understand how it works.

regards

Kurt001
2 Oct 2013, 5:50 AM
So - it's about saving and not reading - right?
In the onSave() method you would simply write the data from formpanel.getValues() to each of the stores.