Applying CellEditTemplate to GridViewComboBoxColumn

2 posts, 0 answers
  1. Minh
    Minh avatar
    43 posts
    Member since:
    May 2014

    Posted 03 Dec 2015 Link to this post

    I currently have a column that binds to a collection of enums. I'm trying to change it so that it will display the display attribute name instead of the enum name. I was able to the the CellTemplate to display the correct attribute name but I wasn't able to get the CellEditTemplate to display the the dropdown correct. It doesn't show anything when clicked. 

    My original code that works but doesn't use display name

        <telerik:GridViewComboBoxColumn Header="Event Type" ItemsSource="{Binding ScriptEvents}" DataMemberBinding="{Binding SelectedEvent}"  IsReadOnly="False" />

    What I tried

        <telerik:GridViewComboBoxColumn ItemsSource="{Binding ScriptEvents}" DataMemberBinding="{Binding SelectedEvent}" IsReadOnly="False">
            <telerik:GridViewComboBoxColumn.CellTemplate >
                    <TextBlock Text="{Binding SelectedEvent, Converter={StaticResource EnumToDisplayAttribConverter}}"/>
            <telerik:GridViewComboBoxColumn.CellEditTemplate >
                    <telerik:RadComboBox ItemsSource="{Binding ScriptEvents, RelativeSource={RelativeSource FindAncestor, AncestorType=UserControl}}">
                                <TextBlock Text="{Binding SelectedEvent, Converter={StaticResource EnumToDisplayAttribConverter}}" DataContext="{Binding}"/>

    Code for enum converter can be found here 
  2. Stefan
    Stefan avatar
    1073 posts

    Posted 08 Dec 2015 Link to this post

    Hi Minh,

    From the provided code I can only be guessing what the cause for the issue might be. Do you experience any BindingErrors when running the application in debug mode? They can be observed in the "output" window in VisualStudio. Can you also share some details on the explicit setting of the DataContext of the TextBlock within the ItemTemplate of RadComboBox?

    Additionally, you can take a look at the ComboBox Column topic for more information on the matter.

    Stefan X1
    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 Feedback Portal and vote to affect the priority of the items
Back to Top