pivotGridControl Filter Event
Good day, I would like to be able to run some code any time the "Ok" button is clicked in the filter selection dialog. I cannot seem to find an event that is triggered at this point. I tried the FilterActionCompleted event but that is not called. Is there anyway to tie some code in automatically when the filters are changed? in particular I am pulling certain pieces of data from the grid by simply selecting the desired range. I would like for that same range to be re-selected and the new data pulled when the grid is filtered.
Also, is there a way to programmatically choose the filter fields and the specific items to be filtered for?
Thanks!
SIGN IN To post a reply.
3 Replies
SR
Sabaridass Ramamoorthy
Syncfusion Team
June 22, 2018 12:15 PM UTC
Hi Travis,
Please find our response below.
|
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.
|
We have created a simple sample to achieve your requirement and please find the sample from below location.
If any of our solution does not meet your actual requirement, please provided the detailed information about your requirement. So that we can provided the solution at the earliest.
Regards,
Sabaridass R
TC
Travis Chambers
June 23, 2018 04:49 PM UTC
Thank you for the update! Unfortunately the filter collectiom changed event doesnt really help me though because at that point we only know what filter fields are present not what items are selected for filtering in the filter selection dialogue box. Is there any way to capture the moment when the "Ok" button is clicked in that filter dialogue? Unfortunately i can not use row pivots only for my purposes.
SR
Sabaridass Ramamoorthy
Syncfusion Team
June 25, 2018 12:21 PM UTC
As we said earlier, we do not have any event handler method to be invoked when the “OK” button was clicked except “Filters_CollectionChanged” event handler. If you want to get the list of selected items from filter dialog box when the “OK” button is pressed, then you can also get them from “Filters_CollectionChanged” event handler. Please refer to the below code example which is helps you to get the selected items from filter dialog box.
|
#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();
}
}
|
Please find the working sample from the below location.
If you are still unable to achieve your requirements using “Filters_CollectionChanged” event handler, then kindly share all your exact requirements. So that we can provide an improvement/feature based on your requirements.
Regards,
Sabaridass R
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
TC Travis Chambers
- Jun 21, 2018 06:19 PM UTC
- Jun 25, 2018 12:21 PM UTC