I am wondering if there is a way to access components in Sencha Touch and ExtJS without component query. And without building object structure by myself.
If I create a view like this:
Ext.Viewport.add({
xtype: 'panel',
itemId: 'panel1',
modal: true,
centered: true,
items: [{
xtype: 'button',
itemId: 'btn1',
text: 'One'
}, {
xtype: 'button',
itemId: 'btn2',
text: 'Two'
}]
});
And to get btn2 I would rather use Ext.Viewport.panel1.btn2
over Ext.Viewport.down('#panel1').down('#btn1')
.
Is is possible to do this manually. But it's not pretty.
Ext.Viewport.panel1 = Ext.Viewport.down('#panel1');
Ext.Viewport.panel1.btn1 = Ext.Viewport.panel1.down('#btn1');
Ext.Viewport.panel1.btn2 = Ext.Viewport.panel1.down('#btn2');
ItemId needs to be unique between siblings it is the perfect property to use for this. Is there already an automated way that I can use? I did not find it in the documentation. Or should I just write a simple script that creates this?