1. #1
    Sencha User harman's Avatar
    Join Date
    Jul 2011
    Location
    India
    Posts
    131
    Answers
    2
    Vote Rating
    3
    harman is on a distinguished road

      0  

    Default Answered: String Date to ExtJS Date Formatted

    Answered: String Date to ExtJS Date Formatted


    Hi,

    I have a Date field that comes to me as a String in JSON like
    Code:
    "09-05-2012 7:33 AM"
    I have to show it as a Date with the same format in my Grid column.
    (I am converting it to date as grid column does not sort it as Date but String)
    How do i do it?
    If i do this in my model
    Code:
    {name: 'someDate', type: 'String', convert:function(value, records){                 var rcptDate=new Date(value);
                     return Ext.Date.format(rcptDate, 'm-d-Y g:i A');
                 }}
    i get value like NaN-NaN-0NaN 12:NaN PM

    What am i doing wrong?
    Or is it that it cant be converted?

  2. You can define the field in the store as follows:

    Code:
    {
        name: 'someDate',
        type: 'date',
        dateFormat: 'm-d-Y g:i A'
    }
    and then put the following renderer on your grid column:

    Code:
    renderer: Ext.util.Format.dateRenderer('m-d-Y g:i A')

  3. #2
    Touch Premium Member
    Join Date
    Feb 2011
    Location
    NJ
    Posts
    311
    Answers
    59
    Vote Rating
    52
    droessner is a jewel in the rough droessner is a jewel in the rough droessner is a jewel in the rough

      0  

    Default


    You can define the field in the store as follows:

    Code:
    {
        name: 'someDate',
        type: 'date',
        dateFormat: 'm-d-Y g:i A'
    }
    and then put the following renderer on your grid column:

    Code:
    renderer: Ext.util.Format.dateRenderer('m-d-Y g:i A')

  4. #3
    Sencha User Tim Toady's Avatar
    Join Date
    Feb 2010
    Location
    Pennsylvania
    Posts
    536
    Answers
    61
    Vote Rating
    70
    Tim Toady is a jewel in the rough Tim Toady is a jewel in the rough Tim Toady is a jewel in the rough Tim Toady is a jewel in the rough

      0  

    Default


    I would also use the date type for the field as droessner stated, but I would be slightly more lazy and use the datecolumn

  5. #4
    Sencha User harman's Avatar
    Join Date
    Jul 2011
    Location
    India
    Posts
    131
    Answers
    2
    Vote Rating
    3
    harman is on a distinguished road

      0  

    Default


    Thanks droessner,

    Exactly what i wanted.
    However i will need a little more testing to see if the Sorting works correctly.

Thread Participants: 2

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..."