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

Add a default filter on a column

4 Answers 664 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Julien
Top achievements
Rank 1
Julien asked on 22 Aug 2011, 02:07 PM
Hi,

I've a  radGridView which displays some "order". Each order has a status(represented by an enum.

I want to not display by default order with a Closed status.

So, I added this on my radgridview:

<telerik:RadGridView.FilterDescriptors>
    <telerik:FilterDescriptor Member="LastStatus.Status" Value="Closed" Operator="IsNotEqualTo"/>
</telerik:RadGridView.FilterDescriptors>

This is actually working, but I've a problem, this filter isn't displayed in any filter list.

Even if I've a column with the exact same DataMember:
<telerik:GridViewDataColumn Header="Current Status" DataMemberBinding="{Binding LastStatus.Status}" />

How can I manage this??? Xaml side of course

I saw this: http://www.telerik.com/help/silverlight/radgridview-filtering-column-filter-descriptors.html
But I can't specify a GridViewDataColumn in the xaml of the FilterDescriptor

4 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 22 Aug 2011, 03:34 PM
Hi Julien,

I believe that my blog post describes what you need.

Let me know if there are problems or questions.

Best wishes,
Ross
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Julien
Top achievements
Rank 1
answered on 23 Aug 2011, 06:09 AM
Like I said I want/have to avoid UI code in the code behind, so how can I do this xaml side?
0
Accepted
Rossen Hristov
Telerik team
answered on 23 Aug 2011, 06:57 AM
Hi Julien,

Unfortunately, you can't do the column filtering entirely in XAML for various reasons. But that should not be a problem.

If you don't want any code-behind to clutter in your main window or user control you can always use the attached behavior pattern and perform the filtering inside the attached behavior. Then in XAML you will simply turn on this behavior. In this way, you will be encapsulate all the filtering logic inside the behavior and you will simplify your XAML even further.

I hope this helps.

Greetings,
Ross
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Julien
Top achievements
Rank 1
answered on 23 Aug 2011, 07:28 AM
Okay, this could be an acceptable solution.

One more question:

I've to add/remove those filter on the collection when it's already full-filled, how can I ask to "apply" those changes? Because I've the impression that if I add/remove filter after I've set the itemSource, it's not applied on my radGridView.

So how to automate the same refresh that is done when I change a filter through the radGridView?

edit:

Nevermind, I was removing the filter the wrong way!

Tags
GridView
Asked by
Julien
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Julien
Top achievements
Rank 1
Share this question
or