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 

Refresh VirtualTree data

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





PostPosted: Tue Feb 21, 2006 2:11 pm    Post subject: Refresh VirtualTree data Reply with quote

Hello!

I would like to refresh data in VirtualTree keeping expanded state of nodes. I mean, those nodes that were expanded before refresh would remain expanded(collapsed remain collapsed).
On refresh DataSource property of the tree is reassigned.
I might need to save expanded state of nodes somewhere before refresh operation and then restore it. But I could not find a way to find out whether a particular node is expanded or collapsed.

Could you help me with this problem?
Thanks.
Back to top
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Tue Feb 21, 2006 11:40 pm    Post subject: Reply with quote

Rather than setting the DataSource again on refresh you might want to consider using the UpdateRows() method to force virtual tree to requery and rebuild the children for each row. This will maintain the expand state of the tree.

To do this it relies on being able to find the index of an item within its parents children using the IList.IndexOf(item) method. If you return the same actual items when the children are requeried this will work. If you create new items each time you return the children (ie there may be multiple objects representing the same item) then you need to ensure that you overload the item IsEqual and GetHashCode methods so that object representing the same item (aliases) are recognised as being the same object.

To answer your actual question you can find out whether a particular Row is expanded by its Expand state.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
CNET Channel
Guest





PostPosted: Wed Feb 22, 2006 4:50 pm    Post subject: Reply with quote

Thanks!
Now I understand how it works inside.
The problem is solved.

I've got yet another issue.
Row class has method InsureVisible(). As I understand it should scroll the tree so that the row is visible. Is it right? Do I need to call any other function to refresh the tree after calling InsureVisible() on some row?
Back to top
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Wed Feb 22, 2006 10:12 pm    Post subject: Reply with quote

Quote:
I've got yet another issue.
Row class has method InsureVisible(). As I understand it should scroll the tree so that the row is visible. Is it right? Do I need to call any other function to refresh the tree after calling InsureVisible() on some row?


No you you shouldn't have to call anything else. Make sure the row has not been disposed of (check its Disposed property). In general you should not hang onto Row objects but instead obtain them (using the FindRow methods) when you need to use them.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
egl



Joined: 27 Jun 2006
Posts: 15
Location: Switzerland

PostPosted: Wed Apr 23, 2008 11:47 am    Post subject: dataset as datasource Reply with quote

hello together,

we have the same problem that the tree collapses when we reload the data. we tried it by not setting the datasource again and use updaterows.
we got the data from a database and don't want to collaps the tree when we refresh the data. so if we don't want to set datasource again, that we have to merge the dataset. but this causes, data that was deleted between the two database calls stayed on the tree. so i tried it by cleaning the dataset before merging the new data back, but this collapsed the tree again. so i thought that the tree may not be able to assign the rows he is showing to one that was just queried from the database.

then i read this:
Quote:
To do this it relies on being able to find the index of an item within its
parents children using the IList.IndexOf(item) method. If you return the same actual items when the children are requeried this will work. If you create new items each time you return the children (ie there may be multiple objects representing the same item) then you need to ensure that you overload the item IsEqual and GetHashCode methods so that object representing the same item (aliases) are recognised as being the same object.


so i thought that i may have to override those methods too to make it possible do find the data. but now my question is:
on the dataset - on what classes do i have to override IsEqual and GetHashCode? DataRow or DataTable or something else?

thanks a lot for the help!

kind regards
jürg
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Wed Apr 23, 2008 10:55 pm    Post subject: Reply with quote

Overriding the IsEqual and GetHashCode methods is only a good idea if the underlying objects really are identical (eg two strings may be different objects - but their contents are identical so IsEqual and GetHashCode can be safely overridden).

For objects like DataRows overriding IsEqual to return true if (for instance some primary key is equal) is likely to cause issues. This is because the two objects may well have different contents. Virtual Tree may hold one copy of the DataRow while your DataSet actually now has a different copy. So when you get the SelectedItems you may actually be getting an old DataRow.

Probably the best solution in this case if you want to keep the expansion state is to handle the RowExpand and RowCollapse events and track the currently expanded rows (by adding them to a collection). Then when you reload the DataSet you can iterate through the collection finding the new DataRows that correspond to the old DataRows and expand the correspong Virtual Tree row.
_________________
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 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