dotnet / DataGridExtensions

Modular extensions for the WPF DataGrid control
MIT License
822 stars 105 forks source link

Add 'Filtered' event and 'DataGridFilteredEventArgs' #109

Closed fraluderin closed 6 months ago

fraluderin commented 9 months ago

I needed to be notified when a filtering on DataGrid was completed. More specifically, I needed to know how many items were found with applied filter. So, this PR adds an event 'Filtered' which occurs after filters are applied. Its argument 'DataGridFilteredEventArgs' contains an IList of matching items found. 'DataGridFilteredEventArgs' could eventually be expanded with additional features.

fraluderin commented 9 months ago

@dotnet-policy-service agree

tom-englert commented 7 months ago

@fraluderin There is already an event FilterChanged, which seems to do the same

tom-englert commented 7 months ago

This will only notify you when the filter condition has changed, not when the filtered data has change. It will not notify you about changes to the data when the data source changes. To achieve this you should rather register to the changes on the items.

fraluderin commented 7 months ago

I added the Filtered event to get information about items that match applied filter(s). FilterChanged does not inform me about which items match applied filter. E.g., I need to know which items match after user changes applied filters; source data didn't change. Is there a way to know this without adding Filtered event and DataGridFilteredEventArgs?

tom-englert commented 7 months ago

You are just returning this: https://github.com/dotnet/DataGridExtensions/blob/a8b0e4aee70bbedcd1831b5b28eee3abd9a7ae83/src/DataGridExtensions/DataGridFilterHost.cs#L234

tom-englert commented 6 months ago

Not required, information already available