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 

Sorting automatically

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



Joined: 24 Dec 2005
Posts: 63

PostPosted: Thu Nov 22, 2007 5:20 am    Post subject: Sorting automatically Reply with quote

In the documentation, it says "If your DataSource implements the ITypedList and IBindingList interfaces then the ObjectRowBinding class will handle sorting for you automatically."

I am finding it is not so straightforward Smile

I am using Object binding and setting it up programatically.

If I have a class MyClass and a class SortableList<MyClass> that implements IBindingList and ITypedList, what properties do I need to specify for the ObjectRowBinding?

The SortableList is the root row, and the other objects are the data rows.

I am currently using version 2 - do I need verison 3 to handle the generics?
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Thu Nov 22, 2007 10:30 pm    Post subject: Reply with quote

While it should be possible to get Version 2 of Virtual Tree to bind properly to a generic list I would strongly recommend upgrading to Version 3 of Virtual Tree if you are using .NET 2.0 or later. Version 3 includes explicit support for generic types and other .NET features as well as a number of performance improvements.

See the following thread on the changes to ObjectBindings for generics (and possible workarounds for Version 2 which doesn't have these changes)

http://www.infralution.com/phpBB2/viewtopic.php?t=557

There are couple of things you have to get right for sorting using ITypedList to work properly:

First you must supply a RowBinding that binds to the root item (ie the DataSource). Note that if VirtualTree cannot find a binding for the root item it will still display items (if the DataSource supports IList) - however sorting via ITypedList will not work.

The best way to ensure that your RowBinding will bind to a generic type is probably to set the rowBinding.Type property programmatically eg

Code:
rowBindingSortableList.Type = typeof(SortableList<MyClass>);


The ChildProperty for the root binding should be set to "this"

Secondly for the RowBinding you create for items in the list you should set the TypeListName property (not the TypeName or Type property). This should be set to the Name returned by ITypedList.GetListName(null). This means that Virtual Tree will use the ITypedList interface to retrieve information about the items (rather than using reflection).
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Andrew Rowley



Joined: 24 Dec 2005
Posts: 63

PostPosted: Fri Nov 23, 2007 9:05 am    Post subject: Reply with quote

Thanks, I have it working now. I have downloaded version 3, and will probably upgrade soon.
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