Hi, I'm little bit confused how can I pass modal data to my own component from parent ViewModel. For example. I have MainModel with some of data and I wanna pass one of my texts data (lets say with id:1) to my control and bind values: So how can I do this ?
Code:
Ext.define('MyTestApp.view.main.MainModel', {
extend: 'Ext.app.ViewModel',
alias: 'viewmodel.main',
data: {
name: 'MyTestApp',
custom: { name: 'test', test: { name: 'ttt'}},
texts: [
{ id: 1, text: 'test1'},
{ id: 2, text: 'test2'}
]
}
});
Ext.define('MyTestApp.view.main.MyControl', {
extend: 'Ext.container.Container',
xtype: 'MyControl',
viewModel: { type: 'MyModel' },
items: [
{
xtype: 'textfield',
fieldLabel: 'Name',
name: 'name2',
bind: '{text}'
}
]
});
Ext.define('MyTestApp.view.main.Main', {
extend: 'Ext.container.Container',
xtype: 'app-main',
viewModel: {
type: 'main'
},
afterRender: function(){
var me = this;
me.add(Ext.widget('MyControl', {
bind: {
reference: 'texts',
id: 1
}
}));
me.callParent(arguments);
}
});
Aucun commentaire:
Enregistrer un commentaire