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

Using CellEditTemplateSelector with different sources for Combobox

4 Answers 73 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Maria
Top achievements
Rank 1
Maria asked on 17 May 2011, 12:58 AM
In my scenario I have a column that can have a ComboBox or a TextBox and it's defined in the following way:

<telerik:GridViewDataColumn Header="Target" DataMemberBinding="{Binding Target}" Width="70" ValidatesOnDataErrors="None" CellEditTemplateSelector="{StaticResource TargetEditStyleSelector}"/>

My templateSelectors are defined here:

<UserControl.Resources>
        <templateSelectors:TargetCellEditTemplateSelector x:Key="TargetEditStyleSelector">
            <templateSelectors:TargetCellEditTemplateSelector.TextBoxTemplate>
                <DataTemplate>
                    <TextBox Text="{Binding Path=Target, Mode=TwoWay}" HorizontalAlignment="Stretch" />
                </DataTemplate>
            </templateSelectors:TargetCellEditTemplateSelector.TextBoxTemplate>
            <templateSelectors:TargetCellEditTemplateSelector.ComboBoxTemplate>
                <DataTemplate>
                    <ComboBox DisplayMemberPath="Name" SelectedValue="Id" ItemsSource="{Binding Source={StaticResource comboBoxSource}}"/>
                </DataTemplate>
            </templateSelectors:TargetCellEditTemplateSelector.ComboBoxTemplate>
        </templateSelectors:TargetCellEditTemplateSelector>
    </UserControl.Resources>

The problem is that comboBoxSource can be changed in code depending on the value selected in another column and I'm not sure how to properly bind the source of that combobox. Any help is highly appreciated. Thanks!


4 Answers, 1 is accepted

Sort by
0
Maria
Top achievements
Rank 1
answered on 24 May 2011, 11:17 PM
Does anybody have an idea? Ple-e-e-ease? :)
0
Ivan Ivanov
Telerik team
answered on 30 May 2011, 03:37 PM
Hello Maria,

You may use a converter that checks the value in the other column and conditionally passes the correct source for the ComboBox.

Greetings,
Ivan Ivanov
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
0
Maria
Top achievements
Rank 1
answered on 31 May 2011, 03:38 PM
Thank you!
DO you happen to have an example of this scenario?

Thanks again!
0
Ivan Ivanov
Telerik team
answered on 31 May 2011, 03:45 PM
Hello Maria,

On a side note, there is another approach to similar scenarios, for which we have an example. Please, refer to this blog and inform us if this solution meets your requirements.

Best wishes,
Ivan Ivanov
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
Maria
Top achievements
Rank 1
Answers by
Maria
Top achievements
Rank 1
Ivan Ivanov
Telerik team
Share this question
or