I have button with id = 'someid'
, i can find it by Ext.getCmp('someid')
...
Is there a way to set some kind of "extraId" to that button, and find that button by "extraId'?
The question is where you want to search to get your item.
Another way could be the itemId.
An itemId can be used as an alternative way to get a reference to a component when no object reference is available. Instead of using an id with Ext.getCmp, use itemId with Ext.container.Container.getComponent which will retrieve itemId's or id's. Since itemId's are an index to the container's internal MixedCollection, the itemId is scoped locally to the container -- avoiding potential conflicts with Ext.ComponentManager which requires a unique id.
Source and further documentation: http://docs.sencha.com/ext-js/4-0/#/api/Ext.AbstractComponent-cfg-itemId
The ComponentQuery (mentioned by wombleton) is also a good way but maybe not as performant as the itemId.
You can search for it by doing an Ext.ComponentQuery
.
Example that will work in the console on the linked page:
Ext.ComponentQuery.query('button[text=OK]')
You can replace text=OK
with the attribute you are searching for.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With