Hi guys,
I'm trying to make the column filters work for items that are displayed on the grid and the ones that are not (one item is composed of multiple ones but only one is viewable on the grid).
The default filter works fine but just for items that are viewable. So what i did i implemented the BeforeRowFilterDropDownPopulateEventArgs event and expanded the filters value list (with the values that are not viewable on the grid). e.ValueList.ValueListItems.Add(filter.FormattedNotViewableItem). And this adds all those items in the filter drop down. After this i added the FilterRowEventArgs event and on every match for my FormattedNotViewableItem and the e.Row.ListObject that contains that filter value i would set e.RowFilteredOut = false;
And this works just fine, it filters the items that are not viewed on the grid. But the problem occurs when i try to filter another column, then the e.RowFilteredOut = false stays the same (it is called in the FilterRowEventArgs event for every row in the grid )so the new filter condition in not taken into account and basically the filter results stay the same.
Can i somehow reset these values before i call the new filter for the new column or i should try another approach?
Anyone with some ideas would be really beneficial.
Thanks
Nikola Kalkovaliev
Hello Nikola,
Thank you for contacting Infragistics!
What do you mean you are trying to get the filter for items are that are not viewable in the grid? Do you mean they are in the data and just currently not in the viewport the grid shows or current page?
Or do you mean they are not in the datasource the is being applied to the grid?
HI Michael,
They are in the datasource but they are not viewed on the grid since they are not shown there for specific reasons. I'm applying that data in my filter drop down and filter with it, but when i use another filter, different from the previous (first one used) it doesn't filter my data according to it (the new filter applied)
It's still not at all clear to me what you mean by rows that are "not viewable in the grid." How are you hiding those rows? Are you setting Hidden to true? What event are you using for that?Or are you just talking about rows that are filtered out because of a filter on another column? If it's the latter case, then the grid's filter dropdown list will only contain rows that are not already filtered out. That's consistent with how Excel works. You could add those hidden values into the filter DropDown, which you mentioned you are doing. But you can't UN-FILTER a row by adding a filter to another column. In other words, if a row is filtered out in column A, and you add a filter to column B, the row will still be filtered out - no matter what you do in column B, that row will still never meet the filter criteria, because it has to meet the criteria for all of the filters in all of the columns. Is that what you are trying to do? Un-filter a row?
Hi Mike
By rows not viewable i mean data that is part of the data grid but is not shown in the grid due to some conditions.
Here's what happens.
I have added that data that is not viewable in my custom FilterConditions and it's there and is shown in the dropdown for the appropriate filter. After i select to filter with that value if filters out the column by firing the FilterRowEvent and there i check for every row if a condition is matched so i can set that row to e.Row.ListObject. Let's say i have selected Location Column filter and filter by value = "New York". It finds the row that has that value and set's it e.Row.ListObject. And this works fine, it filters them as it should.
The problem begins when i select another filter for another column. Let's say Location Code. Here the FilterRowEvent is fired again and it checks every row for values from my newly added filter (Location Code) but it also checks for value match for my previous one (Location). And it messes up the filters since it enters the e.Row.ListObject for every filtered previous row, or in other words the filter results stay the same from the first one selected.
Can i somehow trigger the FilterRowEvent for only the new filter so it works nice or i should try some other custom filters maybe approach?
Thanks.
The FitlerRow event fires once for each row in the grid and the expectation is that you evaluate ALL of the filters against that row to determine whether that row should or should not be filtered out. The event is not fired for each filter condition - that would be very inefficient.
So if you are handling the FilterRow event, you need to evaluate both (or All) of the filters every time.Why do you only want to evaluate one filter at a time? Is it just for efficiency? I don't think there is any way to do that.
Hi Mike,
When i'm handling all of the filters at once my code doesn't work since i set manually e.RowFilteredOut = false; for certain conditions. As i described here the event is fired for every row and every filter selected so it messes up the whole filtering. Let's say i filter it by Locations and it set's e.RowFilteredOut = false; for the conditions but after the next filter selection it checks for the first and for the second filter conditions over and over and it due to e.RowFilteredOut = false; it messes up the filtering.