[CLOSED] Problem with Converter on Date RecordField

  1. #1

    [CLOSED] Problem with Converter on Date RecordField

    Hi
    I am trying to overcome the problem described here:

    http://forums.ext.net/showthread.php...ith-datecolumn

    and in particular:

    "I did not test your sample but I guess it occurs for rows have 'null' initial date, DateField returns empty string instead null
    null and empty string are different values therefore you have dirty flag"

    This is exactly what we are experiencing and I am using a Converter to convert any null dates from the Model:

    <ext:RecordField Name="DateOfBirth" Type="Date" AllowBlank = "true" SubmitEmptyValue="Null">
         <Convert Handler="debugger;if (value === null || typeof value === 'undefined') {value = '';}return value;" />
    </ext:RecordField>
    Now, this works and stops records being marked as dirty. However, if valid dates are present (and the Store does seem to pick them up, for example, we get a value of "1966-04-05T00:00:00.000"), when the record is loaded into the form via
    loadRecord(record)
    the DateField set to display the value doesn't seem to recognise the value as a date and doesn't display it - it displays blank. When the store record is then updated via
    updateRecord(record)
    the store record's date field is set to an empty string, the value from the DateField.

    Is there something I should be doing on my Converter to make sure the store record, when a valid date is present, is seen as a valid Date?

    thank you
    Last edited by Daniil; Jun 08, 2012 at 3:26 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Well, RecordField Convert overcomes its Type.

    Generally, RecordField Type is a predefined Convert function. So, you override the default Date converter and
    Type="Data"
    doesn't work.

    So, you should parse dates manually.

    Example
    <ext:RecordField Name="test">
        <Convert Handler="return Date.parseDate(value, 'Y-m-dTH:i:s');" />
    </ext:RecordField>
  3. #3
    Hi
    I was thinking along these lines but couldn't get any of the date formats to work. However, new Date(the dateParse) seems to work and the DateField reads it in. However, while this stops the null date marking the record as dirty when it is changed to "" the record which has the Date changed via the Converter is marked as dirty on that field.

    Is there any other way we can stop these records as being marked as dirty when thet have a null date value?



    Quote Originally Posted by Daniil View Post
    Hi,

    Well, RecordField Convert overcomes its Type.

    Generally, RecordField Type is a predefined Convert function. So, you override the default Date converter and
    Type="Data"
    doesn't work.

    So, you should parse dates manually.

    Example
    <ext:RecordField Name="test">
        <Convert Handler="return Date.parseDate(value, 'Y-m-dTH:i:s');" />
    </ext:RecordField>
  4. #4
    Hi
    I subsequently find, unlike the null/'' issue, it's not the Converter that's causing the Record to be marked as Dirty it's when
    form.updateRecord(record)
    is called on it - done automatically via a Validation Handler. It is the Date value in question that is being marked as having changed and I'm not doing anything else to it that would mark it thus.

    Quote Originally Posted by GLD View Post
    Hi
    I was thinking along these lines but couldn't get any of the date formats to work. However, new Date(the dateParse) seems to work and the DateField reads it in. However, while this stops the null date marking the record as dirty when it is changed to "" the record which has the Date changed via the Converter is marked as dirty on that field.

    Is there any other way we can stop these records as being marked as dirty when thet have a null date value?
  5. #5
    Could you provide a sample to reproduce?

Similar Threads

  1. [CLOSED] Default date format for Type="Date" RecordField
    By r_honey in forum 1.x Legacy Premium Help
    Replies: 12
    Last Post: May 29, 2012, 4:16 PM
  2. [CLOSED] DefaultValue for Date RecordField
    By SouthDeveloper in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Nov 17, 2011, 3:55 PM
  3. Problem with RecordField
    By walle in forum 1.x Help
    Replies: 1
    Last Post: Feb 06, 2011, 2:38 PM
  4. Date recordfield in gridpanel
    By yobnet in forum 1.x Help
    Replies: 4
    Last Post: Jan 14, 2010, 11:34 AM
  5. RecordField type="date" in coolite 0.8
    By dperera in forum 1.x Help
    Replies: 8
    Last Post: Sep 01, 2009, 6:49 PM

Posting Permissions