dropdown list in child hierachy grid

5 posts, 1 answers
  1. john
    john avatar
    9 posts
    Member since:
    Jun 2009

    Posted 28 Aug 2009 Link to this post

    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
  2. Ludovic Gerbault
    Ludovic Gerbault avatar
    226 posts
    Member since:
    Apr 2009

    Posted 28 Aug 2009 Link to this post

    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.
  3. DevCraft banner
  4. john
    john avatar
    9 posts
    Member since:
    Jun 2009

    Posted 28 Aug 2009 Link to this post

    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

     

  5. Answer
    Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 31 Aug 2009 Link to this post

    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.
  6. john
    john avatar
    9 posts
    Member since:
    Jun 2009

    Posted 31 Aug 2009 Link to this post

    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" };

     

     

    ;
    }

Back to Top
DevCraft banner