dlstrawn
04-14-2010, 11:08 AM
How do I format a date in a grid? Can't I do it in the header parm? See code below:
{header: '<b>ETA DC</b>', width:100, sortable:true, renderer:Ext.util.Format.date(p1,"p2"), dataIndex:'AF01ETAD'}
If the code above is valid, what would I use for the 1st date parm (p1), and for the second date parm ("p2")?
If this is not valid, how would I do it?
Here is the application of some info I found on the internet, but it doesn't work either:
Fields in the JSONStore:
fields: ["AF01CNO","AF01INO","AF01BL","AF01CARR","AF01SAIL","AF01CBPC","AF01ETAP","AF01RP", {name: 'AF01ETAD', type: 'date', dateFormat: 'Y/m/d'}, "AF01RNO"]
Column in the Grid:
{header: '<b>ETA DC</b>', width:100, sortable:true, renderer:Ext.util.Format.dateRenderer('m/d/Y'), dataIndex:'AF01ETAD'}
dlstrawn
04-14-2010, 03:06 PM
It is field AF01ETAD:
{"totalCount":26.00000,"autogrid":[{"AF01CNO":"MSKU4526410","AF01INO":"GB0296/10/C","AF01BL":"801807299","AF01CARR":"MAERSK LINE","AF01SAIL":0,"AF01CBPC":"1601","AF01ETAP":0,"AF01RP":"DL","AF01ETAD":20100406,"AF01RNO":1861},{"AF01CNO":"APMU-4519991","AF01INO":"GB0297/10/C","AF01BL":"801807318","AF01CARR":"MAERSK LINE","AF01SAIL":0,"AF01CBPC":"1601","AF01ETAP":0,"AF01RP":"DL","AF01ETAD":20100406,"AF01RNO":1862},{"AF01CNO":"HDMU4718127","AF01INO":"VN09120063","AF01BL":"HCM10S0321","AF01CARR":"MAERSK LINE","AF01SAIL":0,"AF01CBPC":"1601","AF01ETAP":0,"AF01RP":"DL","AF01ETAD":20100415,"AF01RNO":1859},{"AF01CNO":"MSKU0963095","AF01INO":"GB0331/10/C","AF01BL":"801819108","AF01CARR":"MAERSK LINE","AF01SAIL":0,"AF01CBPC":"1601","AF01ETAP":0,"AF01RP":"DL","AF01ETAD":20100416,"AF01RNO":1863},{"AF01CNO":"TGHU7223235","AF01INO":"PP2210PPP","AF01BL":"550621261","AF01CARR":"MAERSK LINE","AF01SAIL":0,"AF01CBPC":"1601","AF01ETAP":0,"AF01RP":"DL","AF01ETAD":20100417,"AF01RNO":1884},{"AF01CNO":"MSKU-9423307","AF01INO":"22-10/PPP","AF01BL":"550621261","AF01CARR":"MAERSK LINE","AF01SAIL":0,"AF01CBPC":"1601","AF01ETAP":0,"AF01RP":"DL","AF01ETAD":20100417,"AF01RNO":1885},{"AF01CNO":"MSKU4622899","AF01INO":"GB0375/10/C","AF01BL":"801830095","AF01CARR":"MAERSK LINE","AF01SAIL":0,"AF01CBPC":"1601","AF01ETAP":0,"AF01RP":"DL","AF01ETAD":20100419,"AF01RNO":1873},{"AF01CNO":"FSCU-9404234","AF01INO":"NO32 - 10/PPP","AF01BL":"550831339","AF01CARR":"MAERSK LINE","AF01SAIL":0,"AF01CBPC":"1601","AF01ETAP":0,"AF01RP":"DL","AF01ETAD":20100426,"AF01RNO":1888},{"AF01CNO":"PONU-1292073","AF01INO":"29-10/PPP","AF01BL":"","AF01CARR":"MAERSK LINE","AF01SAIL":0,"AF01CBPC":"1601","AF01ETAP":0,"AF01RP":"DL","AF01ETAD":20100427,"AF01RNO":1876},{"AF01CNO":"MRKU0121984","AF01INO":"08E/PPP-ANV/10","AF01BL":"550728416","AF01CARR":"MAERSK LINE","AF01SAIL":0,"AF01CBPC":"1601","AF01ETAP":0,"AF01RP":"DL","AF01ETAD":20100428,"AF01RNO":1875},{"AF01CNO":"PONU-7279000","AF01INO":"KKCL/SEBL/08110","AF01BL":"801841584","AF01CARR":"MAERSK LINE","AF01SAIL":0,"AF01CBPC":"1601","AF01ETAP":0,"AF01RP":"DL","AF01ETAD":20100507,"AF01RNO":1865},{"AF01CNO":"PONU-8036957","AF01INO":"KKCL/SEBL/08210","AF01BL":"801841587","AF01CARR":"MAERSK LINE","AF01SAIL":0,"AF01CBPC":"1601","AF01ETAP":0,"AF01RP":"DL","AF01ETAD":20100507,"AF01RNO":1866},{"AF01CNO":"MRKU-0387212","AF01INO":"KKCL/SEBL/08310","AF01BL":"801841592","AF01CARR":"MAERSK LINE","AF01SAIL":0,"AF01CBPC":"1601","AF01ETAP":0,"AF01RP":"DL","AF01ETAD":20100507,"AF01RNO":1867},{"AF01CNO":"FSCU-6991992","AF01INO":"KKCL/SEBL/08810","AF01BL":"801841600","AF01CARR":"MAERSK LINE","AF01SAIL":0,"AF01CBPC":"1601","AF01ETAP":0,"AF01RP":"DL","AF01ETAD":20100507,"AF01RNO":1868},{"AF01CNO":"TTNU-9255525","AF01INO":"KKCL/SEBL/08410","AF01BL":"801841590","AF01CARR":"MAERSK LINE","AF01SAIL":0,"AF01CBPC":"1601","AF01ETAP":0,"AF01RP":"DL","AF01ETAD":20100507,"AF01RNO":1869},{"AF01CNO":"MSKU-8343505","AF01INO":"KKCL/SEBL/08510","AF01BL":"801841593","AF01CARR":"MAERSK LINE","AF01SAIL":0,"AF01CBPC":"1601","AF01ETAP":0,"AF01RP":"DL","AF01ETAD":20100507,"AF01RNO":1870},{"AF01CNO":"MSKU-8219346","AF01INO":"KKCL/SEBL/08610","AF01BL":"801841596","AF01CARR":"MAERSK LINE","AF01SAIL":0,"AF01CBPC":"1601","AF01ETAP":0,"AF01RP":"DL","AF01ETAD":20100507,"AF01RNO":1871},{"AF01CNO":"MSKU-0730051","AF01INO":"KKCL/SEBL/08710","AF01BL":"801841598","AF01CARR":"MAERSK LINE","AF01SAIL":0,"AF01CBPC":"1601","AF01ETAP":0,"AF01RP":"DL","AF01ETAD":20100507,"AF01RNO":1872},{"AF01CNO":"MSKU-9942658","AF01INO":"KKCL/SEBL/10210","AF01BL":"801863291","AF01CARR":"MAERSK LINE","AF01SAIL":0,"AF01CBPC":"1601","AF01ETAP":0,"AF01RP":"DL","AF01ETAD":20100511,"AF01RNO":1877},{"AF01CNO":"PONU-7364592","AF01INO":"KKCL/SEBL/10310","AF01BL":"801863292","AF01CARR":"MAERSK LINE","AF01SAIL":0,"AF01CBPC":"1601","AF01ETAP":0,"AF01RP":"DL","AF01ETAD":20100511,"AF01RNO":1878},{"AF01CNO":"MSKU-8324824","AF01INO":"KKCL/SEBL/10410","AF01BL":"801863293","AF01CARR":"MAERSK LINE","AF01SAIL":0,"AF01CBPC":"1601","AF01ETAP":0,"AF01RP":"DL","AF01ETAD":20100511,"AF01RNO":1879},{"AF01CNO":"PONU-8208640","AF01INO":"KKCL/SEBL/10510","AF01BL":"801863294","AF01CARR":"MAERSK LINE","AF01SAIL":0,"AF01CBPC":"1601","AF01ETAP":0,"AF01RP":"DL","AF01ETAD":20100511,"AF01RNO":1880},{"AF01CNO":"TTNU-52464519","AF01INO":"KKCL/SEBL/10610","AF01BL":"801863295","AF01CARR":"MAERSK LINE","AF01SAIL":0,"AF01CBPC":"1601","AF01ETAP":0,"AF01RP":"DL","AF01ETAD":20100511,"AF01RNO":1881},{"AF01CNO":"TRIU-5255373","AF01INO":"KKCL/SEBL/10710","AF01BL":"801863297","AF01CARR":"MAERSK LINE","AF01SAIL":0,"AF01CBPC":"1601","AF01ETAP":0,"AF01RP":"DL","AF01ETAD":20100511,"AF01RNO":1882},{"AF01CNO":"TTNU-55576114","AF01INO":"KKCL/SEBL/10810","AF01BL":"801863298","AF01CARR":"MAERSK LINE","AF01SAIL":0,"AF01CBPC":"1601","AF01ETAP":0,"AF01RP":"DL","AF01ETAD":20100511,"AF01RNO":1883}]}
dlstrawn
04-19-2010, 10:37 AM
OK. I got the date to format correctly with the following code:
jsonstore:
fields: [
{name:"AF01CNO"},
{name:"AF01INO"},
{name:"AF01BL"},
{name:"AF01CARR"},
{name:"AF01SAIL"},
{name:"AF01CBPC"},
{name:"AF01ETAP"},
{name:"AF01RP"},
{name:"AF01ETAD", type:'date', dateFormat:'Ymd'},
{name:"AF01RNO"}
]
grid:
columns: [
{header:'<b>Container</b>', width:125, sortable:true, dataIndex:'AF01CNO'},
{header:'<b>Invoice</b>', width:125, sortable:true, dataIndex:'AF01INO'},
{header:'<b>Bill of Lading</b>', width:125, sortable:true, dataIndex:'AF01BL'},
{header:'<b>Carrier</b>', width:125, sortable:true, dataIndex:'AF01CARR'},
{header:'<b>Sail Date</b>', width:100, sortable:true, dataIndex:'AF01SAIL'},
{header:'<b>To Port</b>', width:100, sortable:true, dataIndex:'AF01CBPC'},
{header:'<b>ETA Port</b>', width:100, sortable:true, dataIndex:'AF01ETAP'},
{header:'<b>To Port</b>', width: 100, sortable:true, dataIndex:'AF01RP'},
{header:'<b>ETA DC</b>', width:100, sortable:true, renderer:Ext.util.Format.dateRenderer('m/d/Y'), dataIndex:'AF01ETAD'}
The date now looks the way I want it to. Only problem now is, I can't edit a grid row. When I double click on a row to edit, I get the error message "Hmmm...could not retrieve the record". Any ideas?
dlstrawn
04-21-2010, 10:05 AM
Richard,
It is my belief that however you send data to the front-end is how it should be returned. All formatting/converting should be done on the front end without using server cycles. Correct me if I am wrong.
Therefore, since the data from the server is a 8,0 number showing ..."AF01ETAD":20100507..., I would like to send it back the same way. I have defined the date in the jsonstore as type:'date' (for display purposes) and it works fine. The problem is when I send it back. Currently, it is going back as ..."AF01ETAD":2010-05-07T00:00:00... This means using server cycles to parse the date back to an 8,0 number.
I am showing this same date in the form I am using for editing as 20100507(using daterenderer), so I think it can be done in the post string from the browser, but the way to do this eludes me(can't fugure out how to use daterenderer on the AF01ETAD: section [see below]). So, that is what I am asking. How do I format the post string in the front end code? See example below: (this comes from autocode generated code by the way)
var editWindow = new Ext.Window({
id: 'editWindow',
title: 'Edit Record',
modal: true,
iconCls: 'edit',
layout: 'fit',
width: 200,
height: 330,
closeAction: 'hide',
buttonAlign: 'left',
closable: false,
listeners:{
beforeshow:function(){
Ext.getBody().mask('<B>Retrieving record details...</B>', 'x-msg-loading');
Ext.Ajax.request({
url: 'vvcall.pgm',
params: {
action: 'getRecord',
pgm: 'DPA0006R',
AF01ETAD: currentRecord.data.AF01ETAD,
AF01RNO: currentRecord.data.AF01RNO
I need some way the format the bold red line above to output a post string that looks like this: ..."AF01ETAD":20070507... or possibly ..."AF01ETAD":"20070507"... Either way would be acceptable. I posted this question on the ExtJS forum, but without much success. Thanks.
vBulletin® v3.7.1, Copyright ©2000-2010, Jelsoft Enterprises Ltd.