1

Let's say I have a sample fieldset as follows :

+---| Customer Types | --------------------------+
|                                                |
|   +----------+    +----------+   +---------+   |
|   |  Trader  |    |  Horeca  |   |   SCO   |   |
|   +----------+    +----------+   +---------+   |
|                                                |
+------------------------------------------------+

The fieldset has three buttons which are opening a new window. When an employee click one of the buttons, he/she should fill out some necessary fields. After filling out the forms, he/she will click the submit button the post records. There is no problem thus far.

What I want to do, an employee fill out the form and click the submit button of the opened window, I should disable other buttons to be able to prevent double record.

Here is the questions:

  • Is there any method in ExtJS to select child elements of the fieldset?
  • Or, do you have any suggestion/sample code to select child elements to disable those buttons that I specified in the above?
0

2 Answers 2

1

You will want to use an Ext.ComponentQuery. This is built in to each component if you use the down(), up(), and query() methods.

To get what you want, do something like this:

var buttons = myFieldSet.query('button');
for (var i=0; i<buttons.length; i++)
    buttons[i].disable();

Learn more from the docs here: http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.ComponentQuery

2
  • @dbrin, kevhender thanks for suggestions. One thing I can't resolve until now. How can I keep filled out form button status enable except others? Jul 19, 2013 at 17:57
  • Just check that the button you are disabling is not the one you want to stay enabled - e.g. if (buttons[i].text !== 'Submit') buttons[i].disable()
    – kevhender
    Jul 19, 2013 at 18:01
1

ExtJS provides a ComponentQuery class that lets you find any component anywhere in the page. Additionally some of those CQ methods are added for convience to container components, like the down() method. Using it you can find your components contained within your fieldset. You can search by xtype, itemId or any arbitrary property of your component.

For Components:
    • Ext.getCmp(id)
    • Ext.ComponentQuery.query()
    • up() 
    • down() 
    • nextSibling() 
    • previousSibling()
    • child()
    • previousNode()
plus various find.. Methods

For Elements:
    • Ext.get()
    • Ext.dom.Query() (more on DOM Query http://docs.sencha.com/core/manual/content/domquery.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.