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

Filter for combobox column does not get displayed.

2 Answers 177 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ole
Top achievements
Rank 1
Ole asked on 07 Dec 2011, 02:45 PM
Hi,

I have the following xaml code , but I do not get any column  filter shown, not even the default one(when removing the filter control) , is it because I am binding to an object and not a foreign key (ID) as the example you have in a blog post. http://blogs.telerik.com/pavelpavlov/posts/10-01-20/filtering-gridviewcomboboxcolumn-in-radgridview-for-wpf.aspx. Is it possible to filter when binding to an object ?.

<telerik:GridViewComboBoxColumn UniqueName="cmbActionBy" ShowFieldFilters="True" IsFilterable="True" IsComboBoxEditable="True" Header="Action by" DataMemberBinding="{Binding Path=tblContact}"  telerik:TextSearch.TextPath="ShortName" DisplayMemberPath="ShortName" Width="80" SortMemberPath="tblContact.ShortName" EditorStyle="{Binding Source={StaticResource MyStyle}}">
 
                           <telerik:GridViewComboBoxColumn.FilteringControl>
                               <filter:ComboColumnFilteringControl IsActive="True" IsEnabled="true"></filter:ComboColumnFilteringControl>
                           </telerik:GridViewComboBoxColumn.FilteringControl>
 
                       </telerik:GridViewComboBoxColumn>

2 Answers, 1 is accepted

Sort by
0
Ole
Top achievements
Rank 1
answered on 08 Dec 2011, 12:32 PM
Hi,

I have now got it working with binding to ID and not object using selectedvalueMemberPath.

how do I here filter my contact persons to only display persons that has been selected in the combobox column,

 

using only information from the column object.


Best

Ole
<telerik:GridViewComboBoxColumn UniqueName="cmbActionBy" ShowFieldFilters="True" IsFilterable="True" IsComboBoxEditable="True" Header="Action by"  DataMemberBinding="{Binding Path=ActionByID}"  telerik:TextSearch.TextPath="ShortName" DisplayMemberPath="ShortName" Width="80" SortMemberPath="tblContact.ShortName" EditorStyle="{Binding Source={StaticResource MyStyle}}" SelectedValueMemberPath="ID">
                            
                                <telerik:GridViewComboBoxColumn.FilteringControl>
                                <filter:ComboColumnFilteringControl DataContext="{Binding ElementName=gridViewPunchList, Path=DataContext}"></filter:ComboColumnFilteringControl>
                            </telerik:GridViewComboBoxColumn.FilteringControl>
 
                        </telerik:GridViewComboBoxColumn>

public void Prepare(Telerik.Windows.Controls.GridViewBoundColumnBase column)
       {
           this.compositeFilterDescriptor = new CompositeFilterDescriptor() { LogicalOperator = FilterCompositionLogicalOperator.Or };
           this.column = column as GridViewComboBoxColumn;
           // how do I here filter my contact persons to only display persons that has been selected in the combobox column,
           // using only information from the column object.
           this.listBoxDistinctValues.ItemsSource = this.column.ItemsSource;  
           this.listBoxDistinctValues.DisplayMemberPath = this.column.DisplayMemberPath;
           this.column.DataControl.FilterDescriptors.Add(compositeFilterDescriptor);
       }

0
Pavel Pavlov
Telerik team
answered on 12 Dec 2011, 05:11 PM
Hello Ole,

I am glad you have found a solution to the first problem.
Now regarding filtering  - I am afraid using information only from the column object  you can not build the composite filter descriptor.

To know which items were selected in the comboboxes by the  you definitely need access to the items of the GridView and specifically to their ActionByID property.


Best wishes,
Pavel Pavlov
the Telerik team

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

Tags
GridView
Asked by
Ole
Top achievements
Rank 1
Answers by
Ole
Top achievements
Rank 1
Pavel Pavlov
Telerik team
Share this question
or