Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Multiple ChildRelations, Same Table

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support
View previous topic :: View next topic  
Author Message
jaherbert



Joined: 27 Jan 2008
Posts: 43

PostPosted: Fri Feb 18, 2011 11:19 pm    Post subject: Multiple ChildRelations, Same Table Reply with quote

I have a recursive (DataSet) relationship that creates a hierarchy of categories. The leaves of these categories have detail items. So, there's a recursive relationship among the rows of table1 and the leaf nodes of table1 have a master/detail relationship with table2.

Is it possible to display in a single tree with table1 having two different kinds of children?

Thanks.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Sat Feb 19, 2011 12:30 am    Post subject: Reply with quote

Yes this would be possible - however you would need to handle the GetChildren event programmatically (ie you can't just use design time binding to handle this).

Binding to datasets is a little trickier than to other objects because of the way they use DataRowViews. Here is the basic code you would need in the GetChildren event handler just to replace the standard functionality (minus sorting):

Code:
private void _virtualTree_GetChildren(object sender, GetChildrenEventArgs e)
{
    DataRow dr = e.Row.Item as DataRow;
    if (dr != null)
    {
        DataRelationCollection relations = dr.Table.ChildRelations;
        if (relations.Count > 0)
        {
            DataRowView drv = DataRowRowBinding.GetDataRowView(dr);
            if (drv != null)
            {
                // need to determine the correct relation to use here
                //
                DataView childView = drv.CreateChildView(relations[0]);
                e.Children = new DataViewList(childView);
            }
        }
    }
    else  // for the table just call the default binding method
    {
        RowBinding binding = _virtualTree.GetBindingForRow(e.Row);
        e.Children = binding.GetChildrenForRow(e.Row);
    }
}


The DataViewList class is a wrapper class (in the VirtualTree namespace) that returns the underlying DataRows from a DataView.

Your code would need to select the child relation you wanted to use.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
jaherbert



Joined: 27 Jan 2008
Posts: 43

PostPosted: Tue Feb 22, 2011 10:15 pm    Post subject: Reply with quote

Thanks.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group