1
votes

I am loading my store and grid panel and assigning a filter like so

myGrid.store.filter('enabled', 'true');

This is to filter out records that are not enabled. This works, my gridpanel initially shows all records that are enabled equal to true. Then when I apply a filter using the gridpanel header and search for a record that I know has enabled set to false NOW appears.

The initial gridpanel list after initially assigning store.filter(....) removes all records that don't have enabled equal to true but filtering with the header includes it in the new filter.

I followed the docs here : http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.ux.grid.FiltersFeature

So I have something like this :

 Ext.apply(me, {
        width: 500,
        height: 250,
        store: 'BlockItems',
        features: [{
            ftype: 'filters',
            local: true,

After removing the filter from the header I am left with my list again but now it includes records that enabled != true and also enabled == true i.e All records.

I am very confused. I have filtered my store, so why is the grid "header filter" no complying with the filter I initially added ?

2

2 Answers

1
votes

You can add new filters by creating new instances of Ext.util.Filter and add them to the filters of the store.

I have the following code in my select event of a gridheader combobox:

this.up('grid').getStore().filter(new Ext.util.Filter({
    anyMatch: false,
    disableOnEmpty: true,
    property: field.up('gridcolumn').dataIndex,
    value   : field.getValue()
}));

And this is the code of the keyup of the combobox:

if (Ext.isEmpty(field.getValue()) && isValidKey === true) {
    this.up('grid').getStore().filter(new Ext.util.Filter({
        anyMatch: false,
        disableOnEmpty: true,
        property: field.up('gridcolumn').dataIndex,
        value   : field.getValue()
    }));
}

And this is the keyup of a gridheader textfield:

grid.getStore().filter(new Ext.util.Filter({
    anyMatch: true,
    disableOnEmpty: true,
    property: field.up('gridcolumn').dataIndex,
    value   : field.getValue()
}));

They work perfectly together as you can see in my Sencha Fiddle

1
votes

This is by design. If you use column filters, it removes all other filters from the store, since it can't know whether you want to keep them or not.

You have three possibilities. The most thorough would be to have only the enabled records in the store, if you don't intend to show the disabled ones at all.

If you don't want to do that, you can either listen to the filterchange event and add the enabled filter back after every filterchange (check whether it is already added, or else you get an infinite loop), or you can redefine how each of the column filters should work, so they obey to your special needs:

http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.ux.grid.FiltersFeature-cfg-filters