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

How to dynamically change controls in same column in GridView?

0 Answers 46 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Yang
Top achievements
Rank 1
Yang asked on 07 Oct 2011, 02:29 PM
I want to implement:
If ID ==0 , in the Region column, the control should be comboBox. So that I can select from a list.
if ID != 0, in the Region column, the control should be TextBlock.

I used templateSelector and DataTemplate. The TextBlock controls work fine. But for some reason, the ComboBox doesn't work.

<telerik:RadGridView.Columns>
    <telerik:GridViewColumn CellTemplateSelector="{StaticResource commandCellSelector}" Width="110"/>
    <telerik:GridViewDataColumn DataMemberBinding="{Binding RegionName, Mode=TwoWay}" Header="Region" Width="180" CellTemplateSelector="{StaticResource regionCellSelector}"/>
    <telerik:GridViewDataColumn DataMemberBinding="{Binding DivisionName, Mode=TwoWay}" Header="Division" Width="180"/>
    <telerik:GridViewDataColumn DataMemberBinding="{Binding SubDivisionName, Mode=TwoWay}" Header="SubDivision" Width="180"/>
</telerik:RadGridView.Columns>

<DataTemplate x:Key="RegionEditTemplate">
    <TextBlock Text="{Binding RegionName, Mode=TwoWay}" />
</DataTemplate>
<DataTemplate x:Key="RegionAddNewTemplate">
    <ComboBox ItemsSource="{Binding RegionSearchList, Source={StaticResource ViewModel}}"DisplayMemberPath="Name" SelectedValuePath="ID" SelectedValue="{Binding RegionID}"/>
</DataTemplate>
<templateSelector:ManageWorkAreaRegionSelector x:Name="regionCellSelector" RegionEditTemplate="{StaticResource RegionEditTemplate}" RegionAddNewTemplate="{StaticResource RegionAddNewTemplate}"/>

No answers yet. Maybe you can help?

Tags
GridView
Asked by
Yang
Top achievements
Rank 1
Share this question
or