ComboBox (dynamic) Binding

4 posts, 1 answers
  1. Joel Palmer
    Joel Palmer avatar
    164 posts
    Member since:
    May 2009

    Posted 07 May 2015 Link to this post

    I need to understand the best way to accomplish this.

    I have an ItemType list.  For each ItemType, I specify the type of TreeNode that can be defined.  So, then I have an Item list.  Each Item is assigned an ItemType and has a Children property which are more Item objects thus making the Hierarchy.

    Question is, how do I filter the items in the Item Type Column's ComboBox in relation to the selected Hierarchy Node?

    For pseudo code, do I:

    • Load the master Item Type list
    • Load the Hierarchy
    • Recursively Traverse the Hierarchy attaching the related Item Types to each node
    • Then, Bind?

    Thanks for your help,

    Joel

     

    TreeListView Definition:

    <telerik:RadTreeListView
        x:Name="treeListView"
        AutoGenerateColumns="False"
        HorizontalAlignment="Stretch"
        VerticalAlignment="Stretch"
        CanUserFreezeColumns="False"
        CanUserReorderColumns="False"
        Grid.Row="1"
        Margin="5"
        IsReadOnly="{Binding Context.IsReadOnly}"
        ItemsSource="{Binding Context.Hierarchy, Mode=TwoWay}"
        SelectedItem="{Binding Context.SelectedItem, Mode=TwoWay}"
        AutoExpandItems="True">
     
        <telerik:RadTreeListView.ChildTableDefinitions>
            <telerik:TreeListViewTableDefinition 
                ItemsSource="{Binding Children}"/>
        </telerik:RadTreeListView.ChildTableDefinitions>
        <telerik:RadTreeListView.Columns>
     
            <telerik:GridViewDataColumn
                DataMemberBinding="{Binding Name, Mode=TwoWay}"
                CellTemplate="{StaticResource FirstColumnCellTemplate}"
                IsReadOnly="False"
                Width="*"/>
     
            <telerik:GridViewComboBoxColumn
                x:Name="itemTypeColumn"
                Header="Item Type"
                SelectedValueMemberPath="Name"
                DisplayMemberPath="Name"
                ItemsSource="{Binding Context.ItemTypes}"
                DataMemberBinding="{Binding ItemTypeName, Mode=TwoWay}"
                Width="150"/>
     
            <telerik:GridViewDataColumn
                DataMemberBinding="{Binding IsActive, Mode=TwoWay}"
                Header="Include"/>
     
        </telerik:RadTreeListView.Columns>
    </telerik:RadTreeListView>

  2. Joel Palmer
    Joel Palmer avatar
    164 posts
    Member since:
    May 2009

    Posted 07 May 2015 in reply to Joel Palmer Link to this post

    Another point of clarification.  When I assign Item Types to a Hierarchy Node, it defines the type of child nodes that can be added.  When I select the Hierarchy Node and the options for Type assignment it should be limited to its parent's Type list. 

    I've done my best to describe this... hopefully, it is clear,

    Joel

  3. UI for WPF is Visual Studio 2017 Ready
  4. Answer
    Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 12 May 2015 Link to this post

    Hello,

    As to filtering items in GridViewComboBoxColumn, I can suggest the article on: Filter the Items in GridViewComboBoxColumn. You can also check the ComboBox Column on what its capabilities are.

    You can find some more examples on how to configure the column in our github repository. Please note in order to review them in an easier way you can download and configure SDK Samples Browser as described in the documentation.

    As a side note, you say: "When I assign Item Types to a Hierarchy Node, it defines the type of child nodes that can be added". Generally, we suggest using RadTreeListView for displaying homogeneous data only as your bound object should have a hierarchical Items collection defined with the same structure. You can check our online documentation on how RadTreeListView works and how to specify the hierarchy Item.

    Regards,
    Dimitrina
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  5. Joel Palmer
    Joel Palmer avatar
    164 posts
    Member since:
    May 2009

    Posted 13 May 2015 in reply to Dimitrina Link to this post

    Thanks for the response.  You must be busy because it doesn't typically take 6 days.  I thought I did a pretty good job of explaining this scenario so I'm not sure how you think that this isn't homogenous data.  Everything in the hierarchy works and is a basic "Item, Children, ItemType" scenario.

    I load a collection of ItemTypes and a collection of Items.  Each Item can only have a subset of ItemTypes as Children.  I am no longer trying to accomplish this by using the ComboBox to assign the type.  Instead, I have a RadDropDownButton whose list is set by the selected Item's list of acceptable Item Types.  So, the user defines the Type they are adding during the Add instead of after it is created and in the Tree.  Once its in the Tree, the type cannot be changed.

Back to Top