Created
September 24, 2014 11:38
-
-
Save Thinkscape/af2ee5ce940f863c3b29 to your computer and use it in GitHub Desktop.
Allow configurable filter date format in Ext.grid.filters.filter.Date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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