0

I have this code that is allowing me to filter my store on a single column:

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) {
                                store.filter( 'color', $_GET['color'] )
                         }
                 }
        });

Now, I am wanting to filter on multiple columns.

I was thinking to change the 'listeners' line to this but it is working and I dont see another example where I can use multiple filters - got any suggestions?

listeners:
     { 'load': function(store) {
            store.filter( 'color', $_GET['color'] ),
            store.filter( 'priority', $_GET['priority'] )
     }
}

Update: This is ExtJs 3.4

sha
  • 17,824
  • 5
  • 63
  • 98
Mike
  • 109
  • 1
  • 5
  • 13

1 Answers1

0

If you use filters as in a code you posted you will get logical AND operation. If you need to have something more complicated you can simply create a filter function like this:

store.filter(Ext.create('Ext.util.Filter', {
   filterFn: function(item) { 
       return item.get('color') == 'RED' || item.get('priority') == 'low'; 
   }, 
}))
sha
  • 17,824
  • 5
  • 63
  • 98
  • when I plug that code into my data, I get no filtering at all – Mike May 29 '12 at 19:46
  • I just used:store.filter(Ext.create('Ext.util.Filter', { filterFn: function(item) { return item.get('color') == $_GET['color'] && item.get('priority') == $_GET['priority']; }, })) – Mike May 29 '12 at 19:56
  • which I should mean that both the color and priority should be those values before it should show correct? Im just getting the entire set of data with no filters applied – Mike May 29 '12 at 19:56
  • Yes. It would work like this. Are you on ExtJs4.0x or something else? – sha May 29 '12 at 20:00
  • well, it looks like we are on 3.4 so that is our issue – Mike May 29 '12 at 20:06
  • This might be the reason. My answer was related to ExtJs 4.x – sha May 29 '12 at 20:39