Search code examples
javascriptextjs4

How to locate an element with multiple attributes using Ext.componentQuery.query in extjs


I want to know if can we use multiple attributes in componentquery in extjs to locate an element?

Like the below query searches the button with name as mybutton. Can we add more attributes like class and text in the same query ?

Ext.ComponentQuery.query('button[b-name="mybutton"]')

Solution

  • Yes, it is possible.

    Let's say this is the element you are looking for:

    {
        xtype: 'label',
        id:'iAmId',
        itemsId: 'iAmItemId',
        text: 'Hnweis: Bitte Projekt im SAP/SRM abrechnen.',
        style: {
            'font-weight': 'bold'
        }
    }
    

    This is the component query you can run if you want to look for this element on basis of its id and itemId:

    Ext.ComponentQuery.query('label[itemsId="iAmItemId"][id="iAmId"]')