up() and down() versus Ext.getCmp()

后端 未结 2 435
迷失自我
迷失自我 2020-11-30 05:55

I\'m very confused which one I need to use for grep object between up() down() and Ext.getCmp(ID).

For me, it is easier that define ID to object and retrieve the obj

2条回答
  •  情深已故
    2020-11-30 06:22

    Ext.getCmp() uses a hash map internally, so it is lighting fast, nearly as fast as retrieving the value in an array based on a key.

    .up() and down() are implemented using a traversal of the component hierarchy, which is a slower process.

    But up() and down() use selectors, so they can also select classes, not just ids.

    You just need to remember that are various situations where you might want to use up() or down(), like when there's a common handler for a multitude of controls, or when the component you're after was auto-generated by the framework so you cannot give it an id yourself.

提交回复
热议问题