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

Applying CellEditTemplate to GridViewComboBoxColumn

1 Answer 186 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Minh
Top achievements
Rank 1
Minh asked on 03 Dec 2015, 04:58 PM
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 >
            <DataTemplate>
                <TextBlock Text="{Binding SelectedEvent, Converter={StaticResource EnumToDisplayAttribConverter}}"/>
            </DataTemplate>
        </telerik:GridViewComboBoxColumn.CellTemplate>
        <telerik:GridViewComboBoxColumn.CellEditTemplate >
            <DataTemplate>
                <telerik:RadComboBox ItemsSource="{Binding ScriptEvents, RelativeSource={RelativeSource FindAncestor, AncestorType=UserControl}}">
                    <telerik:RadComboBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding SelectedEvent, Converter={StaticResource EnumToDisplayAttribConverter}}" DataContext="{Binding}"/>
                        </DataTemplate>
                     </telerik:RadComboBox.ItemTemplate>
                 </telerik:RadComboBox>
             </DataTemplate>
        </telerik:GridViewComboBoxColumn.CellEditTemplate>
    </telerik:GridViewComboBoxColumn>

Code for enum converter can be found here http://formatexception.com/2014/07/bind-a-combobox-to-an-enum-while-using-display-attribute/ 

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 08 Dec 2015, 12:57 PM
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.

Regards,
Stefan X1
Telerik
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
Tags
GridView
Asked by
Minh
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or