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
Just tried this and it worked. Not sure why but it did. FYI - can someone explain the relationship between the Key and TargetTypeName a little better. It seems like the key can be a "property? or method?" and the TargetTypeName is a "type" If this is true my problem here i think was with a parent and child relationship of the same table/type using TargetTypeName would not work. Is my solution correct? Why would the key not work with a methods but it did when I turned it into a property?
Here is what I did
Here is code generated for typed data set of empleyees from northwind db
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()][global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")]public EmployeesRow[] GetEmployeesRows() { if ((this.Table.ChildRelations["FK_Employees_Employees"] == null)) { return new EmployeesRow[0]; } else { return ((EmployeesRow[])(base.GetChildRows(this.Table.ChildRelations "FK_Employees_Employees"]))); } }
**** I created this to test with property because specifying GetEmployeesRow in Key= did not work...
public EmployeesRow[] EmployeesChildren { get { return this.GetEmployeesRows(); } }
*** This worked ... see below
Xaml Change:
<ig:XamDataTree ItemsSource="{Binding EmployeesTable}" Name="employeesXamDataTree"> <ig:XamDataTree.GlobalNodeLayouts> <ig:NodeLayout Key="ParentLayout" TargetTypeName="EmployeesRow" DisplayMemberPath="LastName"/> <ig:NodeLayout Key="EmployeesChildren" DisplayMemberPath="LastName"/> </ig:XamDataTree.GlobalNodeLayouts>
</ig:XamDataTree>
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.