1. #1
    Ext JS Premium Member DrZog's Avatar
    Join Date
    Mar 2007
    Location
    Bristol, UK
    Posts
    197
    Vote Rating
    1
    DrZog is on a distinguished road

      0  

    Default Widget initial values

    Widget initial values


    When applying the Datefield widget to an existing markup form element e.g.

    Code:
    <input name="date" id="date" type="text" readonly="true" />
    the widget respects the "readonly" attribute. However if I do this:

    Code:
    <input name="date" id="date" type="text" readonly="true" value="29/03/07">
    the value attribute causes the widget to render "null"??

    I could set it like:

    Code:
    ...
    var DateFilingDate = new Ext.form.DateField({format : "d/m/y",								value: '03/05/74'});
    ...
    but that makes reading existing values from the DB a bit unelegant as I've read them in already with PHP.

    Any ideas?

  2. #2
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854
    Vote Rating
    4
    tryanDLS is on a distinguished road

      0  

    Default


    If you are building a DateField from existing HTML, you need to call applyTo. While this respects readonly on the field, it still allows the datepicker to change the date. I'm not sure that this functionality is correct. Although, on the other hand, if the input is readonly, why make it a DateField?
    Code:
    var d5 = new Ext.form.DateField({
     readonly:true, format: 'd/m/y'
    });
    d5.applyTo('d5');
    
    <input name="d5" id="d5" type="text" readonly="true" value="29/03/07">

  3. #3
    Ext JS Premium Member DrZog's Avatar
    Join Date
    Mar 2007
    Location
    Bristol, UK
    Posts
    197
    Vote Rating
    1
    DrZog is on a distinguished road

      0  

    Default


    Thanks for the reply.

    I use it becasue the rendering is clean. I use the full datefiled elsewhere in the code so I guess its a bit lazy. Nonetheless, the behaviour of changing a readonly field via a script seems OK to me as its only readonly not disabled.

    I left out the ApplyTo code for brevity and have had it in (or the control would'nt have rendered in the first place). So my original question still stands

  4. #4
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854
    Vote Rating
    4
    tryanDLS is on a distinguished road

      0  

    Default


    Ok, then I don't follow. Where are you seeing null. I tested my code with and without a format string and it populates the input field. Without a format, the value isn't correct, because d/m/y isn't the default format, but it does display a value.

  5. #5
    Ext JS Premium Member DrZog's Avatar
    Join Date
    Mar 2007
    Location
    Bristol, UK
    Posts
    197
    Vote Rating
    1
    DrZog is on a distinguished road

      0  

    Default


    my apologies Tim, there was a typo in the SQL and the PHP was returning null

  6. #6
    Sencha - Community Support Team JeffHowden's Avatar
    Join Date
    Mar 2007
    Location
    Forest Grove, OR
    Posts
    1,038
    Vote Rating
    1
    JeffHowden is on a distinguished road

      0  

    Default Re: Widget initial values

    Re: Widget initial values


    Quote Originally Posted by DrZog
    Code:
    <input name="date" id="date" type="text" readonly="true" />
    FWIW, that is not the correct way to indicate that a field is readonly. The readonly attribute in HTML 4.01 is a minimized attribute meaning it doesn't require a value in order to be applied. In other words, simply being included is enough to tell the parser that you wish for it to be enabled. However, since XHTML must be conformant to XML specs, minimized attributes are not allowed. The proper way to use minimized attributes is by repeating the attribute as the value:

    Code:
    <input name="date" id="date" type="text" readonly="readonly" />
    I know that's redundant and a touch counter-intuitive, but that's how it's supposed to be done. Also, you'll notice that when interogating the readOnly property via script, when setting as readonly="readonly" in your markup still results in the a returned boolean value of true. You'll also notice that when you check in Firebug after setting readOnly = false via script that the readonly attribute is removed entirely.
    Jeff Howden
    Ext JS - Support Team Volunteer
    jeff@extjs.com

    Any and all code samples that are authored by me and posted on the Ext forums or website are hereby released into the public domain and I release anyone or entity of liability by using said code samples unless explicitly stated otherwise.

    Opinions are mine and not necessarily endorsed by Ext, LLC. Please do not contact me directly for assistance unless requested by me.

  7. #7
    Ext JS Premium Member DrZog's Avatar
    Join Date
    Mar 2007
    Location
    Bristol, UK
    Posts
    197
    Vote Rating
    1
    DrZog is on a distinguished road

      0  

    Default


    Thanks for the tip Jeff, I guess its good to get into good habbits early. Another one to look out for is the input type "checkbox"

Similar Threads

  1. Grid initial problem XmlReader
    By galdaka in forum Ext 2.x: Help & Discussion
    Replies: 10
    Last Post: 24 May 2007, 1:04 PM
  2. widget contest?
    By Draven in forum Ext 2.x: Help & Discussion
    Replies: 8
    Last Post: 30 Mar 2007, 10:22 AM
  3. Screencast Ext Menu Widget
    By TommyMaintz in forum Community Discussion
    Replies: 5
    Last Post: 12 Mar 2007, 5:46 AM
  4. IE 6 and tabs initial layout
    By JeffBurr in forum Ext 1.x: Bugs
    Replies: 1
    Last Post: 19 Feb 2007, 1:06 PM
  5. Bug in Button widget for 0.33 release
    By grEvenX in forum Ext 1.x: Bugs
    Replies: 5
    Last Post: 18 Dec 2006, 6:44 PM

Thread Participants: 2