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

dropdown list in child hierachy grid

4 Answers 100 Views
GridView
This is a migrated thread and some comments may be shown as answers.
john
Top achievements
Rank 1
john asked on 28 Aug 2009, 04:44 PM
Is there a way to have a dropdown column in a child hierachy grid as I want to give the user a choice of imput values in a column

4 Answers, 1 is accepted

Sort by
0
Ludovic Gerbault
Top achievements
Rank 1
answered on 28 Aug 2009, 04:59 PM
if your childgrid columns are declared in you xaml, you might try to declare a gridviewcomboboxcolumn instead of a gridviewdatacolumn, that should provides you with what you need to set a combobox and its itemsource.

Otherwise, you'll need to declare a CellEditTemplate with a RadComboBox in it and us it on your columns.
0
john
Top achievements
Rank 1
answered on 28 Aug 2009, 05:27 PM
they are not in XAML as this is what my XAML looks like:

<

 

telerikGridView:RadGridView x:Name="MyGrid" AutoGenerateColumns="false" ShowGroupPanel="False" CanUserReorderColumns="False" >

 

 

 

<telerikGridView:RadGridView.Columns >

 

 

 

<telerikGridView:GridViewDataColumn UniqueName="Name" Header="Name" />

 

 

 

</telerikGridView:RadGridView.Columns>

 

 

 

</telerikGridView:RadGridView>

and my code 

 

GridViewTableDefinition

 

detailDefinition = new GridViewTableDefinition();

 

detailDefinition.Relation =

new PropertyRelation("items");

 

 

this.MyGrid.TableDefinition.ChildTableDefinitions.Add(detailDefinition);

 

 

this.MyGrid.ItemsSource = rates;

How would I do this in XAML and is there an example

 

0
Accepted
Vlad
Telerik team
answered on 31 Aug 2009, 06:23 AM
Hi john,

You can use HierarchyChildTemplate similar to our "First Look" demo.

Sincerely yours,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
john
Top achievements
Rank 1
answered on 31 Aug 2009, 02:15 PM
I came up with a different solution as i had to dynamically bind to the combo box:

 

 

<telerik:RadGridView.HierarchyChildTemplate>

 

 

 

<DataTemplate>

 

 

 

<StackPanel DataContext="{x:Null}">

 

 

 

<telerik:RadGridView Width="500" Loaded="RadGridView_Loaded" ItemsSource="{Binding ratedItem}" ShowGroupPanel="False" Margin="20" IsFilteringAllowed="False" AutoGenerateColumns="False" >

 

 

 

<telerik:RadGridView.Columns>

 

 

 

<telerik:GridViewDataColumn Width="400" HeaderText="Sub category" DataMemberBinding="{Binding Name}" />

 

 

 

<telerik:GridViewDataColumn Header="" Width="100">

 

 

 

<telerik:GridViewDataColumn.CellTemplate >

 

 

 

<DataTemplate>

 

 

 

<ComboBox x:Name="Ratings" Loaded="ComboBox_Loaded"></ComboBox>

 

 

 

 

</DataTemplate>

 

 

 

</telerik:GridViewDataColumn.CellTemplate>

 

 

 

</telerik:GridViewDataColumn>

 

 

 

</telerik:RadGridView.Columns>

 

 

 

</telerik:RadGridView>

 

 

 

</StackPanel>

 

 

 

</DataTemplate>

 

 

 

</telerik:RadGridView.HierarchyChildTemplate>

The key is the Loaded="ComboBox_Loaded" and the code behind is:

 

 

private void ComboBox_Loaded(object sender, RoutedEventArgs e)

 

{

 

    var cb = sender as ComboBox;

 

    cb.ItemsSource =  new List<string>() { "one", "two", "three" };

 

 

;
}

Tags
GridView
Asked by
john
Top achievements
Rank 1
Answers by
Ludovic Gerbault
Top achievements
Rank 1
john
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or