Search code examples
extjsgridextjs4filteringextjs4.1

Extjs, filtering grid dynamically


I'm developping with extjs4.
I have two grids as shown in the image, I want when I click on the line of Grid Panel 1 that contanis Number 1, the Grid Panel 2 will show only lines that contains Number 1.

enter image description here


Solution

  • That is pretty much straightforward; subscribe to the select event of the first grid and within that handler filter the store of the second grid. That's it.

    grid1.on('select', function(grid,record) { 
       grid2.store.clearFilter(true); // see http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.Store-method-clearFilter
       grid2.store.filter('Number', record.get('Number');
    },this);