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

ComboBox (dynamic) Binding

3 Answers 215 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Joel Palmer
Top achievements
Rank 2
Joel Palmer asked on 07 May 2015, 07:19 PM

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>

3 Answers, 1 is accepted

Sort by
0
Joel Palmer
Top achievements
Rank 2
answered on 07 May 2015, 07:56 PM

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

0
Accepted
Dimitrina
Telerik team
answered on 12 May 2015, 10:35 AM
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.

 
0
Joel Palmer
Top achievements
Rank 2
answered on 13 May 2015, 04:27 PM

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.

Tags
TreeListView
Asked by
Joel Palmer
Top achievements
Rank 2
Answers by
Joel Palmer
Top achievements
Rank 2
Dimitrina
Telerik team
Share this question
or