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

前端 未结 3 1812
不知归路
不知归路 2021-01-12 11:10

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. Yo

相关标签:
3条回答
  • 2021-01-12 11:42

    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());
    }
    
    0 讨论(0)
  • 2021-01-12 11:58

    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);
    
    0 讨论(0)
  • 2021-01-12 12:02

    If you want the component you can use this: Ext4 and up.

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

    And you will get and array of this components

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

    0 讨论(0)
提交回复
热议问题