[CLOSED] DateFormat on store?

  1. #1

    [CLOSED] DateFormat on store?

    For some reason, I can't seem to get DateFormat on a store to work right:
                    <ext:RecordField Name="NoteId" Type="Int" />
                    <ext:RecordField Name="Username" />
                    <ext:RecordField Name="ShowOnTrackingSheet" Type="Boolean" />
                    <ext:RecordField Name="Updated" Type="Date" DateFormat="dd/mm/YYYY"/>
                    <ext:RecordField Name="ShortText" />
                    <ext:RecordField Name="NoteText" />
    The dateFormat property IS being written out:

    {dateFormat:"d/i/YYYY",type:"date",name:"Updated"}
    But the store isn't loading data into those fields. The field comes out in Firebug as "undefined", even though the data is coming back on the JSON request. If I remove DateFormat, it works fine... but obviously shows the wrong date format.

    Note, this isn't just for my grid, but also for a textbox that I'm filling with the data. If I use DateFormat, both the grid, and my field, don't show the data.
  2. #2

    RE: [CLOSED] DateFormat on store?

    Hi Dave,

    The DateFormat property should accept a string using the standard .NET datetime format specifiers.

    I think your sample should be revised as follows, although I have not tested to confirm.

    Example

    <ext:RecordField Name="Updated" Type="Date" DateFormat="dd/MM/yyyy"/>
    The following documentation from Datejs .toString() function lists accepted .NET format specifiers, see http://code.google.com/p/datejs/wiki/FormatSpecifiers

    Just below the .toString() docs in the Datejs page above, is the .format() function, which is used to support the PHP/Unix syntax. It's a good reference for comparing .NET vs PHP format syntx.

    The date format strings used in ExtJS are based on a PHP/Unix style. When rendering we convert the supplied .NET format string into a PHP format string. With the Coolite Toolkit, any "DateFormat" type properties should be set using a .NET format string.
    Geoffrey McGill
    Founder
  3. #3

    RE: [CLOSED] DateFormat on store?

    Nope, no dice. It renders this out, but nothing is showing up.
    {dateFormat:"d/m/Y",type:"date",name:"Updated"}
  4. #4

    RE: [CLOSED] DateFormat on store?

    Hi Dave,

    What is the format of the date string being sent within the JSON? The DateFormat property must match that format.

    If you're serializing with JSON.Serialize(), then you probably do not need to set the property at all because the default DateTime serialization format is "yyyy-MM-ddThh:mm:ss".

    Example

    <ext:RecordField Name="Updated" Type="Date" />
    If the date/time JSON data is sent in a different format than "yyyy-MM-ddThh:mm:ss", you must set .DateFormat with a custom value. Although, I would highly recommend transporting the date/time value in JSON as a string in the ISO 8601 format of "yyyy-MM-ddThh:mm:ss".

    Hope this helps.

    Geoffrey McGill
    Founder
  5. #5

    RE: [CLOSED] DateFormat on store?

    Hi Dave,

    I'm just wondering if the DateFormat property is working properly for you now? Please let me know if you require any further assistance.*


    Geoffrey McGill
    Founder
  6. #6

    RE: [CLOSED] DateFormat on store?

    *Yes, I'm serializing with JSON.Serialize. *I was mistaken in thinking that the store controlled what format it displayed as. *I solved my problem by changing my grid and my form field(s) to reformat the date to what I wanted to display.
  7. #7

    RE: [CLOSED] DateFormat on store?

    How do i get the datetime format in the store to keep the milliseconds. When i bind data to the store and then retrieve this data, i am losing the milliseconds.
  8. #8

    Convert DateTime Problem

    this.Store.DataSource = ((DataTable)tbl).DefaultView;
    where {ColumnDate} have type DateTime

    Test 1
                JsonReader StoreFields = new JsonReader();
                        if (recordType == RecordFieldType.Date)
                        {
                            StoreFields.Fields.Add(sg.cColumnName, recordType, "yyyy-MM-dd");
                        }
    {View Date in DataBase MSSQL} =>=>=> {View Date in GridPanel with DateColumn.Format = "yyyy-MM-dd";}
    "2011-03-31 00:00:00.000" =>=>=> "2011-03-31"
    "2011-04-12 00:00:00.000" =>=>=> "2011-04-12"
    "2011-06-23 09:24:00.000" =>=>=> "" // undefined

    Test 2
                JsonReader StoreFields = new JsonReader();
                        if (recordType == RecordFieldType.Date)
                        {
                            StoreFields.Fields.Add(sg.cColumnName, recordType, "yyyy-MM-dd HH:mm");
                        }
    {View Date in DataBase MSSQL} =>=>=> {View Date in GridPanel with DateColumn.Format = "yyyy-MM-dd";}
    "2011-03-31 00:00:00.000" =>=>=> "" // undefined
    "2011-04-12 00:00:00.000" =>=>=> "" // undefined
    "2011-06-23 09:24:00.000" =>=>=> "2011-06-23"

    Test 3
                JsonReader StoreFields = new JsonReader();
                        if (recordType == RecordFieldType.Date)
                        {
                            StoreFields.Fields.Add(sg.cColumnName, recordType, "yyyy-MM-dd HH:mm:ss");
                        }
    {View Date in DataBase MSSQL} =>=>=> {View Date in GridPanel with DateColumn.Format = "yyyy-MM-dd";}
    "2011-03-31 00:00:00.000" =>=>=> "" // undefined
    "2011-04-12 00:00:00.000" =>=>=> "" // undefined
    "2011-06-23 09:24:00.000" =>=>=> "" // undefined

    Test 4
                JsonReader StoreFields = new JsonReader();
                        if (recordType == RecordFieldType.Date)
                        {
                            StoreFields.Fields.Add(sg.cColumnName, recordType);
                        }
    {View Date in DataBase MSSQL} =>=>=> {View Date in GridPanel with DateColumn.Format = "yyyy-MM-dd";}
    "2011-03-31 00:00:00.000" =>=>=> "" // undefined
    "2011-04-12 00:00:00.000" =>=>=> "" // undefined
    "2011-06-23 09:24:00.000" =>=>=> "" // undefined


    What is this????
    Last edited by ViDom; Mar 15, 2011 at 12:32 PM.
  9. #9
    Hi,

    Please start a new thread. If you feel they are related please feel free to cross link between two.

Similar Threads

  1. [CLOSED] DateField DateFormat "YYYY/MM/DD" SelectedValue
    By pattake in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 02, 2012, 1:19 AM
  2. [CLOSED] Version 1.2 Grid/Store DateFormat
    By ndotis in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Oct 04, 2011, 5:14 PM
  3. [CLOSED] [1.0] DateFormat="M$" not working
    By Fredrik in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Jul 28, 2011, 4:04 PM
  4. Replies: 2
    Last Post: Jul 08, 2009, 12:37 PM
  5. DateFormat in Grid Problem
    By bruce in forum 1.x Help
    Replies: 1
    Last Post: Mar 19, 2009, 8:47 AM

Posting Permissions