How else could i access this class, i need my dynamic ID for something else… Normally if this was // var something = Ext.create(… i would do something.getForm().load…)???
Ext.define('app.winKontakt',{
extend:'Ext.form.Panel',
closable:true,
id:"myId", <------------------------------------------ID
waitMsgTarget: true,
border:false,
defaults: {
anchor: '30%',
padding:10
},
reader : Ext.create('Ext.data.reader.Json', {
model: 'app.contact',
record : 'contact',
successProperty: '@success'
}),
...
buttons: [{
text: 'Load',
handler: function(){
winId = Ext.getCmp("myId"); <--------------GET
winId.getForm().load({ <---------------EXECUTE
url: 'app/new.json',
waitMsg: 'Loading...',
method:"GET"
});
}
...
I just started with ExtJS, so there may be a better practices.
You can assign an itemId to the component and use ComponentQuery to get it.
Another options is to use the up() function from AbstractComponent to get the enclosing form.
I normally don’t put any code in the view definition, instead I use the control() function within a Ext.app.Controller to have proper MVC separation:
In this small example it looks quite like some overhead, but with a larger codebase the control function is quite handy to understand the events sent from a complex view to the controller.