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

How to enable the filter when the column is not bind to a property but object?

2 Answers 71 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, 02:19 PM
This is just a sample of our code, the actual is more complex.

So I have my RadGridView binded to a collection of object Person.

Person class expose FirstName, LastName, and some other property.

<telerik:RadGridView SelectedItem="{Binding CurrentSelectedTreeItem}" x:Name="MyRadDataGrid" AutoGenerateColumns="False"  ItemsSource="{Binding PersonCollection}">
 
                        <telerik:RadGridView.Columns>
 
                            <telerik:GridViewDataColumn DataMemberBinding="{Binding FirstName}" SortMemberPath="ID" Header="My Frist Name"/>
 
                            <telerik:GridViewDataColumn DataMemberBinding="{Binding LastName}" Header="My Last Name"/>
 
                            <telerik:GridViewDataColumn Header="My Last Name" IsFilterable="True">
 
                                <telerik:GridViewDataColumn.CellTemplate>
 
                                    <DataTemplate>
 
                                        <Button Content="{Binding SomeObject.AnotherProperty}"/>
 
                                    </DataTemplate>
 
                                </telerik:GridViewDataColumn.CellTemplate>
 
                            </telerik:GridViewDataColumn>
 
                        </telerik:RadGridView.Columns>
 
                    </telerik:RadGridView>

As you can see, the 3rd column is not specify to bind to a property. So the 3rd column by default is binding to a Person object and is using its Person object's property to build a data template.

So here is the problem, even if I enabled IsFilterable = True for the 3rd column, the filter function (the filter icon that suppose to come up on the column header is not visable) is still won't enable.  I think is because the binded object is not a value type.

Is there anything we can do to enable the filter for this column so I can use RadGridView's Filter functionality? I understand there is maybe a need to write our own filter algorithm against this Person object, but how to do it in RadGridView?

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimitrina
Telerik team
answered on 17 Apr 2012, 02:28 PM
Hi,

When the column filters on a certain property, this property has to be filterable. When the property is of type object, RadGridView does not know how to filter.

Probably this blog post can help you implement your filtering.

Greetings,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
King Chan
Top achievements
Rank 1
answered on 17 Apr 2012, 02:39 PM
thanks for your help! :D
Tags
GridView
Asked by
King Chan
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
King Chan
Top achievements
Rank 1
Share this question
or