Best way to access adjacent components / fields

后端 未结 2 891
不思量自难忘°
不思量自难忘° 2021-01-18 03:08

I am looking for a way to access components / field that are either in the same items array as the accessing one or even only in a same parent items array (the last one is j

相关标签:
2条回答
  • 2021-01-18 03:36

    Here are some tricks I have used:

    //lookup by name
    formPanel.getForm().findField('state'); 
    
    //lookup using nextSibling/prevSibling in a fieldset or fieldcontainer
    myField.ownerCt.nextSibling('textfield[fieldLabel=Description]')
    

    Here fieldLabel property is used to narrow down field selection but you can use ANY property at all. So if you construct a field with a property ref you can then use it to select your field similar how you would use it in a ComponentQuery .

    0 讨论(0)
  • 2021-01-18 03:37

    Alternately, for your case of getting the next element in a container, you can use the nextSibling or prevSibling. All components have these methods. It would be a little less walking around the DOM structure. They also allow for a selector argument.

    They are described in the docs here.

    0 讨论(0)
提交回复
热议问题