View Full Version : Inconsistent behavior of Store filters generated with an Ext.form.field.Date

28 Aug 2013, 2:33 PM
I have a grid that enables users to filter the results based on the create date by selecting a date within a Ext.form.field.Date control. The server-side logic is to filter out all records that were created after the selected date. When activated the grid performs an AJAX call with a filter param that looks like this:


Note that the "ending" date is rendered with the time as 00:00:00. This is what the Date control emits, the Store builds the AJAX request with it verbatim, and that's fine for my purpose.

Subsequently I've added a feature that generates a static PDF report that needs to use the same filtered data as used by my Ext grid. To do this I wanted to grab the filter from the store and post the values back to the server to process the report. The problem I'm seeing is that when I retrieve this filter from the store using dataStore.filters.getByKey('timebox') it comes back with a date that has been offset by 6 hours, or rather it's in Zulu time:


The different format causes the report I generate to have different data from what is displaying in the grid.

I can think of some ways to compensate for this behavior, but I'm wondering if this is a bug or whether there's some special usage considerations with filters containing date type values.

Here's the code that adds the filter to the store:

var currTimebox = {};
currTimebox['period'] = Ext.getCmp('timeFilterPeriod').getValue()['days'];
currTimebox['ending'] = Ext.getCmp('timeFilterEnd').getValue(); // returns time in form 2013-08-02T00:00:00
dataStore.filters.add('timebox', new Ext.util.Filter({ property: 'created_at', value: currTimebox}));

And here is where I retrieve the "timebox" filter from the store:

var timeboxFilter = dataStore.filters.getByKey('timebox');
var ending = timeboxFilter['ending'] // returns in form 2013-08-02T06:00:00.000Z

28 Aug 2013, 3:08 PM
The fix I used was to convert the Date coming from the Ext.form.field.Date to Zulu format using toISOString(), which apparently the Store does under the hood when you request a filter back with a Date type value: