You found a bug! We've classified it as TOUCH-5167 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Sencha User
    Join Date
    Jun 2012
    Posts
    7
    Vote Rating
    0
    abryant is on a distinguished road

      0  

    Default ST 2.3.1 - Date format on model.save with REST proxy

    ST 2.3.1 - Date format on model.save with REST proxy


    I'm testing our upgrade from ST 2.0.0 to ST 2.3.1 and am having issues when saving a date value back to our server. For some reason, the "UpdatedDate" value is being sent as a decimal value when POSTing to the server. See below.

    Folder Model
    Code:
    Ext.define('GlobalFocus.model.Folder', {
        extend: 'Ext.data.Model',
        
        config: {
            fields: [
                {name: 'ID',  type: 'int', persist: false},
                {name: 'FolderName',  type: 'string'},
                {name: 'UpdatedDate',  type: 'date'},
                {name: 'FolderCount', type: 'int'},
                {name: 'IsPublic',  type: 'bool'},
                {name: 'IsSelected', type: 'bool'}
            ],
            
            idProperty: 'ID',
            
            proxy: {
                type: 'rest',
                url: GlobalFocus.util.Config.getRecruiterURL() + 'Folder',
                noCache: false,
                reader: {
                    type: 'json'
                }
            }
        }
    });

    Creating the model instance
    Code:
    var folder = Ext.create(
                'GlobalFocus.model.Folder', {
                FolderName: values.name,
                UpdatedDate: new Date(),
                FolderCount: 0,
                IsPublic: (values.ispublic == '1'),
                IsSelected: false
            });
    When I do a console.log of the folder object, I get the following, which looks correct:

    Code:
    FolderCount: 0
    FolderName: "Folder Test"
    ID: "ext-record-9"
    IsPublic: true
    IsSelected: false
    UpdatedDate: Thu Nov 21 2013 11:54:41 GMT-0500 (Eastern Standard Time)
    However, when the save method is invoked on the model, the POST payload looks like this:

    Code:
    FolderCount: 0
    FolderName: "Folder Test"
    IsPublic: true
    IsSelected: false
    UpdatedDate: 1385052881.959
    Notice the decimal value for UpdatedDate now. This same issue was addressed in a previous post, but that user was using a store.sync() call I believe.

  2. #2
    Sencha - Support Team
    Join Date
    Oct 2011
    Posts
    3,955
    Vote Rating
    131
    fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all

      0  

    Default


    Thanks for the report! I have opened a bug in our bug tracker.

  3. #3
    Sencha User
    Join Date
    Jun 2012
    Posts
    7
    Vote Rating
    0
    abryant is on a distinguished road

      0  

    Default


    I was able to work around this issue by adding a dateFormat property to my model. I didn't realize this property also affected the output of the writer. We are using ASP.NET Web API, which returns dates in ISO 8601 format:

    Code:
    2013-12-05T14:33:55.4569641-05:00
    Changing my model to the following took care of the immediate issue. However, it still seems an odd choice, to me at least, that the default writer format would be a timestamp. Is this for better compatibility with PHP and Java services?

    Code:
    Ext.define('GlobalFocus.model.Folder', {
        extend: 'Ext.data.Model',
        
        config: {
            fields: [
                {name: 'ID',  type: 'int', persist: false},
                {name: 'FolderName',  type: 'string'},
                {name: 'UpdatedDate',  type: 'date', dateFormat: 'c'},
                {name: 'FolderCount', type: 'int'},
                {name: 'IsPublic',  type: 'bool'},
                {name: 'IsSelected', type: 'bool'}
            ],
            
            idProperty: 'ID',
            
            proxy: {
                type: 'rest',
                url: GlobalFocus.util.Config.getRecruiterURL() + 'Folder',
                noCache: false,
                reader: {
                    type: 'json'
                }
            }
        }
    });

Thread Participants: 1

Tags for this Thread