View previous topic :: View next topic |
Author |
Message |
macu
Joined: 06 Jun 2006 Posts: 12
|
Posted: Mon Jun 12, 2006 2:13 pm Post subject: many to many relation realization (m:n) |
|
|
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 |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Mon Jun 12, 2006 10:49 pm Post subject: |
|
|
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 |
|
|
macu
Joined: 06 Jun 2006 Posts: 12
|
Posted: Tue Jun 13, 2006 7:08 am Post subject: |
|
|
thanks very much i will try to do that |
|
Back to top |
|
|
|