简体   繁体   中英

extjs - How to filter grid data except selected value in combo box

Ext js has in built function for Grid store called filter and which filter grid result with selected value from combobox.

I want reverse of it. It should filter grid data except selected data.

Example: By default, All check box are selected at first. When I uncheck any checkbox than grid should be show data except that selected checkbox.

Please find screenshot for filter options

Following is the code which I have tried but it does filter grid with selected checkbox.

var filterArray = [];

filterArray.push({
                   id: 'h2',
                   property: 'vehicle_trafic_light',
                   value: 'Y',     //For Yellow-Ball
                   anyMatch: true,
                   ensitive: false
                 }); 
filterArray.push({
                   id: 'h2',
                   property: 'vehicle_trafic_light',
                   value: 'G',      //For Green-Ball
                   anyMatch: true,
                   ensitive: false
                 });

store.filter(filterArray);

Let me know if anyone have any suggestion for it.

您可以使用filterFn

You can user filterBy

filterBy takes a function (lets call is fun) as argument and function fun is called for each record in store.

store.fliterBy(function(record){
        if(condition to include record)
            return true;                    // record will be included
        else
            return false;                   // record will be excluded
});

And records are filtered based on return value of fun for that record.

So,

  1. If fun return true for record A, then record A will be included in store.
  2. If fun returns false for record B , then record B will be excluded.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM