-
30 Apr 2007 3:17 AM #1
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:
Firebug Error: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'); }
Not sure what is happening, can any one help?value.dateFormat is not a function
[Break on this error] return String.format(value.dateFormat('M j, Y, g:i a'));
-
30 Apr 2007 5:20 AM #2
-
30 Apr 2007 6:02 AM #3
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.
-
30 Apr 2007 6:14 AM #4
-
30 Apr 2007 6:16 AM #5
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:
Many ThanksCode: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'] ) });
-
30 Apr 2007 7:06 AM #6
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'}
-
30 Apr 2007 7:23 AM #7
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.
-
30 Apr 2007 7:42 AM #8
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.
Tim Ryan
Read BEFORE posting a question / BEFORE posting a Bug
Use Google to Search - API / Forum
API Doc (4.x | 3.x | 2.x | 1.x) / FAQ / 1.x->2.x Migration Guide / 2.x->3.x Migration Guide
-
30 Apr 2007 8:03 AM #9
Fantastic, many thanks guys. It now works

For reference, the timestamp dateformat is:Code:'Y-m-d H:i:s'
-
24 Feb 2008 1:58 PM #10
I am having this exact same problem. What am I staring at that I am missing?
my error in firebug:Code:function renderDate(value){ return value.dateFormat('Y-m-d H:i:s'); };
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 },


Reply With Quote