Is there a way to filter on multiple columns with angular-slickgrid ?
I have columns showing the same information in different regions, and I'd like the user to be able to use one filter to get any row matching regardless of which region (column) matches.
Thanks
The short answer is No you cannot (but there's a longer Yes option below), there's a reason why each filter are shown on top of each column and it's because they are associated with that said column (by looping through each column definition, these filters are being created dynamically). You can however use another column when filtering, with queryFieldFilter
or with queryFieldNameGetterFn
depending on the data but again that will only be associated to 1 column at a time.
Does that mean that you cannot do it at all? Not necessarily, you could provide a different filter
implementation via the SlickGrid DataView dataView.setFilter(myFilter);
but if you do that then you'll bypass all the column filters (in other words, none of the default column filters would work anymore when you override the DataView filter method) but maybe that is acceptable for you by making it as a global filter and disabling the filters header row. You can take this SlickGrid Example to see the code, it has an external filter with multiple conditions and that might work for you.
function myFilter(item, args) {
if (item["percentComplete"] < args.percentCompleteThreshold) {
return false;
}
if (args.searchString != "" && item["title"].indexOf(args.searchString) == -1) {
return false;
}
return true;
}
Basically what I meant to say is that you do have the option to rewrite your own filter implementation but by doing so, you will for sure break the default column filters implementation. I typically never do that because it's more work and also not as effective to have only 1 global search filter but it's up to you and your use case.
It would be easier to just add that column in the grid and ask the user to filter it by region
Please note that I'm the author of Angular-Slickgrid