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 

UpdateRows() without collapsing tree

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



Joined: 04 Apr 2005
Posts: 69

PostPosted: Mon Apr 04, 2005 3:45 pm    Post subject: UpdateRows() without collapsing tree Reply with quote

It would be a lot more user friendly if UpdateRows() didn't collapse the entire tree, but kept the view exactly as it was, except that changes in the data source would be reflected.
I try to use UpdateRowData instead, but that doesn't catch new and deleted children.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Tue Apr 05, 2005 8:23 am    Post subject: Reply with quote

Actually this is the behaviour of UpdateRows() if you don't generate new lists of objects each time GetChildren. You can check this by modifying the ADO Dataset sample to call UpdateRows() - the current tree expansion state is unaffected.

The UpdateRows() method simply calls RootRow.UpdateChildren(reloadChildren =>true, recursive => true). Which means that the tree will cause the lists of children to be reloaded. If instead you call RootRow.UpdateChildren(false, true) you will probably get the behaviour you want.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
MHB



Joined: 04 Apr 2005
Posts: 69

PostPosted: Wed Apr 06, 2005 2:39 pm    Post subject: Reply with quote

Quote:
this is the behaviour of UpdateRows() if you don't generate new lists of objects each time GetChildren

That was a nice piece of information, it should be in the description of UpdateChildren, UpdateRows and/or GetChildrenForRow! I generated new lists on every call. I have now changed this behaviour, resulting in a few complications, but it works...

UpdateChildren(reloadChildren = false, recursive = true) did not solve the problem. In fact it seems like only leaf nodes are reloaded. I don't quite see how reloadChildren = false should be useful?
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Wed Apr 06, 2005 11:50 pm    Post subject: Reply with quote

If the actual list object you return in GetChildrenForRow doesn't change (ie you maintain a reference to this list in your own code) then you could add an item to the list of children and then call UpdateChildren(false, true) on the parent row.

VirtualTree then does not have to call GetChildrenForRow again to reload the list of children (because the list reference is unchanged). It simply updates the visual representation of the rows children to match the new size and contents of the current list.

Typically in this paradigm GetChildrenForRow would create new lists and their contents (for example loading objects from a database) and you use UpdateChildren(false, true) to force the tree to update the visual representation when you add/delete something to one of the lists.

If you have a large project then I would also recommend investigating using lists that support IBindingList as this means you don't have to hand code the update stuff at all - it all happens automatically. We provide a base class (BindingCollectionBase) that makes implementing binding collections very easy.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
MHB



Joined: 04 Apr 2005
Posts: 69

PostPosted: Fri Apr 08, 2005 11:18 am    Post subject: Reply with quote

Thanks - good explanation! Now I think I understand what's going on. These descriptions belong in the help files, so others may find them more easily!
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 Feature Requests 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