<div> <ig:WebScriptManager ID="WebScriptManager1" runat="server"> </ig:WebScriptManager> <ig:WebHierarchicalDataGrid ID="WebHierarchicalDataGrid1" runat="server" Height="350px" InitialDataBindDepth="-1" InitialExpandDepth="-1" Width="1000px" AutoGenerateBands="False" AutoGenerateColumns="False" DataKeyFields="ProductID, ClassID" DataMember="SqlDataSource1_DefaultView" DataSourceID="WebHierarchicalDataSource1" IsSelfReference="true" Key="SqlDataSource1_DefaultView"> <Behaviors> <ig:Paging> </ig:Paging> </Behaviors> <Columns> <ig:BoundDataField DataFieldName="ProductID" Key="ProductID"> <Header Text="ProductID" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="ProductName" Key="ProductName"> <Header Text="ProductName" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="CustomerName" Key="CustomerName"> <Header Text="CustomerName" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="ClassID" Key="ClassID"> <Header Text=" ClassID " /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="ParentId" Key="ParentId"> <Header Text="ParentId" /> </ig:BoundDataField> </Columns> </ig:WebHierarchicalDataGrid> <ig:WebHierarchicalDataSource ID="WebHierarchicalDataSource1" runat="server"> <DataViews> <ig:DataView ID="SqlDataSource1_DefaultView" DataMember="DefaultView" DataSourceID="SqlDataSource1" /> </DataViews> <DataRelations> <ig:DataRelation ChildColumns="ParentId, ClassID" ChildDataViewID="SqlDataSource1_DefaultView" ParentColumns="ProductID, ClassID" ParentDataViewID="SqlDataSource1_DefaultView" /> </DataRelations> </ig:WebHierarchicalDataSource> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MyDatabaseConnectionString %>" SelectCommand="SELECT [ProductID], [ProductName], [CustomerName], [ClassID], [ParentId] FROM [vwTesting]"> </asp:SqlDataSource> </div>
this scenario was created in designer modeversion 10.2
Hi quantom,
Thank you for your reply.
Parent nodes need to have the childID values set to NULL which is why your machineID parent-child relation cannot be applied - the parent row needs to have a NULL value for machineID in order to be a parent, but in the same time it would need to have a NON-NULL value to be matched with any child rows.
Therefore it might be worth considering to add a new column to your database table which has NULL for rows where ParentJobID is NULL, i.e. for parent rows.
Please let me know if this answers your questions.
Best Regards,Petar IvanovDeveloper Support EngineerInfragistics, Inc.http://ko.infragistics.com/support
Thank you for your reply, few question arise
1. So am I suppose to change the database to add it another column just to be able to use this control ?
2. How would there be infinite nesting, that can't already be when using one column relationship, I can easy build an infinite loop with one column, and the 2nd column is just an extra constraint, so I don't understand the logic for preventing this simple feature that is enabled without problem on .NET's DataRelation.
3. You forgot to mention that the parent nodes must have the childID set to NULL, otherwise it five empty table.
Thank you for posting in the community.
Please note that when defining a self reference based on more than one key, the child and parent columns need to be different, for instance:
JobID, MachineIdentityID - > ParentID, ParentMachineIdentityID.
This ensures that no infinite parent-child nesting occurs.
Here is some sample code for a self-referenced grid with 2 datakeyfields (where the parent-child relation is based on different columns):
<ig:WebHierarchicalDataGrid ID="WebHierarchicalDataGrid1" runat="server" DataSourceID="WebHierarchicalDataSource1" Height="350px" IsSelfReference="True" Width="400px" AutoGenerateBands="False" AutoGenerateColumns="False" DataKeyFields="JobID,MachineIdentityID" DataMember="SqlDataSource4_DefaultView" Key="SqlDataSource4_DefaultView" MaxDataBindDepth="1" style="margin-right: 0px" > <Columns> <ig:BoundDataField DataFieldName="JobID" Key="JobID"> <Header Text="JobID" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="MachineIdentityID" Key="MachineIdentityID"> <Header Text="MachineIdentityID" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="ParentJobID" Key="ParentJobID"> <Header Text="ParentJobID" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="ChildMachineID" Key="ChildMachineID"> <Header Text="ChildMachineID" /> </ig:BoundDataField> </Columns> <Behaviors><ig:Paging></ig:Paging></Behaviors> </ig:WebHierarchicalDataGrid> <ig:WebHierarchicalDataSource ID="WebHierarchicalDataSource1" runat="server" Width="333px"> <dataviews> <ig:DataView ID="SqlDataSource4_DefaultView" DataMember="DefaultView" DataSourceID="SqlDataSource4" /> </dataviews> <DataRelations> <ig:DataRelation ChildColumns="ParentJobID,ChildMachineID" ChildDataViewID="SqlDataSource4_DefaultView" ParentColumns="JobID,MachineIdentityID" ParentDataViewID="SqlDataSource4_DefaultView" /> </DataRelations> </ig:WebHierarchicalDataSource> <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:TestConnectionString %>" SelectCommand="SELECT [JobID], [MachineIdentityID], [ParentJobID], [ChildMachineID] FROM [DoubleDependency]"> </asp:SqlDataSource> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT [EmployeeID], [LastName], [FirstName], [ReportsTo] FROM [Employees]"> </asp:SqlDataSource> <asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$ ConnectionStrings:TestConnectionString %>" SelectCommand="SELECT * FROM [DoubleDependency]"></asp:SqlDataSource>
Please let me know if you have any questions.