-
4 Jun 2012 9:56 AM #1
store.filter with a date range
store.filter with a date range
I have tried a couple of different methods to filter my store using a date range, I feel as though I am close but just off a bit - can you point me in the right direction?
Code:if ('fromdate' in $_GET) { store.filter([ {property: 'CollectTime' , value: record.get('CollectTime') >= $_GET['fromdate'] && record.get('CollectTime') <= $_GET['todate'] , anyMatch: true , caseSensitive: false} ]); }
-
4 Jun 2012 10:35 AM #2
store.filter() is for use in the store load listener.
If you want to apply a filter after, please use filterBy()
Scott.
-
4 Jun 2012 11:08 AM #3
so is this then incorrect even though it works?
I figured that if I showed my code a bit more it might help.Code:var events_ds = new Ext.data.JsonStore({ autoLoad: true, autoDestroy: true, url: '<% $base %>json/events/<% $eventWWN %>.json', storeId: 'events_ds', idProperty: 'id', fields: [ 'id', 'precedence', 'affectedWWN', 'eventType', 'color', 'CollectTime' ] listeners: { 'load': function(store) { if ('priority' in $_GET) { store.filter([ {property: 'precedence' , value: $_GET['priority'] , anyMatch: true , caseSensitive: false} ]); } if ('color' in $_GET) { store.filter([ {property: 'color' , value: $_GET['color'] , anyMatch: true , caseSensitive: false} ]); } } }
Just wanting to make sure I am doing this correctly.
-
4 Jun 2012 11:40 AM #4
Based on your original code, I was not sure you were using a button or store load.
Can you describe your problem in more detail. Is the filter not working at all, or just the wrong data?
Are you sure your values are resolving in time using $_GET() in your JS code?
Scott.
-
4 Jun 2012 4:20 PM #5
What I am trying to do is to add a third filter that will filter on a field called 'CollectTime'.
I have the form (that was created using ExtJS) and it is passing the variables 'fromdate' and 'todate' correctly (via $_GET).
Now, I am trying to add in the final filter that will allow the selected date range to be the only data that is shown, I'm just not sure of the syntax to make it work where I am trying to do a date range
Code:if ('fromdate' in $_GET) { store.filter([ {property: 'CollectTime' , value: record.get('CollectTime') >= $_GET['fromdate'] && record.get('CollectTime') <= $_GET['todate'] , anyMatch: true , caseSensitive: false} ]); }
-
5 Jun 2012 12:23 PM #6
Here is my entire set of code as it currently stands where I am grabbing the data and then filtering it:
Code:var events_ds = new Ext.data.JsonStore({ autoLoad: true, autoDestroy: true, url: '<% $base %>json/events/<% $eventWWN %>.json', storeId: 'events_ds', idProperty: 'id', fields: [ 'id', 'precedence', 'affectedWWN', 'eventType', 'color', 'CollectTime' ], listeners: { 'load': function(store) { if ('priority' in $_GET) { store.filter([ {property: 'precedence' , value: $_GET['priority'] , anyMatch: true , caseSensitive: false} ]); } if ('color' in $_GET) { store.filter([ {property: 'color' , value: $_GET['color'] , anyMatch: true , caseSensitive: false} ]); } if ('fromdate' in $_GET) { store.filter([ { fn: function(record) { return (record.get('CollectTime') >= $_GET['fromdate']) }, scope: this } ]); }


Reply With Quote
