Skip to content

Instantly share code, notes, and snippets.

@Thinkscape
Created September 24, 2014 11:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Thinkscape/af2ee5ce940f863c3b29 to your computer and use it in GitHub Desktop.
Save Thinkscape/af2ee5ce940f863c3b29 to your computer and use it in GitHub Desktop.
Allow configurable filter date format in Ext.grid.filters.filter.Date
/**
* Allow configurable date format when creating a store filter.
*
* To set a global default app-wise, include this fix and use something like:
*
* Ext.grid.filters.filter.Date.prototype.dateWriteFormat = 'c';
*
*/
Ext.define('Ext.bugfix.GridFilterDate', {
override: 'Ext.grid.filters.filter.Date',
config: {
/**
* @cfg {String} dateWriteFormat
*
* The date format to use when creating store filter. For available formats see {@link Ext.Date.format}.
* Defaults to 'timestamp'
*/
dateWriteFormat: null
},
convertValue: function (value, convertToDate) {
var dateFormat;
if (convertToDate && !Ext.isDate(value)) {
value = Ext.isDate(value);
} else if (!convertToDate && Ext.isDate(value)) {
dateFormat = this.getDateWriteFormat();
if (dateFormat) {
value = Ext.Date.format(value, dateFormat);
} else {
value = (+value);
}
}
return value;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment