Come posso ottenere una griglia per mostrare il tempo corretto in Extjs 4?
Domanda
Ho un GridPanel
con Extjs 4. Una delle colonne restituisce un timestamp nel formato seguente:
1900-01-01 14:00:00.0
.
Questa è la mia colonna dal mio jsonstore
{
name: 'clockOut',
mapping: 'clockOut',
dateFormat: 'H:i A',
type: 'date'
}
.
Voglio solo mostrare la sezione time
ma tutto quello che ottengo è una colonna vuota.
Quando rimuovo il type: 'data'
ottengo i dati ma nel formato sopra.
Qualche suggerimento?
Grazie
Soluzione
You could add a renderer to the column that formats it the way you want:
{
name: 'clockOut',
mapping: 'clockOut',
renderer: dateRenderer
}
And then a function for dateRenderer
:
function dateRenderer(value, id, r) {
var d = new Date(r.data['clockOut']);
return d.format('H:i A');
}
Altri suggerimenti
You could even use ExtJS built in renderer instead of defining your own function:
renderer: Ext.util.Format.dateRenderer('H:i A')
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow