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

ComboBoxColumn Edit and Read display

1 Answer 65 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Koren
Top achievements
Rank 1
Koren asked on 25 Feb 2011, 10:36 PM
I am using a gridviewcomboboxcolumn to select a transaction code.  Because the description of the code may be fairly long, I would like to display the Code and Description in the Dropdown in Edit mode (e.g. 0110 Long Description) but when it is in Display mode I would like only the Code to show without the description (e.g. 0110).  (The ID of the transaction is saving perfectly to my MVVM model right now so this is a display issue only.)

thanks!

1 Answer, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 28 Feb 2011, 08:43 AM
Hello Koren,

You may define an EditorStyle for the GridViewComboBoxColumn. For example:

//Style definition:
<Window.Resources>
        <Style x:Key="MyStyle" TargetType="telerik:RadComboBox">
            <Setter Property="ItemTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition Width="*"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <TextBlock Text="{Binding ID}"></TextBlock>
                            <TextBlock Text="{Binding Name}"  Grid.Column="1"></TextBlock>
                        </Grid>
                    </DataTemplate>                
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>
 
//Column definition:
<telerik:GridViewComboBoxColumn Header="Nationality"           
                                                EditorStyle="{StaticResource MyStyle}"
                                                DataMemberBinding="{Binding CountryID, Mode=TwoWay}"
                                                DisplayMemberPath="Name"
                                                SelectedValueMemberPath="ID">                  
                </telerik:GridViewComboBoxColumn>
            

Both "Name" and "ID" are properties from the ItemsSource of the column.
 

Regards,
Maya
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
GridView
Asked by
Koren
Top achievements
Rank 1
Answers by
Maya
Telerik team
Share this question
or