1. #1
    Ext User
    Join Date
    Apr 2007
    Posts
    70
    Vote Rating
    0
    benny is on a distinguished road

      0  

    Default dateFormat error, function not found?

    dateFormat error, function not found?


    Hi,

    I have a feeling this is a dumb question with an easy answer, I just cannot see it right now.

    While using a grid, I'm trying to apply a date format with a renderer (as per the paging example).

    For example:
    Code:
    var cm = new Ext.grid.ColumnModel([      
    // some other rows                      
     {header: "TimeDate", width: 120, dataIndex: 'timestamp', type: 'date', renderer: renderDate}
            ]);
    
    // the renderer
    function renderDate(value){
      return String.format(value.dateFormat('M j, Y, g:i a'));
    }
    // also used this one with no luck
    function renderDate(value){
      return value.dateFormat('M j, Y, g:i a');
    }
    Firebug Error:
    value.dateFormat is not a function
    [Break on this error] return String.format(value.dateFormat('M j, Y, g:i a'));
    Not sure what is happening, can any one help?

  2. #2
    Ext JS Premium Member
    Join Date
    Mar 2007
    Location
    Virginia, USA
    Posts
    220
    Vote Rating
    0
    dfenwick will become famous soon enough

      0  

    Default


    Quote Originally Posted by benny View Post
    Hi,

    I have a feeling this is a dumb question with an easy answer, I just cannot see it right now.

    While using a grid, I'm trying to apply a date format with a renderer (as per the paging example).

    For example:
    Code:
    var cm = new Ext.grid.ColumnModel([      
    // some other rows                      
     {header: "TimeDate", width: 120, dataIndex: 'timestamp', type: 'date', renderer: renderDate}
            ]);
    
    // the renderer
    function renderDate(value){
      return String.format(value.dateFormat('M j, Y, g:i a'));
    }
    // also used this one with no luck
    function renderDate(value){
      return value.dateFormat('M j, Y, g:i a');
    }
    Firebug Error:


    Not sure what is happening, can any one help?
    Are you sure you're not calling that renderer from another data element as well? Or perhaps you're getting a date back that's not a valid date?

  3. #3
    Ext User
    Join Date
    Apr 2007
    Posts
    379
    Vote Rating
    0
    sfwalter is on a distinguished road

      0  

    Default


    Are you sure the value is a Date object? It might help if you post the creation of the datastore so that we can see your reader configuration.

    scott.

  4. #4
    Ext User
    Join Date
    Apr 2007
    Posts
    70
    Vote Rating
    0
    benny is on a distinguished road

      0  

    Default


    Quote Originally Posted by dfenwick View Post
    Are you sure you're not calling that renderer from another data element as well? Or perhaps you're getting a date back that's not a valid date?
    No, I just created the renderer - so it is only called once. The date format is coming through valid (2007-01-21 12:03:23).
    Thanks

  5. #5
    Ext User
    Join Date
    Apr 2007
    Posts
    70
    Vote Rating
    0
    benny is on a distinguished road

      0  

    Default


    Quote Originally Posted by sfwalter View Post
    Are you sure the value is a Date object? It might help if you post the creation of the datastore so that we can see your reader configuration.

    scott.
    Hmm, you may be correct, I do have a bit ob confusion of where to declare the field as data (in dataStore or in columnModel).... here is the data store:

    Code:
    var ds = new Ext.data.Store({
            proxy: new Ext.data.HttpProxy({url: 'get_json.php'}),
            reader: new Ext.data.JsonReader({
               root:"records",
               totalProperty: 'totalCount',
               id:"id"
            }, ['id','version','report_number','timestamp','store_name','store_number','icc']
            
            )
        });
    Many Thanks

  6. #6
    Ext User
    Join Date
    Apr 2007
    Posts
    379
    Vote Rating
    0
    sfwalter is on a distinguished road

      0  

    Default


    I believe in your reader for your column that you want to treat as a Date data type. You need to identify it as date type as well as the format of the incoming date text.

    For example:

    {name: 'duedate', type:'date', dateFormat:'n/j/Y h: i a'}

  7. #7
    Ext User
    Join Date
    Apr 2007
    Posts
    70
    Vote Rating
    0
    benny is on a distinguished road

      0  

    Default


    thanks sfwalter, that makes sense. Do you have any idea what the date format mask is for timestamp? (2007-04-30 16:22:34 - for example) I can not find any reference to this is the API docs.

  8. #8
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854
    Vote Rating
    4
    tryanDLS is on a distinguished road

      0  

    Default


    Look at the docs for the Date class - there are a some examples there and also a link to the PHP site on which the formats are based - I think there are more examples there.

  9. #9
    Ext User
    Join Date
    Apr 2007
    Posts
    70
    Vote Rating
    0
    benny is on a distinguished road

      0  

    Default


    Fantastic, many thanks guys. It now works
    For reference, the timestamp dateformat is:
    Code:
    'Y-m-d H:i:s'

  10. #10
    Sencha User
    Join Date
    Jun 2007
    Posts
    260
    Vote Rating
    4
    hallikpapa is on a distinguished road

      0  

    Default


    I am having this exact same problem. What am I staring at that I am missing?

    Code:
       function renderDate(value){				
    		return value.dateFormat('Y-m-d H:i:s');
                };
    my error in firebug:

    value.dateFormat is not a function
    renderDate("2008-01-08 00:49:38")

    My datetime stamp is the same as benny's, so I am obviously missing something stupid.

    I mean if I comment out the renderer, It displays data fine. Just trying to understand the grid-php example completely and why it isn't working for me.

    Code:
     },{
                    	dataIndex: 'FirstCall',
                        header: "First Call", 
                        //renderer: renderDate, 
                        sortable: true, 
                        width: 20
                    },{
                    	dataIndex: 'LastCall',
                        header: "LastCall", 
                        //renderer: renderDate, 
                        sortable: true, 
                        width: 20               
    				},

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..."