Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User
    Join Date
    Feb 2008
    Location
    Italy
    Posts
    20
    Vote Rating
    0
    BrightSoul is on a distinguished road

      0  

    Question [CLOSED]Model date fields issues on Android and iPhone

    [CLOSED]Model date fields issues on Android and iPhone


    I've stumbled upon something that might be a bug. Here's what I have, a simple entity with just one date field:

    Code:
    Ext.regModel('Calendar', {
        fields: [{ name: 'startDate', type: 'date'}]
    });
    Then, I use a store to load json data from a file.

    Code:
    var calendarStore = new Ext.data.Store({
        model: 'Calendar',
        autoLoad: true,
        listeners:{load:function(store, records, successful){ alert(records[0].data.startDate); }},
        proxy: {
            type: 'ajax',
            url: './calendar.txt',
            reader: {
                type: 'json',
                root: 'results'
            }
        }
    });
    Notice how I subscribed the load event, and used alert() to see the value of startDate from the first record.
    This is the JSON content of calendar.txt
    Code:
    {"results":[{"startDate":"2010-11-06T20:00:00.000Z"}]}
    The load is successful, but this is what happens:
    • Google Chorme: it shows the correct date, working as expected
    • Android-sdk-windows emulator: shows null
    • iBBDemo2 iPad simulator: show null

    (see screenshot)
    date-parsing-problem.jpg

    It really doesn't matter what date format I use, I also tried "2010-11-06 20:00:00" and "2010-11-06" but still no luck.

    As a temporary fix, I changed my date field to type:"string" and parsed the value as needed with Date.parseDate(value, "c") <-- this works fine on all 3 testing environments.

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,664
    Vote Rating
    586
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    You need to pass the dateFormat parameter. Chrome is a bit better with parsing dates, so you need to explicitly specify the format for the other browsers.

    Code:
    {name: 'foo', type: 'date', dateFormat: 'c'}
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  3. #3
    Ext User
    Join Date
    Oct 2010
    Posts
    1
    Vote Rating
    0
    lazarev is on a distinguished road

      0  

    Default Doesn't works for me

    Doesn't works for me


    That's my model:
    Code:
    Ext.regModel('Measure', {
               fields: [
                   {name: 'pk', type: 'int'},
                   {name: 'model', type: 'string'},
                   {name: 'fields', fields: [
                          {name: "date", type: 'date', dateFormat: 'c'},
                          {name: "dimension", type: "string" },
                          {name: "value", type: "float" }
                      ]
                   }
               ]
            });
    That's my data part:
    Code:
    {"pk": 1, "model": "dimension.measure", "fields": {"date": "2010-08-01 08:00:00", "dimension": 1, "value": 83.5}}

    But I still can convert it by hands. That code works fine:
    Code:
    var date = Date.parseDate(record.data.fields.date, "c");
    Trying this on Chrome 7.0.517.44

Similar Threads

  1. Advices on form and portability Android/iPhone
    By gabrielstuff in forum Sencha Touch 1.x: Discussion
    Replies: 9
    Last Post: 9 Nov 2010, 4:08 AM
  2. Default Android and iPhone click/tap styles?
    By djkraz in forum Sencha Touch 1.x: Discussion
    Replies: 1
    Last Post: 21 Sep 2010, 6:47 AM
  3. [FIXED-247] Model date fields do not parse
    By JacobGu in forum Sencha Touch 1.x: Bugs
    Replies: 3
    Last Post: 2 Sep 2010, 2:50 PM
  4. Iphone, android, webOS and Blackberry compatability breakdown
    By oliverashford in forum Sencha Touch 1.x: Discussion
    Replies: 2
    Last Post: 23 Aug 2010, 11:16 PM
  5. IPhone, Android, Slates,.... ???
    By steenj in forum Community Discussion
    Replies: 11
    Last Post: 2 Feb 2010, 11:54 PM

Thread Participants: 2