1. #1
    Sencha User
    Join Date
    Oct 2011
    Location
    indonesia
    Posts
    17
    Vote Rating
    0
    stoneboys is on a distinguished road

      0  

    Default Answered: Checkbox fires

    Answered: Checkbox fires


    Hi all, I want create fires on checkbox..
    this my case :
    I have one checkbox & one textfield , If Checkbox values = 1 OR Checkbox event change The Textfield is enable but if Checkbox values = 0 the Textfield is disable ?


    thank before.

  2. Here is how you can achieve it:
    Code:
    Ext.create('Ext.form.Panel', {
        renderTo: Ext.getBody(),
        items: [{
            xtype: 'checkbox',
            boxLabel: 'Check This',
            listeners: {
                change: function(fld, newVal, oldVal, opts) {
                    if (newVal)
                        fld.up('panel').down('textfield').enable();
                    else
                        fld.up('panel').down('textfield').disable();
                }
            }
        }, {
            xtype: 'textfield',
            labelText: 'Text',
            disabled: true
        }]
    });

  3. #2
    Sencha Premium Member findajit's Avatar
    Join Date
    Mar 2009
    Location
    Hyderabad, India
    Posts
    61
    Answers
    6
    Vote Rating
    0
    findajit is on a distinguished road

      0  

    Default


    Here is how you can achieve it:
    Code:
    Ext.create('Ext.form.Panel', {
        renderTo: Ext.getBody(),
        items: [{
            xtype: 'checkbox',
            boxLabel: 'Check This',
            listeners: {
                change: function(fld, newVal, oldVal, opts) {
                    if (newVal)
                        fld.up('panel').down('textfield').enable();
                    else
                        fld.up('panel').down('textfield').disable();
                }
            }
        }, {
            xtype: 'textfield',
            labelText: 'Text',
            disabled: true
        }]
    });
    My Book on Sencha Touch - Sencha Touch Cookbook (2nd Edition)
    My older book on Sencha Touch - Sencha Touch Cookbook
    My Sencha Touch Blog - Walking Tree Sencha Touch Blog
    My ExtJS Blog - Walking Tree ExtJS Blog
    Active contributor to - Walking Tree's ExtJS and Touch Forums

    Buy ExtJS Components from - Walking Tree e-Store

  4. #3
    Sencha User
    Join Date
    Oct 2011
    Location
    indonesia
    Posts
    17
    Vote Rating
    0
    stoneboys is on a distinguished road

      0  

    Default


    Quote Originally Posted by findajit View Post
    Here is how you can achieve it:
    Code:
    Ext.create('Ext.form.Panel', {
        renderTo: Ext.getBody(),
        items: [{
            xtype: 'checkbox',
            boxLabel: 'Check This',
            listeners: {
                change: function(fld, newVal, oldVal, opts) {
                    if (newVal)
                        fld.up('panel').down('textfield').enable();
                    else
                        fld.up('panel').down('textfield').disable();
                }
            }
        }, {
            xtype: 'textfield',
            labelText: 'Text',
            disabled: true
        }]
    });
    thanks my problem is resolved, but i make litle change here, this my code :
    Code:
    Ext.create('Ext.form.Panel', {
        renderTo: Ext.getBody(),
        items: [{
            xtype: 'checkbox',
            boxLabel: 'Check This',
            listeners: {
                change: function(fld, newVal, oldVal, opts) {
                   val = fld.disabled==true;
                          if (newVal && val)
                        fld.up('panel').down('textfield').enable();
                    else
                        fld.up('panel').down('textfield').disable();
                }
            }
        }, {
            xtype: 'textfield',
            labelText: 'Text',
            disabled: true
        }]
    });
    this my code :

    Code:
    val = fld.disabled==true;
                         if (newVal && val)
    i use it because some checkbox already checked & current disabled,this on case if we just need edit some datas..

    thanks findajit..

Thread Participants: 1

Tags for this Thread