View Full Version : Question Regarding Grid Sorting..

13 Oct 2009, 9:52 PM
Hi all,
we are using grid to create tables in an application...in one of the colomn we have both date and string combined as one field...and when we tring to sort it, it is not sorting @ date..it taking tht field as string and sortin it.

Please explain the best possible way to sort it by Date.

14 Oct 2009, 1:45 AM
Create an own sortType, e.g. for a field that ends with a date in 'yyyy-mm-dd' notation:

Ext.data.SortTypes.asMixedDate = function(s) {
if( /(\d\d\d\d-\d\d-\d\d)$/.exec(s) ) {
return Date.parseDate(RegExp.$1, 'Y-m-d');
return Date.parseDate('1970-01-01', 'Y-m-d');

and then use that type in the field definition of the store

fields: [
{ name: 'mydatefield', sortType: 'asMixedDate' },