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

Filter on CustomProperty not show in centain condition

0 Answers 32 Views
GridView
This is a migrated thread and some comments may be shown as answers.
King Chan
Top achievements
Rank 1
King Chan asked on 17 Apr 2012, 06:32 PM
So I was following this page as well as this blog to do the filtering.
I created the "Person" class which is identical to the example the page shown.

It works when I create a collection of object, and the object has a CustomProperty (in this case property Person).
But if I create a Collection of Person and binds this Person collection to the RadGridView, create a DataColumn that's binding to itself:

<telerik:GridViewDataColumn Header="Person" UniqueName="Person" DataMemberBinding="{Binding}" IsFilterable="True" />      


This column will not be filterable.

Below is the example code:

Xaml:
<Grid x:Name="LayoutRoot" Background="White">
    <telerik:RadGridView x:Name="MyRadGridView" IsFilteringAllowed="True">
        <telerik:RadGridView.Columns>
            <telerik:GridViewDataColumn Header="Person" UniqueName="Person" DataMemberBinding="{Binding}" IsFilterable="True" />               
        </telerik:RadGridView.Columns>
    </telerik:RadGridView>
</Grid>



Code:
public partial class MainPage : UserControl
   {
       public MainPage()
       {
           InitializeComponent();
 
 
           ObservableCollection<MyCustomProperty> MyCustomPropertyCollection = new ObservableCollection<MyCustomProperty>()
           {
               new MyCustomProperty(),
               new MyCustomProperty()
           };
 
           this.MyRadGridView.ItemsSource = MyCustomPropertyCollection; //Case 1) work, you can see MyPerson is filterable
 
           this.MyRadGridView.ItemsSource = MyCustomPropertyCollection[0].People; //Case 2) you can see the Person column is not filterable
       }
   }
 
   public partial class MyCustomProperty
   {
       public ObservableCollection<Person> People { get; set; }
 
       public Person MyPerson { get; set; }
 
       public MyCustomProperty()
       {
           People = new ObservableCollection<Person>() {
               new Person("Man A") { Age = 17 },
               new Person("Man B") {Age = 18},
               new Person("Man C") {Age = 18},
               new Person("Female A") {Age = 10},
               new Person("Female B") {Age = 19},
               new Person("Female B") {Age = 20}
           };
           MyPerson = new Person("Person A") { Age = 12 };
       }
 
 
   }

No answers yet. Maybe you can help?

Tags
GridView
Asked by
King Chan
Top achievements
Rank 1
Share this question
or