I use ExtJS version 4.0.7. I have a data store with fields: recordName and recordDate. What I want to do is to sort these records by date, however recordDate format is: d/m/y. After sorting the records, I need to bind a grid panel with these records. At this point user still wants to see recordDate in d/m/y format.
As a summary, I have a recordDate field in a datastore with format d/m/y (because user wants to see it in that format in the grid panel), but to sort by date I need to reverse to format as y/m/d without changing the format in the grid panel.
Example:
recordDate in the datastore: 27/08/2012 (and this is what user want to see at the grid panel)
date format to sort by date: 2012/08/27
As @Evan mentioned:
If it's a date object, it's not relevant. If you're storing it as a string, then it's not date sorting, it's string sorting.
You need to set your model in a similar fashion:
Ext.define('MyModel', {
extend : 'Ext.data.Model',
fields : [{
name : 'recordDate',
type : 'date',
dateFormat : 'd/m/Y'
},{
name: 'recordName,
type: 'string'
}]
});
Since recordDate will now be a date object, you can use a datecolumn in your grid
columns:[{
text : 'Date',
dataIndex : 'recordDate',
xtype: 'datecolumn',
format:'d/m/Y'
},{
text : 'Name',
dataIndex : 'recordName'
}]