This is a migrated thread and some comments may be shown as answers.

Filtering like Excel

2 Answers 37 Views
GridView
This is a migrated thread and some comments may be shown as answers.
John Thompson
Top achievements
Rank 2
John Thompson asked on 04 Oct 2010, 10:52 PM
Is there an "out of the box" way to filter columns like Excel does?  In other words, I want the distinct values calculated after each column is filtered and I only want to see the value that still remain in the view.

2 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 05 Oct 2010, 09:26 AM
Hi John Thompson,

This Excel mode IS the out-of-the-box behavior. You can try it. I have attached a sample project. Filter by country. Choose only England. Then go to filter by Player. You will see that only English players are shown. So you do not have to do anything in order to have this -- it is the default mode.

In case you want to turn this behavior off and show ALL distinct values (i.e. anti-Excel) there is a way to do that as well. Here is how to turn filtering off:

private void playersGrid_DistinctValuesLoading(object sender, Telerik.Windows.Controls.GridView.GridViewDistinctValuesLoadingEventArgs e)
{
    var filterDistinctValues = false;
    e.ItemsSource = this.playersGrid.GetDistinctValues(e.Column, filterDistinctValues);
}

I have added this to the sample project as well. You can play around with it by uncommenting the code.

I hope this helps. Let me know if you have any other questions.

Kind regards,
Ross
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
John Thompson
Top achievements
Rank 2
answered on 05 Oct 2010, 12:21 PM
This surely does help... I have implemented the DistinctValuesLoading event handler and I had false as the second parameter to GetDistinctValues.  Changing this to true fixed my handler!  Many thanks!
Tags
GridView
Asked by
John Thompson
Top achievements
Rank 2
Answers by
Rossen Hristov
Telerik team
John Thompson
Top achievements
Rank 2
Share this question
or