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

Combo Box in a RadGridView Column

1 Answer 76 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jack Helm
Top achievements
Rank 1
Jack Helm asked on 11 May 2010, 03:18 PM
In the code below I am trying to setup a combo box in a RadGridView. The Grid is being setup in a DataTemplate in the UserControl.Resources and is called by a RadTabControl and bound to a list of items. The item properties are bound to several controls in this DataTemplate, one of which is a Gridview showing a property that is a child list of objects. Among these proeperties of the chis child table is a setting that is a flag with two possibilities. When I run it is seems to work ... to a point. I can select and drop the box and select one fo the two selections it appears in the column. But when i click anywhere else and the control loses focus, the text in the column becomes the text describiing the combobox control ("Telerick.Windows.Controls.RadComboBoxItem"). I have to assume this is due to the way I am setting up the column. ut it is the only example I have found so far that allowed me to set the values in the list box in the Xaml and bind the selected value to the value in the object. If anyone can tell me what I am doing wrong or suggest a better way to do it, I would be very appreciative.

<telerikGridView:GridViewDataColumn DataMemberBinding="{Binding DisplayColFlag, Mode=TwoWay}" Header="PPD/COL">  
    <telerikGridView:GridViewDataColumn.CellTemplate> 
        <DataTemplate> 
            <TextBlock Text="{Binding DisplayColFlag}" /> 
        </DataTemplate> 
    </telerikGridView:GridViewDataColumn.CellTemplate> 
    <telerikGridView:GridViewDataColumn.CellEditTemplate> 
        <DataTemplate> 
            <telerikInput:RadComboBox x:Name="cboColFlag" SelectedValue="{Binding DisplayColFlag, Mode=TwoWay}">  
                <telerikInput:RadComboBoxItem Content="PPD Only" /> 
                <telerikInput:RadComboBoxItem Content="PPD+COL" /> 
            </telerikInput:RadComboBox> 
        </DataTemplate> 
    </telerikGridView:GridViewDataColumn.CellEditTemplate> 
</telerikGridView:GridViewDataColumn> 

1 Answer, 1 is accepted

Sort by
0
Yavor Georgiev
Telerik team
answered on 13 May 2010, 03:33 PM
Hi Jack Helm,

 You can do the following, using a GridViewComboBoxColumn instead:

<telerik:GridViewComboBoxColumn DataMemberBinding="{Binding DisplayColFlag}" Header="PPD/COL">
                        <telerik:GridViewComboBoxColumn.Resources>
                            <x:Array Type="sys:String" x:Key="MyItemsSource"
                                     xmlns:sys="clr-namespace:System;assembly=mscorlib">
                                <sys:String>PPD Only</sys:String>
                                <sys:String>PPD+COL</sys:String>
                            </x:Array>
                        </telerik:GridViewComboBoxColumn.Resources>
                        <telerik:GridViewComboBoxColumn.ItemsSource>
                            <Binding Source="{StaticResource MyItemsSource}" />
                        </telerik:GridViewComboBoxColumn.ItemsSource>
                    </telerik:GridViewComboBoxColumn>

All the best,
Yavor Georgiev
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.
Tags
GridView
Asked by
Jack Helm
Top achievements
Rank 1
Answers by
Yavor Georgiev
Telerik team
Share this question
or