1. #1
    Sencha User
    Join Date
    Jan 2010
    Posts
    28
    Vote Rating
    2
    Sejal is on a distinguished road

      1  

    Exclamation Ext get element by class name

    Ext get element by class name


    Hi

    I am new to Extjs .
    Is their any provisions to get element by class name

    Thanks

  2. #2
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,458
    Vote Rating
    20
    Animal is a jewel in the rough Animal is a jewel in the rough Animal is a jewel in the rough

      0  

    Default


    API docs? DomQuery? Ext.Element.select? Ext.Element.query?

  3. #3
    Sencha User
    Join Date
    Jan 2010
    Posts
    28
    Vote Rating
    2
    Sejal is on a distinguished road

      0  

    Default


    Thanks for timely reply

  4. #4
    Sencha User
    Join Date
    Jan 2010
    Posts
    28
    Vote Rating
    2
    Sejal is on a distinguished road

      1  

    Question Ext get element by class name

    Ext get element by class name


    hi

    In Extjs how to get Id of element which has class="foo".

    Thanks

  5. #5
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,458
    Vote Rating
    20
    Animal is a jewel in the rough Animal is a jewel in the rough Animal is a jewel in the rough

      -9  

    Default


    There might be many elements with class "foo".

    The documentation which you have of course read tells you how to find them. You did read it didn't you?

  6. #6
    Sencha User
    Join Date
    Jan 2009
    Posts
    18
    Vote Rating
    6
    MakFracta is on a distinguished road

      6  

    Default


    I'm sure that you found out how to accomplish this, but I'd like to answer so the solution gets written for feature reference and maybe save to someone a couple of hours.

    Quote Originally Posted by Sejal View Post
    hi

    In Extjs how to get Id of element which has class="foo".

    Thanks
    Element.query and Element.select can be used to this.

    PHP Code:
    var parent Ext.get("IdOfParent");
    var 
    elems parent.select("CSS_SELECTOR").elements;
    //OR
    elems parent.query("CSS_SELECTOR"); 
    elems is an array of the elements that has the CSS_SELECTOR.

    The CSS_SELECTOR is of this form:
    <tagName>.<className>

    So, if you want the elements with class="foo" you need to know wich tag they are and do this:

    PHP Code:
    var parent Ext.get("IdOfParent");
    var 
    elems parent.select("div.foo").elements;
    //OR
    elems parent.query("div.foo"); 
    I suggest that you use Visual Studio to debug the script and find out the structure of the returned objects. FireBug may help too if you don't have Visual Studio.

  7. #7
    Sencha User darthwes's Avatar
    Join Date
    Mar 2010
    Posts
    631
    Vote Rating
    -15
    darthwes can only hope to improve

      0  

    Default


    How's Visual Studio debugging Ext/Dom stuff? That's hot, I want one.
    Wes

  8. #8
    Sencha User
    Join Date
    Jul 2010
    Posts
    14
    Vote Rating
    5
    rnicholus is on a distinguished road

      5  

    Default


    (psst) the ExtJS documentation is god-awful