View Full Version : Clarification on filterUpdate event

13 Feb 2012, 2:12 PM
I am not finding a lot of documention on the 'filterUpdate' event that takes place when I select the filters from my column headings and filter the LOCAL store. The issue is probably trivial. Let's assume we are looking at a grid that list movies and studios producing those movies. Perhaps 50 or so are listed. grid.store.getCount() would return "50". Now suppose we want to select just "Disney Movies", so we go to our "Studio" column heading, check the box next to "Disney" and the list condenses/filters to show 20 movies. I am placing a listener on the "filterUpdate" event and in that function, I update the panel header that says "Filter applied: n movies displayed", where n is the count of records. However, in the function executed on "filterUpdate", the count contains the original count of 50, not the subset of 20.

var lmovie_grid = Ext.ComponentManager.get('movie_grid');
movie_grid.on('filterUpdate', me.onFilterUpdate, me);

onFilterUpdate: function(grid) {
var viewTitle = Ext.ComponentManager.get('main_panel');
viewTitle.setTitle('Filter applied: ' + grid.store.getCount() + ' movies displayed.');


The console log and the panel header both display 50. When I undo the filter, they then display 20! It is as though "filterUpdate" is triggered before the store is filtered, not after.

Am I doing something wrong? Should I be using a different event?

Thanks for any help.

14 Feb 2012, 5:26 AM
Any event a filter menu fires will fire the filterupdate event. It sounds like a timing issue that your listener is fired before the store is filtered.

14 Feb 2012, 5:26 AM
See if you have better luck with the datachanged event on the store.

14 Feb 2012, 6:43 AM
Genius! Thanks again, Mitchell. :D