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

[Solved] Problem when using filter in RadGridView

3 Answers 127 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Triet Nguyen Cong
Top achievements
Rank 2
Triet Nguyen Cong asked on 01 Oct 2010, 11:11 AM
1. Filter is allow: I'm only using DataMemberBinding

<Controls3:RadGridView Name="gvAdvisorTasks"
             CanUserFreezeColumns="False"         
             RowIndicatorVisibility="Collapsed"
             AutoGenerateColumns="False"
             ShowGroupPanel="False"
                                    AutoExpandGroups="True"
                                    IsFilteringAllowed="True"
                                    Visibility="{Binding HasRecord}"  
                                    ItemsSource="{Binding Path=AdvisorTaskCollections}" TabIndex="19">
                            <Controls3:RadGridView.Columns>
                                <Controls3:GridViewDataColumn Header="Task Details"
                                                            DataMemberBinding="{Binding Path=Description}"
                                                            IsReadOnly="True"/>
</Controls3:RadGridView.Columns>
                        </Controls3:RadGridView>

2. Filter not allow: I'm only binding in CellTemplate
<Controls3:RadGridView Name="gvAdvisorTasks"
                                    CanUserFreezeColumns="False"         
                                    RowIndicatorVisibility="Collapsed"
                                    AutoGenerateColumns="False"
                                    ShowGroupPanel="False"
                                    AutoExpandGroups="True"
                                    IsFilteringAllowed="True"
                                    Visibility="{Binding HasRecord}"  
                                    ItemsSource="{Binding Path=AdvisorTaskCollections}" >
                            <Controls3:RadGridView.Columns>
                                <Controls3:GridViewDataColumn Header="Task Details"
                                   IsReadOnly="True">
                                <Controls3:GridViewDataColumn.CellTemplate>
                                 <DataTemplate>
                                        <TextBlock Text="{Binding Path=Description}"/>
                                 </DataTemplate>
                                </Controls3:GridViewDataColumn.CellTemplate>
                              </Controls3:GridViewDataColumn>
</Controls3:RadGridView.Columns>
                        </Controls3:RadGridView>


3. Not Normal- filter is allow: i'm binding both place: DataMemberBinding and CellTemplate.
<Controls3:RadGridView Name="gvAdvisorTasks"
                                    CanUserFreezeColumns="False"         
                                    RowIndicatorVisibility="Collapsed"
                                    AutoGenerateColumns="False"
                                    ShowGroupPanel="False"
                                    AutoExpandGroups="True"
                                    IsFilteringAllowed="True"
                                    Visibility="{Binding HasRecord}"  
                                    ItemsSource="{Binding Path=AdvisorTaskCollections}">
                            <Controls3:RadGridView.Columns>
                                <Controls3:GridViewDataColumn Header="Task Details"
                                                            DataMemberBinding="{Binding Path=Description}"
                                                            IsReadOnly="True">
                                <Controls3:GridViewDataColumn.CellTemplate>
                                 <DataTemplate>
                                        <TextBlock Text="{Binding Path=Description}" />
                                 </DataTemplate>
                                </Controls3:GridViewDataColumn.CellTemplate>
                              </Controls3:GridViewDataColumn>
</Controls3:RadGridView.Columns>
                        </Controls3:RadGridView>
 So, Why that? Is that bug?

3 Answers, 1 is accepted

Sort by
0
Triet Nguyen Cong
Top achievements
Rank 2
answered on 04 Oct 2010, 03:14 AM
Hi Telerik team,
why you not answer me?
0
Accepted
Milan
Telerik team
answered on 04 Oct 2010, 07:09 AM
Hi Triet Nguyen Cong,

Actually this is the expected behavior - you need to specify DataMemberBinding to be able to sort, filter or group a column. When you only specify a cell template the grid does not have a clue which property should be used for data operations. 

When you specify CellTemplate you are redefining the way data gets displayed and that is why you should create binding expressions in CellTemplate in addition to the binding specified in DataMemberBinding. 

I hope this makes sense. 


All the best,
Milan
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
Triet Nguyen Cong
Top achievements
Rank 2
answered on 04 Oct 2010, 07:22 AM
Thanks for your answer!
Thus, i will choice number 3.
Tags
GridView
Asked by
Triet Nguyen Cong
Top achievements
Rank 2
Answers by
Triet Nguyen Cong
Top achievements
Rank 2
Milan
Telerik team
Share this question
or