I am trying to figure out how to bind a dataset datatable "Typed" with a self referencing relationship into the tree. I have tried many options none of witch seem to work. I sort of understand the relationship between the TargetTypeName and the underlying data. From my unerstanding its not a property or method but a type that it is trying to match in the underlying data source... I think? If so then the type for both my nodes parent and child is the same... and that did not work... This is simple to recreate... I used the employees table from northwind but any self referencing dataset datatable will do.
EmployeesTable returns a stringly typed EmployeesDataTable - Example from Northwind DB Employees table.
I get the first level but cant seem to get anything else... Plus since this releationship can go more than two deep do i need to create another nodelayout one for as many levels as i think my data will go or is one second child level enough for it to create all other levels based on the data. The ChildLayout below is not working this was just one thing i tried.. Also can you explain a little more on how the key comes into play. I read a post the described its usage in some cases to assist in finding the item... but not quite sure how this works.
<ig:XamDataTree ItemsSource="{Binding EmployeesTable}" Name="employeesXamDataTree"> <ig:XamDataTree.GlobalNodeLayouts> <ig:NodeLayout Key="ParentLayout" TargetTypeName="EmployeesRow" DisplayMemberPath="LastName"/> <ig:NodeLayout Key="ChildLayout" TargetTypeName="EmployeesRow.GetEmployeesRows" DisplayMemberPath="Title"/> </ig:XamDataTree.GlobalNodeLayouts> </ig:XamDataTree>
I moved this from the Silverlight section to WPF. My previous post was in Silverlight section by accident.
Basically just trying to figure out how the set the options in xaml to get a dataset
with a self referencing relationship to show the data in the tree with parent and children
based on the relationship.
Thanks in advance
Any thoughts on the previous two posts?
Another question. Now I add one more level to the previous example... and then I start getting "Band" like headers above the two levels... show below I don't want those headers... How do I get ride of them?
<ig:XamDataTree ItemsSource="{Binding Offices}" Name="locations" DisplayMemberPath="caption" > <ig:XamDataTree.GlobalNodeLayouts> <ig:NodeLayout Key="rootLocations" DisplayMemberPath="caption"/> <ig:NodeLayout Key="locationsChildren" DisplayMemberPath="caption" /> <ig:NodeLayout Key="containersCurrent" DisplayMemberPath="caption" /> </ig:XamDataTree.GlobalNodeLayouts> </ig:XamDataTree>
When I add in containersCurrent a relation hanging off locations it shows everything in the right place but i get Header or "bands" with the Key name showing up on two nodes ... Why? and How can I get rid of them.
Yes it was some what helpful in that it better describes some items... but I am still having a bit of trouble getting what I want. I'll explane. Yes when you have a single self referent as the top of the tree your setting the key=1 and targettypename=objecttype works. But when I move to a situation like I have it does not quite work.
I have office entity with a relationship to locations
Offices --> Locations (self reference)
<ig:XamDataTree ItemsSource="{Binding Offices}" Name="locations" DisplayMemberPath="caption" > <ig:XamDataTree.GlobalNodeLayouts> <ig:NodeLayout Key="Locations" DisplayMemberPath="caption"/>
so it should look like
Cleveland
Location A
Location B
Location B.1
Location B.2
... etc
But what I get is
Now I tried two options.
Option 1 (did not work)
In windows controls I'm used to either filtering out the first level to just be the root data items or in the row or node initialize i check the level and if it is the rool level and the parent id is not null I hide the node. This has alwasy work fine for me in windows form controls of yours. So I thought hey give it a try. So i did the below. (if node is a locations node and its level = 1 (root) hide node if its not a root.
private void locations_InitializeNode(object sender, Infragistics.Controls.Menus.InitializeNodeEventArgs e) { location l = e.Node.Data as location; XamDataTree t = sender as XamDataTree; XamDataTreeNode n = e.Node; Infragistics.Controls.Menus.NodesManager m = n.Manager; Debug.Print("Nodel Level = " + m.Level.ToString() + " Name = " + n.ToString() + " Hidden = " + n.NodeLayout.Visibility.ToString()); if (l != null) { if (m.Level == 1 && l.parent_location_id != null) { m.NodeLayout.Visibility = System.Windows.Visibility.Hidden; n.NodeLayout.Visibility = System.Windows.Visibility.Hidden; //XamDataTreeNodeControl c = n.control //c.Visibility = System.Windows.Visibility.Hidden; } else Debug.Print("Not Hidden Node Index = " + n.Index.ToString()); }
For some reason this never worked. Even though the Visibility is set to Hidden it still shows. Why?
So I moved to my second option and make another entity inherited from locations called rootLocations that only got the root records and then modifed the locations entity to on get children then did the following.
<igWindows:TabItemEx Header="Other 3"> <ig:XamDataTree ItemsSource="{Binding Offices}" Name="locations" DisplayMemberPath="caption" > <ig:XamDataTree.GlobalNodeLayouts> <ig:NodeLayout Key="rootLocations" DisplayMemberPath="caption"/> <ig:NodeLayout Key="locationsChildren" DisplayMemberPath="caption" /> </ig:XamDataTree.GlobalNodeLayouts> </ig:XamDataTree> </igWindows:TabItemEx>
This gave me what I wanted. I don't really have a problem doing this it does remove a few issues that I had to deal
with in window about the nodes being hidden... but still wondering why the hide node via visibility did not work.
Did I do something wrong?
Hello ks4561,
I am just checking if my last reply was helpful for you.
If you require any further assistance please do not hesitate to ask.
Sincerely,
Yanko
Developer Support Engineer
Infragistics
www.infragistics.com/support
I have been looking into your issue and I suppose you use the ADO.NET Entity Framework to create a connection to the database. If you would like to get more information about the properties of the NodeLayout object you can look through the following link :
http://help.infragistics.com/NetAdvantage/WPF/2011.2/CLR4.0/?page=xamDataTree_Node_Layouts.html
As you can see the ‘Key’ property works as an unique identifier of the node layout and if you would like the tree to automatically create children nodes, the ‘Key’ can be set to the property of the objects in the initial collection. This is the reason why nothing happens when you set it to a method.
The ‘TargetTypeName’ allows you to specify a mapping between the NodeLayout and a data source property by telling the xamDataTree control to match this property’s value to the object Type name contained in the collection exposed by a data source property.
The ‘DisplayMemberPath’ specifies the property of the object type that will be displayed in the tree.
I can suggest you use only one NodeLayout like :
<ig:NodeLayout Key="1"
TargetTypeName="EmployeesRow"
DisplayMemberPath="LastName">
</ig:NodeLayout>
In this case the ‘Key’ is used as an unique identifier and the children nodes will be created automatically.
If you have any other questions, feel free to ask.