Extjs 4 :Disable all the input elemets in an Extjs form at once

11,952

Solution 1

If you are using FormPanel in ExtJs 4.x this is what you are looking for -

yourFormPanel.getForm().applyToFields({disabled:true});

The getForm() method returns the Ext.form.Basic object, with this class, you also could access to all the fields on this form with getFields(), then you could iterator all the fields to do anything.

Hope this helps and good luck:-)

Solution 2

What about panel's disable/enable method? This seems much easier.

panel.disable();

panel.enable();

Solution 3

Here is a suggestion.. Since, you say your form is divided into two parts why don't you put them in a FieldSet ? You can disable the fieldset as a whole with one method ie, setDisabled.

This will avoid the looping of components and disabling / enabling them one after the another.

Share:
11,952

Related videos on Youtube

Nick
Author by

Nick

Updated on June 05, 2022

Comments

  • Nick
    Nick almost 2 years

    I have created a extjs form which is divided into 2 parts using column layout and have almost 10-15 input elements in it. How can i disable all these input elements at a time depending on a condition. Currently i have created a function which fetchs all the components in a form and using ext.each loop through each element to disable them

    Here is the function that i use

    function prepare_form_view(form){
        var f=Ext.getCmp(form);
        var els=f.query('component');
        Ext.each(els,function(o){
            var xtype=o.getXType();
            if(xtype=='textfield'||xtype=='combobox'||xtype=='datefield'||xtype=='textareafield'||xtype=='button'){
                o.disabledCls='myDisabledClass';
                o.disable();
            }
        });
    }
    

    Is there any alternative way so that I can disable all elements without looping through each and every elements. I want to use this function with other forms too. I looking for something like 'setFieldDefult' function.

  • Nick
    Nick about 12 years
    Thank you for reply Abdel. but as i said i want to use this function with other forms too.And different forms have different layout...
  • Glenn Lawrence
    Glenn Lawrence almost 9 years
    It also disables the panel's toolbar, otherwise this works well.