1. #1
    Sencha User
    Join Date
    Jul 2011
    Posts
    12
    Vote Rating
    0
    jason199x is on a distinguished road

      0  

    Default Answered: Sort Date Grid

    Answered: Sort Date Grid


    Hey there everyone,
    I am having a problem with sorting a column of type 'date' on my grid. I am getting a JSON object in dateFormat 'U' (e.g. '1302539400000') and I am trying to render this in a 'm-d-Y g:i' format using a convert function in 'datetime' model field. I am able to get this to render correctly but I am unable to sort this column.

    Here is the field in my model.
    Code:
    fields : [
              { 
                  name : 'datetime', 
                  type: 'date',
                  dateFormat: 'm-d-Y g:i:s',
                  convert : function(v, rec) {
                         var dt = new Date(v);
                         return Ext.Date.format(dt, 'm-d-Y g:i:s');
                  }
              }
    ]
    and here is the column in my grid.

    Code:
    columns:[
                         {
                             header: 'Time', 
                             dataIndex: 'datetime',
                             width: 135,
                             menuDisabled: true,
                             sortable: true
                         }
    ]
    I am probably missing something small, but with all the tweaking I have done I have yet to find a solution. Sorry if there has already been a post about this, but so far I haven't found a fix. Any help is appreciated. Thanks!

  2. Try this:
    1. Get rid of the convert function on the field.
    2. Set the field's dateFormat to 'U'. The field will now contain Date object and it knows how to sort them.
    3. Switch the column to xtype: 'datecolumn'.
    4. Set the column's format to 'm-d-Y g:i:s'. This will render the Date objects correctly in the column.

  3. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,588
    Answers
    540
    Vote Rating
    322
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    Try this:
    1. Get rid of the convert function on the field.
    2. Set the field's dateFormat to 'U'. The field will now contain Date object and it knows how to sort them.
    3. Switch the column to xtype: 'datecolumn'.
    4. Set the column's format to 'm-d-Y g:i:s'. This will render the Date objects correctly in the column.

  4. #3
    Sencha User
    Join Date
    Jul 2011
    Posts
    12
    Vote Rating
    0
    jason199x is on a distinguished road

      0  

    Default


    Thanks skirtle!
    I can now sort the date column. Unfortunately I'm getting some weird dates now. When I put the epoch time into a conversion website it returns the correct date
    Mon Apr 11 2011 09:30:00 GMT-0700 (Pacific Daylight Time), but in my extjs grid it returns as Mon Oct 30 43245 05:00:00 GMT-0700 (Pacific Daylight Time). Is 'U' the correct format to use, or is there some additional formatting I need to look at?

    EDIT: I think my JSON object is sending back epoch time in milliseconds, not seconds. To fix this I just changed my dateFormat from 'U' to 'time'.
    Last edited by jason199x; 28 Oct 2011 at 1:50 PM. Reason: Update Info

Thread Participants: 1

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..." hd porno faketaxi