[CLOSED] Field ReadOnly Javascript

  1. #1

    [CLOSED] Field ReadOnly Javascript

    HI, I have a problem, readOnly non work the set client-side,Server-side work ok, here is the example:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="ARWebRevolution.WebForm1" %>
    
    <%@ 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 id="Head1" runat="server">
        <title>Ext.NET v2 Example</title>
     
    </head>
    <body>
        <form id="Form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" >
        </ext:ResourceManager>
        <ext:FormPanel ID="FormPanel1" runat="server" ButtonAlign="Right" Height="185" Padding="5"
            Title="Title" Width="300">                 
            <Items>
               <ext:NumberField ID="NumberField1" runat="server" ReadOnly="true">
        </ext:NumberField>
                <ext:TextField ID="TextField1" runat="server" >
                </ext:TextField>
            </Items>
            <Buttons>
                <ext:Button ID="Button1" runat="server" Icon="Disk" Text="Enable Field">
                    <Listeners>
                        <Click Handler="enableField();" />
                    </Listeners>
                </ext:Button>
            </Buttons>
        
        </ext:FormPanel>
        
        </form>
        <script type="text/javascript" >
    
            function enableField() {
                App.NumberField1.readOnly = false;
                App.TextField1.readOnly = true;         
               
            }        
          
        </script>
    </body>
    </html>
    protected void enableField(object sender, DirectEventArgs e)
            {
                NumberField1.ReadOnly = false;           
    
            }
    1) If click button only with function listener, readOnly non work
    2)If click button only with function
     <DirectEvents>
                        <Click OnEvent="enableField" />
                    </DirectEvents>
    it's work ok,
    3) With Direct and Listener not work.

    Also if use readOnly the spinner to right of the field not is show.

    Thank
    Aurelio
    Last edited by Daniil; Mar 22, 2012 at 7:38 AM. Reason: [CLOSED]
  2. #2
    Hi,

    Please use the setReadOnly method on client side instead of just setting the readOnly property.
    http://docs.sencha.com/ext-js/4-0/#!...od-setReadOnly
  3. #3
    Hi, Daniil, today my brain is malfunctioning !!!!

    however the spinner not appear the readOnly is set to false to the function..

    Thanks
    Aurelio
  4. #4
    Confirmed, thanks for the report.

    Here is the test case.

    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 v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:NumberField ID="NumberField1" runat="server" ReadOnly="true" />
            <ext:Button runat="server" Text="setReadOnly(false)">
                <Listeners>
                    <Click Handler="App.NumberField1.setReadOnly(false);
                                    // Doesn't work as well
                                    // App.NumberField1.setReadOnly(false);
                                    " />
                </Listeners>
            </ext:Button>
        </form>
    </body>
    </html>
  5. #5
    Please update from SVN.
  6. #6
    Hi, Daniil, ok work fine..but i have another problem with number field:
    When setting the property MinValue = 0, if the value is 0, the value property returns null..
    Here the sample:
    1)Click the button enable field, it's setValue = 0
    2)Click the button ShowValue, it's not show 0 but the value is null.
    So I can not assign a value of 0 which is the minimum value

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="ARWebRevolution.WebForm1" %>
    
    <%@ 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 id="Head1" runat="server">
        <title>Ext.NET v2 Example</title>
     
    </head>
    <body>
        <form id="Form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" >
        </ext:ResourceManager>
        <ext:FormPanel ID="FormPanel1" runat="server" ButtonAlign="Right" Height="185" Padding="5"
            Title="Title" Width="300">   
            <FieldDefaults LabelWidth="90" /> 
                   <FieldDefaults ReadOnly="true" />                 
            <Items>
               <ext:NumberField ID="NumberField1" runat="server" MinValue="0"   >
        </ext:NumberField>
                <ext:TextField ID="TextField1" runat="server" >
                </ext:TextField>
            </Items>
            <Buttons>
                <ext:Button ID="Button1" runat="server" Icon="Disk" Text="Enable Field">
                    <Listeners>
                        <Click Handler="enableField();" />
                    </Listeners>               
                </ext:Button>
                 <ext:Button ID="Button2" runat="server" Icon="Disk" Text="Show Value">
                    <Listeners>
                        <Click Handler="showValue();" />
                    </Listeners>               
                </ext:Button>
            </Buttons>
        
        </ext:FormPanel>
        
        </form>
        <script type="text/javascript" >
    
            function enableField() {
                App.NumberField1.setReadOnly(false);
                App.NumberField1.setValue(0);           
            }
            function showValue() {
                Ext.Msg.show({
                    title: 'Value',
                    msg: App.NumberField1.getValue(),
                    buttons: Ext.Msg.OK,
                    icon: Ext.Msg.QUESTION
                });
            }
    
        </script>
    </body>
    </html>
    Thanks
    Aurelio
  7. #7
    Please keep one issue per one thread. So, please start a new forum thread.
  8. #8
    Hi, Daniil... ok

    Thanks

Similar Threads

  1. Replies: 12
    Last Post: Sep 20, 2011, 3:33 PM
  2. [CLOSED] [1.1] Prevent backspace on readonly field on ie
    By John_Writers in forum 1.x Premium Help
    Replies: 4
    Last Post: Sep 20, 2011, 11:29 AM
  3. Replies: 2
    Last Post: Aug 19, 2011, 2:36 PM
  4. Replies: 2
    Last Post: Feb 17, 2010, 10:47 AM
  5. [CLOSED] Dynamically set field label in javascript
    By macap in forum 1.x Premium Help
    Replies: 3
    Last Post: Dec 29, 2009, 5:17 AM

Posting Permissions