I have set column filter programmaticaly. It does filters the view.
When I click the funnel icon - the default filtering control does not reflect filtering condition.
When I click the funnel icon - the default filtering control does not reflect filtering condition.
using
System.Collections.Generic;
using
System.Windows;
using
Telerik.Windows.Data;
namespace
TestGridViewFilter
{
public
partial
class
MainPage
{
public
MainPage()
{
Documents.Add(
new
Document { Title =
"T1"
, State = State.Returned });
Documents.Add(
new
Document { Title =
"T2"
, State = State.Draft });
Documents.Add(
new
Document { Title =
"T3"
, State = State.Final });
Documents.Add(
new
Document { Title =
"T4"
, State = State.InReview });
Documents.Add(
new
Document { Title =
"T5"
, State = State.New });
Documents.Add(
new
Document { Title =
"T6"
, State = State.Submitted });
Documents.Add(
new
Document { Title =
"T7"
, State = State.Withdrawn });
InitializeComponent();
}
private
void
SetFilters()
{
TestGridView.FilterDescriptors.SuspendNotifications();
TestGridView.FilterDescriptors.Clear();
var statusFilterDescriptor =
new
CompositeFilterDescriptor();
statusFilterDescriptor.FilterDescriptors.Add(
new
FilterDescriptor(
"State"
, FilterOperator.IsEqualTo, State.Final));
statusFilterDescriptor.FilterDescriptors.Add(
new
FilterDescriptor(
"State"
, FilterOperator.IsEqualTo, State.Withdrawn));
statusFilterDescriptor.LogicalOperator = FilterCompositionLogicalOperator.Or;
TestGridView.FilterDescriptors.Add(statusFilterDescriptor);
TestGridView.FilterDescriptors.ResumeNotifications();
}
private
List<Document> _documents;
public
List<Document> Documents
{
get
{
return
_documents ?? (_documents =
new
List<Document>()); }
}
private
void
TestGridViewDistinctValuesLoading(
object
sender, Telerik.Windows.Controls.GridView.GridViewDistinctValuesLoadingEventArgs e)
{
e.ItemsSource = TestGridView.GetDistinctValues(e.Column,
false
);
}
private
void
UserControlLoaded(
object
sender, RoutedEventArgs e)
{
SetFilters();
}
}
public
class
Document
{
public
State State {
get
;
set
; }
public
string
Title {
get
;
set
; }
}
public
enum
State
{
New,
Draft,
Withdrawn,
Submitted,
InReview,
Final,
Returned
}
}
<
UserControl
xmlns
=
"http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
mc:Ignorable
=
"d"
x:Class
=
"TestGridViewFilter.MainPage"
MinWidth
=
"640"
MinHeight
=
"480"
x:Name
=
"UserControl"
Loaded
=
"UserControlLoaded"
>
<
Grid
x:Name
=
"LayoutRoot"
Background
=
"White"
>
<
telerik:RadGridView
x:Name
=
"TestGridView"
VerticalAlignment
=
"Center"
HorizontalAlignment
=
"Center"
ItemsSource
=
"{Binding Documents, ElementName=UserControl}"
AutoGenerateColumns
=
"False"
IsReadOnly
=
"True"
ShowGroupPanel
=
"False"
RowIndicatorVisibility
=
"Collapsed"
CanUserFreezeColumns
=
"False"
DistinctValuesLoading
=
"TestGridViewDistinctValuesLoading"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewDataColumn
Header
=
"Title"
DataMemberBinding
=
"{Binding Title}"
/>
<
telerik:GridViewDataColumn
Header
=
"State"
DataMemberBinding
=
"{Binding State}"
/>
</
telerik:RadGridView.Columns
>
</
telerik:RadGridView
>
</
Grid
>
</
UserControl
>