1. #1
    Sencha User
    Join Date
    Sep 2011
    Posts
    1
    Vote Rating
    0
    awirdev is on a distinguished road

      0  

    Default Unanswered: Extjs Grid date column issue

    Unanswered: Extjs Grid date column issue


    Hello everyone, i have ran into a little issue with the data grid, and could use your help:

    I have a json data source that returns the date field as
    Code:
    "opened":"\/Date(1207022400000-0400)\/"
    . I have labeled the model field created as
    Code:
    { name: 'opened', type: 'date' },
    . In the grid, it's column is set up as
    Code:
    { text: "Date Closed", dataIndex: 'opened', xtype:'datecolumn', type: 'date', dateFormat: 'm/d/Y' },
    The issue is it's not rendering the date. I have been unable to find any examples out there showing how to handle this. Your help is greatly appreciated

    Thanks!

  2. #2
    Ext JS Premium Member twaindev's Avatar
    Join Date
    Sep 2009
    Posts
    223
    Vote Rating
    3
    Answers
    15
    twaindev is on a distinguished road

      0  

    Default


    Try this:

    Code:
    { name: 'opened', type: 'date', dateFormat: 'MS' },
    MS is a special format for Microsoft AJAX serialized dates.

    See Ext.Date.

    HTH

  3. #3
    Sencha User
    Join Date
    Nov 2010
    Posts
    24
    Vote Rating
    1
    Crockford is on a distinguished road

      0  

    Default


    Probably you are using a Microsoft Web service.

    The only solution I found these months is this:

    { name: 'opened', type: 'date', convert: function (v, record) { return new Date(parseInt(v.substr(6), 10)) } }

    using this you'll have inside your model a Date object that ExtJs will use at its best.
    It's an hack, I know and I don't like it but it works and it doesn't violate too many rules.

    Bye

  4. #4
    Sencha User
    Join Date
    Nov 2010
    Posts
    24
    Vote Rating
    1
    Crockford is on a distinguished road

      0  

    Default


    Quote Originally Posted by twaindev View Post
    Try this:

    Code:
    { name: 'opened', type: 'date', dateFormat: 'MS' },
    MS is a special format for Microsoft AJAX serialized dates.

    See Ext.Date.

    HTH
    You are missing the point.
    The problem is not formatting but converting date. The microsoft serializazion date format need to be converted to Date object, first of all.
    Too much problems if you avoid this.

    Bye

  5. #5
    Ext JS Premium Member twaindev's Avatar
    Join Date
    Sep 2009
    Posts
    223
    Vote Rating
    3
    Answers
    15
    twaindev is on a distinguished road

      0  

    Default


    @Crockford,

    On fields in a store or model the dateFormat config is used to specify how the date should be converted to a Date object.
    'MS' is the converter for Microsoft AJAX serialized dates. Have a look at src/core/src/lang/Date.js.

  6. #6
    Sencha User
    Join Date
    Nov 2010
    Posts
    24
    Vote Rating
    1
    Crockford is on a distinguished road

      0  

    Default


    Quote Originally Posted by twaindev View Post
    @Crockford,

    On fields in a store or model the dateFormat config is used to specify how the date should be converted to a Date object.
    'MS' is the converter for Microsoft AJAX serialized dates. Have a look at src/core/src/lang/Date.js.
    You are absolutely right.
    An Ext.data.Field type can be enriched with property dateFormat that I didn't known. I have to skill up with that documentation.

    { name : 'opened', type: 'date', dateFormat: 'MS' }

    Personally tested. It works.

  7. #7
    Sencha User
    Join Date
    Aug 2014
    Posts
    31
    Vote Rating
    3
    Answers
    1
    nobruds is on a distinguished road

      0  

    Default


    But that way displays the date on my grid panel like = 'Thu Feb 19 00:00:00 UTC-0200 2015',

    how can I change to D/M/Y ?

    My store { name: 'Date', type: 'date', dateFormat: 'MS' },
    My Grid column { id: 'Date', dataIndex: 'Date', header: 'Date', width: 80 },