|
Is there anyway to tie some code in automatically when the filters are changed? |
As per the current behavior of PivotGrid control, we have provided the “FilterActionCompleted” event handler method only for RowPivotsOnly mode.
If you would like you implement your own logic after applying filters, then you can use the “Filters_CollectionChanged” event handler method in your application. CollectionChanged event will be invoked once the filters are applied into the filters collection of PivotGrid control.
Please refer to the below code example.
| |
|
I would like for that same range to be re-selected and the new data pulled when the grid is filtered. |
By default, maintaining the grid selections for every operation is not the proper behavior. Since some of the selected cells will be removed from grid control when applying filters. So that only we have cleared the grid selections when we are applying filters.
But you can maintain the grid selection after applying filters if you want. To achieve this, you should use the “SelectionChanged” and “DataRefreshed” event handlers in your application.
Please refer to the below code example.
| |
|
Also, is there a way to programmatically choose the filter fields and the specific items to be filtered for? |
Yes. You can apply filters based on your own filter expression and it can be achieved by adding the “FilterExpression” into the Filters collection.
Please refer to the code example below.
|
|
#Form1.cs
void Filters_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
// You can write your code here...
persistSelection = true;
var filterExpression = e.NewItems[0] as FilterExpression;
if(filterExpression != null && filterExpression.Tag is FilterItemsCollection)
{
List<FilterItemElement> listOfSelectedItems = (filterExpression.Tag asFilterItemsCollection).Where(x => x.IsSelected == true).ToList();
}
}
|