This is a migrated thread and some comments may be shown as answers.
RadComboBox CellTemplate in RadGridGriew
3 Answers 80 Views
This is a migrated thread and some comments may be shown as answers.
Andrei
Top achievements
Rank 2
Andrei asked on 14 May 2012, 09:18 AM
I have a RadGridView with a column that is RadComboBox:




<telerik:RadGridView x:Name="gridSelectedResources" Style="{StaticResource GridViewSelectedResources}"
                                         BeginningEdit="gridSelectedResources_BeginningEdit"
                                         RowEditEnded="gridSelectedResources_RowEditEnded"
                                         Deleted="gridSelectedResources_Deleted"
                                         EditTriggers="CellClick"
                                         IsReadOnly="{Binding CurrentRole.Editable,Converter={StaticResource ReverseBoolConverter}}">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn.CellEditTemplate>
                                    <DataTemplate>
                                        <telerik:RadComboBox
                                            Style="{StaticResource ComboBoxCellEditStyle}"
                                            Loaded="RadComboBox_Loaded"
                                            SelectionChanged="RadComboBox_SelectionChanged"
                                            DisplayMemberPath="Name"
                                            SelectedValuePath="Id"
                                            SelectedValue="{Binding CS.Id, Mode=TwoWay}"
                                            >
                                            <i:Interaction.Behaviors>
                                                <sharedBehaviors:ShowDescriptionBehavior ComboBoxWithDescriptionTemplate="{StaticResource NonEditableComboBoxWithDescription}"/>
<telerik:RadGridView.Columns>
                                            </i:Interaction.Behaviors>
                                        </telerik:RadComboBox>
                                    </DataTemplate>
                                </telerik:GridViewDataColumn.CellEditTemplate>
                            </telerik:GridViewDataColumn>
 </telerik:RadGridView.Columns>
                    </telerik:RadGridView>


Problem: how from tests select a item from RadComboBox?
I try to Cast, but it doesn't work, I try to FindAllByType<RadComboBox> => count is 0.

Do you have some solutions to solve this problem?








3 Answers, 1 is accepted

Sort by
0
Anthony
Telerik team
answered on 14 May 2012, 10:19 PM
Hello Andrei,

Is this a Silverlight RadComboBox? If so, here's code against a sample Telerik demo page that gets a list of all RadComboBoxes and makes a selection from the first one:

Settings.Current.Web.EnableSilverlight = true;
Manager.LaunchNewBrowser();
ActiveBrowser.NavigateTo("http://demos.telerik.com/silverlight/#ComboBox/FirstLook");
 
SilverlightApp app = ActiveBrowser.SilverlightApps()[0];
Telerik.WebAii.Controls.Xaml.RadComboBox cb = app.Find.ByAutomationId<Telerik.WebAii.Controls.Xaml.RadComboBox>("TechnologySelection");
Assert.IsNotNull(cb);
 
IList<Telerik.WebAii.Controls.Xaml.RadComboBox> list = app.Find.AllByType<Telerik.WebAii.Controls.Xaml.RadComboBox>();
Log.WriteLine(list.Count.ToString());
 
cb.SelectItem("Silverlight", true);
System.Threading.Thread.Sleep(1000);

If you continue to have difficulty, can you point me to a public site that demonstrates the behavior along with a full code sample I can run directly?

Kind regards,
Anthony
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Andrei
Top achievements
Rank 2
answered on 15 May 2012, 06:14 AM
Yes, it;s a Telerik RadComboBox.
When RadComboBox isn't as CellTemplate => I know how access it and select items, but in my case this RadComboBox is in RadGridView cell template => and I can't find some solutions to get this RadComboBox and select some items.


0
Anthony
Telerik team
answered on 16 May 2012, 04:46 PM
Hello Andrei,

Perhaps the ComboBox isn't "active" until clicking or double clicking on the cell (or row). In the example below, I identify a specific row in the grid, double click it, then identify and make a selection from its RadComboBox. You may need to go further and identify a specific cell in the row as well.

Settings.Current.Web.EnableSilverlight = true;
Manager.LaunchNewBrowser();
ActiveBrowser.NavigateTo("http://demos.telerik.com/silverlight/#GridView/ComboBoxColumn");
 
SilverlightApp app = ActiveBrowser.SilverlightApps()[0];
RadGridView grid = app.Find.ByAutomationId<RadGridView>("RadGridView1");
Assert.IsNotNull(grid);
 
GridViewRow row = grid.Rows[2];
row.User.Click(MouseClickType.LeftDoubleClick);
 
Telerik.WebAii.Controls.Xaml.RadComboBox cb = row.Find.ByType<Telerik.WebAii.Controls.Xaml.RadComboBox>();
cb.SelectItem("Product6", true);
System.Threading.Thread.Sleep(1000);


Greetings,
Anthony
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Asked by
Andrei
Top achievements
Rank 2
Answers by
Anthony
Telerik team
Andrei
Top achievements
Rank 2
Share this question
or