PDA

View Full Version : How to use Ext.ComponentQuery.query()



softball
6 Jun 2014, 12:47 AM
Dear?
there is a sample as:


<script type="text/jscript">
Ext.onReady(function() {
Ext.create('Ext.panel.Panel', {
renderTo: Ext.getBody(),
width: 400,
height: 300,
title: 'Container Panel',
layout : 'fit',
tbar : [
{xtype : 'button',text : 'Bar1', b_name : 'mybutton1' }
,{xtype : 'button',text : 'Bar2', b_name : 'mybutton2' }
]
});

//var x=Ext.ComponentQuery.query('panel toolbar button')[0];
var x=Ext.ComponentQuery.query('button[b_name="mybutton2"]');
alert(x);
});
</script>

then it show ? [object Object]

so?
1.how can know what the type or value of the return?
2.if is's an [object Object]?how to get text of tabr , or width of Panel?
3.by the way, how to set text of tabr , or width of Panel?

I;m so confused at the return of Ext,and don't know how to control it ?

THX

Scott Mildenberger
6 Jun 2014, 7:41 AM
If you look at the documentation http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.ComponentQuery-method-query you will see that it returns an array of matched components. Notice the [0] on the commented line - that was to get the first element of the array. See if this gets you farther.

softball
9 Jun 2014, 4:04 PM
Dear Scott:
Thank for your help!
I will try it!