PDA

View Full Version : How to set system date format to date column of grid



pra123@
16 May 2013, 7:14 AM
Hi,

I have a grid with date column.
I want to display the date in date column with same format what i have in my system.
If i will change my system date format, Once i will refresh grid then date column should show new format.

To achieve this what format i will set for date column?
Is it possible or not. Please help?

tobiu
16 May 2013, 7:44 AM
For localisation, the framework has several languages covered including date formats that make sense.

If you only want to change the date format, i would go for something like:

date.toLocaleString()

pra123@
16 May 2013, 7:56 AM
Hi tobiu,
Thanks for quick reply,
yes, i want to change only date format.
But my problem is, in grid how i will do this for each row of date column.
Please refer my snapshot.
first column is my date string and second column is date column.
we can make out second column display m/d/y but my system format d-m-y.
how i will do this?

tobiu
17 May 2013, 8:52 AM
the date column requires a format:
http://docs.sencha.com/extjs/4.2.0/#!/api/Ext.grid.column.Date

when you look at the source, it only applies:



initComponent: function(){
if (!this.format) {
this.format = Ext.Date.defaultFormat;
}

this.callParent(arguments);
},

defaultRenderer: function(value){
return Ext.util.Format.date(value, this.format);
}


you can put in your toLocaleString format into the format config or you can extend / override the date column class to fullfil your needs.