Results 1 to 7 of 7

Thread: how to render datetime in a particular format in extjs 3.4

  1. #1

    Default how to render datetime in a particular format in extjs 3.4

    Hi,
    I need to display to datetime in date format inorder to do sorting.Below is mt columnModel to dispaly it.



    header : 'DateTime(dd:mm:yy)</b>',
    dataIndex : 'time',
    renderer: Ext.util.Format.dateRenderer('m-d-Y H:i')

    and in store I have given the type :'date' and format:'m-d-Y H:i'. But its not displaying anything.Please do help me in this.

    Thanks,
    Vamshi

  2. #2
    Sencha User
    Join Date
    Dec 2009
    Posts
    425

    Default

    This works for me...
    In store
    Code:
    {name: 'start_date', type: 'date', dateFormat: 'Y-m-d\TH:i:sP'}
    In Column model
    Code:
    {header: "Start Date", width: 90, dataIndex: 'start_date', renderer: Ext.util.Format.dateRenderer('Y-m-d')}

  3. #3

    Default how to render datetime in a particular format in extjs 3.4

    Hi Raj,

    It hav'nt worked for me.In my case sorting is not working properly..


    Regards,
    Vamshi

  4. #4
    Sencha User
    Join Date
    Dec 2009
    Posts
    425

    Default

    Does your column config have sortable: true?
    If so, check the date format returned from your server.
    That should be the same as the dateFormat in store.

  5. #5

    Default how to render datetime in a particular format in extjs 3.4:

    Hi Raj,


    Thanks alot ...Its fixed


    Thanks,
    Vamshi

  6. #6
    Sencha User
    Join Date
    Jan 2011
    Posts
    549

    Default

    It sounds like the date format being returned from the server does not match what you are stating it is inside your store's field.

    So for example, the below expects the format returned from the server to be "2013-01-02 12:34:56".
    Code:
    var fields = [
    	{name:'datetime', mapping:'datetime', type:'date', dateFormat:'Y-m-d H:i:s'}
    ];
    	
    var store = new Ext.data.JsonStore({
    	// USUAL CONFIG HERE
    	fields: fields
    });
    If your returned format differs from that stated in your store, then it will fail, and display blank values if you try and apply different date rendering in your grid column.

  7. #7

    Default how to render datetime in a particular format in extjs 3.4

    Hi willigogs,

    You are right...

    This is the field in store ,
    { name : 'time',mapping : 'time',type: 'date',dateFormat: 'd-m-Y H:i'}

    &
    Here is the columnModel
    {header: "Time", width: 90, dataIndex: 'time',format:'d-m-Y H:i', xtype: 'datecolumn',
    renderer : function(val, meta, record) {return '<div align="center">' + val + '</div>';} }


    This works well. Format Should be specified same everywhere.




    Thanks,
    Vamshi

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •