[CLOSED] [1.0] Checkbox ReadOnly

  1. #1

    [CLOSED] [1.0] Checkbox ReadOnly

    When I set ReadOnly of a Checkbox to true in codebehind the checkbox is not read only.
    Last edited by Daniil; Sep 16, 2010 at 11:07 AM. Reason: [CLOSED]
  2. #2
    Hello!

    I'm not sure but it seems there is an issue with the ReadOnly property.

    Several days ago I tried this code working on
    http://forums.ext.net/showthread.php...donly-Property
    and a checkbox appears read only.

    We will investigate.

    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:Checkbox runat="server" ReadOnly="true" />
        </form>
    </body>
    </html>
    Last edited by Daniil; Sep 15, 2010 at 6:26 PM.
  3. #3
    Hi,

    ReadOnly flag is add readonly attribute to the input field
    readOnly : Boolean
    true to mark the field as readOnly in HTML (defaults to false).
    Note: this only sets the element's readOnly DOM attribute. Setting readOnly=true, for example, will not disable triggering a ComboBox or DateField; it gives you the option of forcing the user to choose via the trigger without typing in the text box. To hide the trigger use hideTrigger.
    As I now only WebKit (Chrome, Safari) supports that attribute for checkbox, IE and FF don't support it
    I suggest to use Disabled="true" instead ReadOnly
  4. #4
    Ok, I will use disabled for the checkboxes.
    Thx, Klaus
  5. #5
    Hello!

    The Disabled property is a good alternative but note that a disabled control is not submitted and it's always valid (isValid method always return true). As I can judge this behavior is applied for all disabled controls (not only for checkbox).

    If you don't have to use these features please use the disabled property as Vladimir suggested.

    But if you need it (maybe in the future) here is a solution for you.

    As I said earlier I tested the ReadOnly property and it works as expected. Yes, but it was on the Coolite 0.8.2 which is based on ExtJS 2.3.

    There (in ExtJS 2.3) was another policy with the readOnly property. As an example for checkbox, it's considered in the onClick function and value changing was prevented by using the stopEvent method.

    I can't see any obstacles to use this technique. Also I'm not sure and a little bit curious why it was changed in ExtJS 3.x.x.

    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>
    
        <script type="text/javascript">
            myOnClick = function(e) {
                if ((this.el.dom.checked != this.checked) && !this.readOnly) {
                    this.setValue(this.el.dom.checked);
                }
                e.stopEvent();
            }
        </script>
    
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:Checkbox runat="server" ReadOnly="true">
            <CustomConfig>
                <ext:ConfigItem Name="onClick" Value="myOnClick" Mode="Raw" />
            </CustomConfig>
        </ext:Checkbox>
        </form>
    </body>
    </html>

Similar Threads

  1. [CLOSED] Combobox readonly
    By gidi in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Feb 29, 2012, 3:22 PM
  2. Replies: 4
    Last Post: Oct 06, 2010, 9:08 AM
  3. [CLOSED] [1.0] Dynamically load checkbox in Checkbox Group
    By vali1993 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jun 14, 2010, 5:05 PM
  4. [CLOSED] Adding Checkbox items to checkbox group during a postback?
    By vedagopal2004 in forum 1.x Legacy Premium Help
    Replies: 19
    Last Post: Feb 05, 2010, 10:13 AM
  5. Replies: 1
    Last Post: Aug 13, 2009, 9:37 AM

Tags for this Thread

Posting Permissions