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 

Expand tree to certain items

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



Joined: 21 Nov 2005
Posts: 13

PostPosted: Tue Mar 28, 2006 6:07 am    Post subject: Expand tree to certain items Reply with quote

Can you help me with implementing the following requirement Rolling Eyes :

This is my data-structure, my data structure contains elements that are not to be shown in the tree (this is aranged by overriding the GetChildrenForRow of the ObjectRowBinding):

- Root
- Item A
- Item A1
- ChildToBeShown A1q *
- Item A2
- ChildNotToBeShown A2q
- ChildToBeShown A3q
- Item A3
- ChildToBeShown A3q *
- ChildNotToBeShown A3r *
- Item B
- Item B1
- ChildNotToBeShown B1q
- Item B2
- ChildToBeShown B2q *
- ChildNotToBeShown B2q
- Item B3
- ChildNotToBeShown B3q *
- ChildToBeShown B3q

So, in my virtual tree, when all is expanded it is shown as follows:
- Root
- Item A
- Item A1
- ChildToBeShown A1q *
- Item A2
- ChildToBeShown A3q
- Item A3
- ChildToBeShown A3q *
- Item B
Item B1
- Item B2
- ChildToBeShown B2q *
- Item B3
- ChildToBeShown B3q

When all is Collapsed it is shown as follows:
+ Root

Now, the user clicks a button and wants to expand the tree so that all ChildToBeShown, marked with an asterix(*), are displayed:

- Root
- Item A
- Item A1
- ChildToBeShown A1q *
+ Item A2
- Item A3
- ChildToBeShown A3q *
- Item B
Item B1
- Item B2
- ChildToBeShown B2q *
+ Item B3

I have the collection with all the items that have the * (including the items that do not need to be shown).
- ChildToBeShown A1q *
- ChildToBeShown A3q *
- ChildNotToBeShown A3r *
- ChildToBeShown B2q *
- ChildNotToBeShown B3q *
From here I need to show the tree is shown above.

Could you be so kind to give me some directions/suggestion?
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Tue Mar 28, 2006 9:07 am    Post subject: Reply with quote

I think the formatting showing your hierarchy got lost so it is a little difficult to be sure about what you asking. But I think what you want is to iterate over your collection something like this:

Code:

_virtualTree.SuspendLayout();
foreach (Object item in myItems)
{
    Row row = _virtualTree.FindRow(item);
    if (row != null)
    {
        row.ExpandAncestors();
    }
}
_virtualTree.ResumeLayout();


This assumes that you have set up the Parent-Child relationships by setting the ParentProperty in the RowBindings or by handling the GetParent event and so FindRow will be able to locate the row by traversing the relationships.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Harri



Joined: 21 Nov 2005
Posts: 13

PostPosted: Tue Mar 28, 2006 9:18 am    Post subject: Reply with quote

Yep, the formatting is lost,

In your code, the method FindRow is used. However, when my tree is completly collapsed, all my items are not displayed and the FindRow returns null.

I'll try to repost my tree-hierchie with formatting
Code:

- Root
   - Item A
      - Item A1
         - ChildToBeShown A1q *
      - Item A2
         - ChildNotToBeShown A2q
         - ChildToBeShown A3q
      - Item A3
         - ChildToBeShown A3q *
         - ChildNotToBeShown A3r *
   - Item B
      - Item B1
         - ChildNotToBeShown B1q
      - Item B2
         - ChildToBeShown B2q *
         - ChildNotToBeShown B2q
      - Item B3
         - ChildNotToBeShown B3q *
         - ChildToBeShown B3q

So, in my virtual tree, when all is expanded it is shown as follows:
- Root
   - Item A
      - Item A1
         - ChildToBeShown A1q *
      - Item A2
         - ChildToBeShown A3q
      - Item A3
         - ChildToBeShown A3q *
   - Item B
        Item B1
      - Item B2
         - ChildToBeShown B2q *
      - Item B3
         - ChildToBeShown B3q

When all is Collapsed it is shown as follows:
+ Root

Now, the user clicks a button and wants to expand the tree so that all ChildToBeShown, marked with an asterix(*), are displayed:

- Root
   - Item A
      - Item A1
         - ChildToBeShown A1q *
      + Item A2
      - Item A3
         - ChildToBeShown A3q *
   - Item B
        Item B1
      - Item B2
         - ChildToBeShown B2q *
      + Item B3


Thank you in advance for your answer.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Tue Mar 28, 2006 10:01 pm    Post subject: Reply with quote

The reason FindRow returns null is because there is a problem with your Parent-Child relations. If these are setup correctly it will work even when the tree has not been expanded.

FindRow(Object) works by building the path to the row by calling GetParent until it gets to the root row. If you have SuppressErrorMessages set to false (the default) then if FindRow is unable to locate the row it will print diagnostic messages to the Trace (Visual Studio Output) Window to help you work out what the problem might be.

You can alternatively use one of the other overloaded versions of FindRow that take a full path.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
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