Results 1 to 4 of 4

Thread: getting component

  1. #1

    Default getting component

    hi,
    I got a lot of way of getting a component inside a controller in MVC.

    But what is the difference among them.Which is more proper.
    like. Ext.widget()
    Ext.getCmp()
    getComponent()
    this.getViewName()

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,409
    Answers
    716

    Default

    Ext.widget() <- creates generic component
    Ext.getCmp() <- get id of component if known; not recommended; use query and itemId
    getComponent() <- ok if looking for sub component
    this.getViewName() <- MVC approach to get view from config

    Scott.

  3. #3
    Sencha Premium User Tim Toady's Avatar
    Join Date
    Feb 2010
    Location
    Pennsylvania
    Posts
    579
    Answers
    67

    Default

    Ext.widget is not a getter. It creates and returns component based on a config rather than the way Ext.create does it.

    Ext.getCmp should be avoided as it requires the use of static IDs on a component.

    getComponent is fine if you have a reference to the parent of the item you want and know the childs itemId.

    this.get____ I am assuming you are referring to using refs to create getters for components. This is generally my preferred way. I find it clean and it also only does the work to find it the first time.

    I will occassionaly use down and up as well when a ref might be a little overkill.

    If you wanted to get more than one component with your component query you would want to do something like Ext.ComponentQuery.query rather than down/up/refs

    --Edit
    Sorry for the double answer, I took too long to type that I guess and was beat by a solid 8 minutes.

  4. #4
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,409
    Answers
    716

    Default

    I guess and was beat by a solid 8 minutes
    I started running before the shot was fired

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •