How to query a component by component name that contains some part of a string
I want to use Ext.ComponentQuery.query()
to query the name of a button containing some name path.
Suppose I have 4 buttons named declare as 'edit_btn', 'add_btn', 'add2_btn' and 'edit2_btn'
Then I use query.
Ext.ComponentQuery.query("button[name='*edit*']");
I have to get edit_btn and edit2_btn .
Ext.ComponentQuery.query("button[name='*add*']");
I have to get 'add_btn ' and 'add2_btn' .
Or can I use regex in the command Ext.ComponentQuery.query()
?
If possible, how to use it?
source to share
This is not implemented. I looked at the source code and there is only the equality operator. Hovewer is easy to extend (see the filterByAttribute
ComponentQuery.html file), but you have to copy all of the code from the source because it's implemented as a singleton.
Another way is to select buttons with name attribute and filter later, for example:
Ext.Array.filter(
Ext.ComponentQuery.query('button[name]'),
function(c){ return /^add/.test(c.name); }
)
source to share