How to get buttons in Ext.FormPanel?

I do not see buttons from Ext.FormPanel being defined as follows:

Ext.apply({ .... buttons: [ { text: 'Save', itemId: 'btnSave' } ] }); 

I tried getComponent on an instance of FormPanel, but that does not return btnSave. Is btnSave on an element other than the rest of the form?

+4
source share
3 answers

You cannot use getComponent() because buttons are not part of the items configuration.

getComponent () - "Examine the property of this container and get the direct child component of this container."

You can specify the id button and then use Ext.getCmp() or use a component request, as @limscoder shows.

+2
source

You can use the container's query method to retrieve child components:

panel.query ("# ​​btnSave")

+2
source

In Extjs 4.2, I had a similar code with your buttons at the bottom of the window.
This worked for me:

 var bbar = this.getDockedItems('toolbar[dock="bottom"]')[0]; var button = bbar.getComponent('btnSave'); 

The toolbar and elements are not in your code, but they are implied using the buttons: [{}]

0
source

Source: https://habr.com/ru/post/1398845/


All Articles