PDA

View Full Version : Alternatives Ext.getCmp() is Ext.ComponentQuery, but how use it right?



kramal
1 Feb 2013, 12:17 AM
Hello Friends!

I have problem with Ext.ComponentQuery.query().

Several days ago I have finished my first application. But there I used Ext.getCmp() to get references.
But I have read article where was explained why Ext.getCmp() is bad style. now I want to understand how works Ext.Component.Query.query() method. Here some testing example:41614

Ext.onReady(
function(){

Ext.create('Ext.Panel',{
renderTo:Ext.getBody(),
title:'121212',
width: 500,
height: 200,
layout:'column',
items:[
{
xtype:'button',
text:'Button',
handler:function()
{
var btn=Ext.ComponentQuery.query('textfield');
alert('some');
btn[0].hide();
btn[0].setRawValue('jjjj');
}
},
{
xtype:'textfield',
fieldValue:'text'
}
]
});
});

I cant get results how i expected

friend
1 Feb 2013, 6:40 AM
You could change your button handler to do something like this:



handler:function(){
this.up('panel').down('textfield').setValue('jjjj');
}


Keep in mind that it's also perfectly fine to use itemId: 'someValue' on child components in a container. This just gives them a unique name within the parent container against which you can query:

kramal
1 Feb 2013, 9:56 AM
Thank you ! I understand it:)