How to use jQuery $ (". Something") to select a class in ExtJS?

I am looking for an equivalent method to select a class element like this $ (". ClassName") in JQuery for ExtJS.

I understand that Ext.get () only accepts an identifier. Your help will be greatly appreciated.

Cheers, Mickey

Edited by:

Let me explain further. I want to do something like Ext.get after I have done "select". For example:

$(".className").css("width"); 

I understand that Ext.Element has a getWidth () method. I was hoping I could do something like ...

 Ext.select(".className").getWidth(); // it just return me [Object object] 

Maybe I do not understand this well.

Thank you, my dear.

+7
extjs
source share
3 answers

I think you are looking for:

 Ext.query(".className"); 

This method allows you to retrieve elements by a given query string, as jQuery does.

EDIT

 var els=Ext.query(".className"), ret=[]; for(var i=0; i<els.length; i++) { ret.push(els[i].getWidth()); } 
+11
source share

Yes, Ext.select () is what you want. It returns a CompositeElement (the same API as a single element, but contains an internal collection of all selected elements). You can do this to see the width of each element:

 Ext.select('.className').each(function(el){ console.log(el.getWidth()); }); 

The way you called it is more useful for working with elements in some way, for example:

 Ext.select('.className').setWidth(100); 
+13
source share

If you want to use the component, you can use this: Ext4 and higher.

 Ext.ComponentQuery.query('panel[cls=myCls]'); 

And you get an array of these components

source: http://docs.sencha.com/ext-js/4-1/#!/api/Ext.ComponentQuery

+3
source share

All Articles