1. #11
    Sencha - Community Support Team friend's Avatar
    Join Date
    Apr 2011
    Posts
    895
    Answers
    106
    Vote Rating
    27
    friend has a spectacular aura about friend has a spectacular aura about

      0  

    Default


    I think I found the problem; you specified format instead of dateFormat in your 'fields' declaration. Here's your code sample with the correction made, where it now gives the desired effect:

    Code:
    Ext.onReady(function() {
    
        store = new Ext.data.Store({
            fields: [ 
             {name: 'testId', type: 'int'}, 
             {name: 'received_on', type: 'date', dateFormat: 'Y-m-d'} 
            ],
            data: [ {testId: 1, received_on: '2012-02-04'} ]
        });
        
        console.log( Ext.util.Format.date(store.getAt(0).get('received_on')) );
    });
    Last edited by friend; 6 Feb 2012 at 11:52 AM. Reason: typo

  2. #12
    Sencha User
    Join Date
    Feb 2011
    Posts
    35
    Answers
    2
    Vote Rating
    0
    nkezhaya is on a distinguished road

      0  

    Default


    Quote Originally Posted by friend View Post
    I think I found the problem; you specified format instead of dateFormat in your 'fields' declaration. Here's your code sample with the correction made, where it now gives the desired effect:

    Code:
    Ext.onReady(function() {
    
        store = new Ext.data.Store({
            fields: [ 
             {name: 'testId', type: 'int'}, 
             {name: 'received_on', type: 'date', dateFormat: 'Y-m-d'} 
            ],
            data: [ {testId: 1, received_on: '2012-02-04'} ]
        });
        
        console.log( Ext.util.Format.date(store.getAt(0).get('received_on')) );
    });
    Wow! Awesome!

    Do you know how to set this as the default dateFormat for all fields set with type "date"?

  3. #13
    Sencha - Community Support Team friend's Avatar
    Join Date
    Apr 2011
    Posts
    895
    Answers
    106
    Vote Rating
    27
    friend has a spectacular aura about friend has a spectacular aura about

      0  

    Default


    I don't know of any easy/built-in way of achieving this. You could possibly extend Ext.data.Store and override the constructor to handle this.

  4. #14
    Sencha User
    Join Date
    Feb 2011
    Posts
    35
    Answers
    2
    Vote Rating
    0
    nkezhaya is on a distinguished road

      0  

    Default


    Yeah, but then I'd need to go back and change every single Store in my app (there are about 30).

    Is there a way to override the Store constructor before any of them are instantiated?

  5. #15
    Sencha - Community Support Team friend's Avatar
    Join Date
    Apr 2011
    Posts
    895
    Answers
    106
    Vote Rating
    27
    friend has a spectacular aura about friend has a spectacular aura about

      0  

    Default


    This could get fairly nasty, fairly quick as you'll be delving into the guts of ExtJs pretty heavily. Regardless, here's how to globally override functionality of any ExtJs class, using Ext.data.Store for this particular example. Note that you can override multiple methods, if desired. Just separate them with a comma:

    Code:
    Ext.data.Store.override({
    
        /**
         * Creates the store.
         * @param {Object} config (optional) Config object
         */
        constructor: function(config) {
            // Clone the config so we don't modify the original config object
            config = Ext.Object.merge({}, config);
    
            var me = this,
                groupers = config.groupers || me.groupers,
                groupField = config.groupField || me.groupField,
                proxy,
                 data;
    
          <...snip...>
    
       }
    });

  6. #16
    Sencha User
    Join Date
    Jan 2012
    Posts
    1
    Vote Rating
    0
    riyaz1074 is on a distinguished road

      0  

    Default


    Hi nkezhaya ,

    Your post is really useful. I sent the date from the server in the format of
    "
    private static final SimpleDateFormat sdf2 = new SimpleDateFormat("MM/dd/yyyy");"
    Date dt = new Date();
    sd1 = sdf2.format(dt);
    modelMap.addAttribute("dateStr1", sd1);


    and retrieved in the extjs in the format
    "Ext.util.Format.date('${dateStr1}', "M d, Y"), "

    {
    text: Ext.util.Format.date('${dateStr1}', "M d, Y"),
    flex: 1,
    width: 100,
    dataIndex: 'col4',
    sortable: true,
    align: 'right',
    renderer: renderCurrency
    }
    [FONT='Helvetica Neue', Arial, 'Lucida Grande', sans-serif]Now it's coming properly. [/FONT]

Thread Participants: 2

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar