Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Jquery $(".something") to select a class in ExtJS?

Tags:

extjs

I'm looking for an equivalent method to select a class element like this $(".className") in Jquery for ExtJS.

I understand that Ext.get() only takes in an id. Your help will be very much appreciated.

Cheers, Mickey

Edited:

Let me explain further. I want to be able to do something like Ext.get after I did a "select". For example:

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

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

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

Maybe i don't understand it well.

Thanks a mil.

like image 385
Mickey Cheong Avatar asked Jan 27 '10 13:01

Mickey Cheong


2 Answers

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

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

The way you called it is more useful for operating on the elements in some way, e.g.:

Ext.select('.className').setWidth(100);
like image 99
Brian Moeskau Avatar answered Sep 28 '22 00:09

Brian Moeskau


I think you are looking for:

Ext.query(".className");

This method allows you to get elements by the given query string like jQuery does.

EDIT

var els=Ext.query(".className"), ret=[];
for(var i=0; i<els.length; i++)
{
    ret.push(els[i].getWidth());
}
like image 32
mck89 Avatar answered Sep 28 '22 01:09

mck89