[CLOSED] Setting Disabled Property of a NumberField after CheckBox is Checked

  1. #1

    [CLOSED] Setting Disabled Property of a NumberField after CheckBox is Checked

    Hi,

    I have one CheckBox and one Disabled NumberField into a FormPanel, i wish to set disabled property of the numberfield when the user check the checkbox, i try to use check listener, but it does not work.

    <ext:Checkbox ID="chkGeralExigeAvalista" runat="server" BoxLabel="Exige Avalista">
                                                                                            <Listeners>
                                                                                                <Check Handler="if(this.check){#{txtGeralNumero.disabled=false;}" />
                                                                                            </Listeners>
                                                                                        </ext:Checkbox>
    How to solve this problem?
    Last edited by Daniil; Sep 17, 2010 at 7:17 PM. Reason: [CLOSED]
  2. #2
    Hello!

    The Checkbox has no 'check' property. So, it's always undefined and the code within the if operator is not executed.
    It's better to use 'checked' parameter which is passed to an event's handler.

    To enable the field please use the enable method.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:FormPanel runat="server">
            <Items>
                <ext:NumberField ID="NumberField1" runat="server" Disabled="true" FieldLabel="NumberField"/>
                <ext:Checkbox runat="server" FieldLabel="Check to enable">
                    <Listeners>
                        <Check Handler="if (checked) { #{NumberField1}.enable(); }"/>
                    </Listeners>
                </ext:Checkbox>
            </Items>
        </ext:FormPanel>
        </form>
    </body>
    </html>
  3. #3
    Might be better to use the .setDisabled() function.

    Example

    <Check Handler="#{NumberField1}.setDisabled(this.checked);" />
    See also

    http://dev.sencha.com/deploy/dev/doc...er=setDisabled
    Last edited by geoffrey.mcgill; Sep 17, 2010 at 4:23 PM.
    Geoffrey McGill
    Founder
  4. #4

    Thanks

    Thank You.

    It Works!
  5. #5

    It Works But How To Set the Value of numberField in JS

    Quote Originally Posted by geoffrey.mcgill View Post
    Might be better to use the .setDisabled() function.

    Example

    <Check Handler="#{NumberField1}.setDisabled(this.checked);" />
    See also

    http://dev.sencha.com/deploy/dev/doc...er=setDisabled

    Than you, It Works, bu how to set the value of numberField?

    <ext:Checkbox ID="chkGeralExigeAvalista" runat="server" BoxLabel="Exige Avalista">
                                                                                            <Listeners>
                                                                                                <Check Handler="#{txtGeralPercentualRenda}.setDisabled(!this.checked);#{txtGeralPercentualRenda}.value='0';" />
                                                                                            </Listeners>
                                                                                        </ext:Checkbox>
    It disable the NumberField, but don´t change de value (Text) of the TextField
    Last edited by geoffrey.mcgill; Sep 20, 2010 at 10:04 PM. Reason: please use [CODE] tags
  6. #6
    Hi,

    In future posts, please remember to wrap your code samples in [CODE] tags.
    Geoffrey McGill
    Founder
  7. #7
    Quote Originally Posted by pdcase View Post
    Than you, It Works, bu how to set the value of numberField?

    <ext:Checkbox ID="chkGeralExigeAvalista" runat="server" BoxLabel="Exige Avalista">
                                                                                            <Listeners>
                                                                                                <Check Handler="#{txtGeralPercentualRenda}.setDisabled(!this.checked);#{txtGeralPercentualRenda}.value='0';" />
                                                                                            </Listeners>
                                                                                        </ext:Checkbox>
    It disable the NumberField, but don´t change de value (Text) of the TextField
    I use the SetValue and it Works


    Thanks Again
  8. #8
    Quote Originally Posted by pdcase View Post
    It Works, bu how to set the value of numberField?
    All Field classes include the .setValue function, see

    http://dev.sencha.com/deploy/dev/doc...ember=setValue

    Hope this helps.
    Geoffrey McGill
    Founder

Similar Threads

  1. [CLOSED] How to set checkbox node has been checked?
    By gs_user in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Jun 21, 2012, 8:40 AM
  2. [CLOSED] Another way to check checkbox is checked ot not....
    By rosua in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jun 21, 2012, 5:39 AM
  3. Replies: 3
    Last Post: Jun 07, 2012, 6:15 PM
  4. [CLOSED] CheckBox.Checked is not getting set
    By speedstepmem3 in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jul 01, 2011, 11:27 AM
  5. [CLOSED] ext:CheckBox.checked property funnies
    By daneel in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jul 06, 2010, 2:20 PM

Posting Permissions