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,507
    Vote Rating
    56
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      -5  

    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,507
    Vote Rating
    56
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      -19  

    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
    10
    MakFracta will become famous soon enough

      10  

    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
    633
    Vote Rating
    -11
    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
    7
    rnicholus is on a distinguished road

      7  

    Default


    (psst) the ExtJS documentation is god-awful

  9. #9
    Sencha User
    Join Date
    Sep 2013
    Posts
    1
    Vote Rating
    3
    RolanR is on a distinguished road

      3  

    Default


    Quote Originally Posted by Animal View Post
    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?
    Look, you really aren't helping.
    This thread is the first result for the Google search "extjs get element by class", and I'd expect to find an answer here instead of your haughtiness.

    You could at the very least link the relevant documentation entries.

  10. #10
    Sencha User
    Join Date
    Jan 2011
    Posts
    546
    Vote Rating
    52
    willigogs is a jewel in the rough willigogs is a jewel in the rough willigogs is a jewel in the rough

      3  

    Default


    Quote Originally Posted by RolanR View Post
    You could at the very least link the relevant documentation entries.
    API Element Select:
    http://docs.sencha.com/extjs/3.4.0/#!/api/Ext.Element-static-method-select

    API Element Query:
    http://docs.sencha.com/extjs/3.4.0/#!/api/Ext.Element-method-query

    ...or just go to the API (http://docs-origin.sencha.com/extjs/3.4.0/) and type in "Element" in the top right.