In the AfterRowFilterChanged event, how can I get the visible rows collection?
I can see that e.Rows.VisibleRowCount updates with the new visible row count, however, I can't find a handle on the actual rows. ActiveRowScrollRegion.VisibleRows still contains the visible row collection _before_ the filter was applied, so is no use to me.
Thanks.
Hi,
Thank you for contacting Infragistics Developer Support.
It seems that the VisibleRowCollection is not yet updated in that event. What you could do is to actually check the .HiddenResolved property of each row in the visible row collection, which is updated in the event:
var rows = ultraGrid1.ActiveRowScrollRegion.VisibleRows.
Cast<VisibleRow>().Where(r => !r.Row.HiddenResolved);
This way you will get the currently visible rows. Note that this won’t return all the non-filtered rows, just the ones that can be currently seen by the user.
I have attached a sample in order to demonstrate this suggestion.
Please let me know if you have any additional questions.
Hi Dimitar,
Thanks for getting back to me. I don't think that works though - that just gives me the rows that are still visible from the previous filter. If the filter changes completely and now displays rows that were hidden before, they won't be returned.
The only way I have found currently is to call a DoEvents in the AfterRowFilterChanged event. However, that isn't ideal as it allows a refresh of the grid before I can handle it in code.
The filtering is performed asynchronously. So the visible rows have not been updated at the time AfterRowFilterChanged fires.
If you want to get the visible rows at that point, the only way to do that would be to force the filtering to occur synchronously. You can do this by handling BeforeRowFitlerChanged and setting the ProcessMode to synchronous.
void ultraGrid1_BeforeRowFilterChanged(object sender, BeforeRowFilterChangedEventArgs e) { e.ProcessMode = ProcessMode.Synchronous; }
The down side of this approach is, of course, that the filtering is performed synchronously and every time the user changes a filter, it will lock up the UI. This is probably not a big deal if you only have 100 rows. But if you have 10,000 rows, it may create a bad user experience.
Thanks Mike.