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 

many to many relation realization (m:n)

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



Joined: 06 Jun 2006
Posts: 12

PostPosted: Mon Jun 12, 2006 2:13 pm    Post subject: many to many relation realization (m:n) Reply with quote

I have a tables in dataSet look like that :
--------
Author
PK(ID)
---------
Book
PK(ID)
--------
AuthorBook
PK(ID-book)
PK(ID-author)
--------

My relation look like this
Author(ID) -> AuthorBook(ID-author)
Author(ID) <- AuthorBook(ID-author)

Book(ID) -> AuthorBook(ID-book)
Book(ID) <- AuthorBook(ID-book)

I want to use your tree to display Author-Book relation but the problem is that it has 3 levels.
Author-+
...........|
...........+-AuthorBook-+
.................................|
.................................+-Book
Is it possible to hide AuthorBook level ??
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Mon Jun 12, 2006 10:49 pm    Post subject: Reply with quote

Yes you can do this. You will have to handle the GetChildren event programmatically. Below is some code that modifies our DataSet Browser sample to display all the OrderDetails directly for a customer (bypassing the Orders table)

Code:
        private void _virtualTree_GetChildren(object sender, GetChildrenEventArgs e)
        {
            OrderDataSet.CustomersRow customer = e.Row.Item as OrderDataSet.CustomersRow;
            if (customer != null)
            {
                 string filter = "Parent(OrdersDetails).CustomerID = '" + customer.CustomerID + "'";
                 e.Children = this._dataSet.Order_Details.Select(filter);
            }
            else
            {
                RowBinding binding = _virtualTree.GetBindingForRow(e.Row);
                e.Children = binding.GetChildrenForRow(e.Row);
            }
        }


Note that if you want to support sorting you will need to call the Select method with a sort expression based on the current SortColumn. You should also modify GetParent to return the correct parent for each row type - otherwise you will not be able to use VirtualTree methods to select rows based on the underlying DataRow.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
macu



Joined: 06 Jun 2006
Posts: 12

PostPosted: Tue Jun 13, 2006 7:08 am    Post subject: Reply with quote

thanks very much i will try to do that Very Happy
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