View previous topic :: View next topic |
Author |
Message |
TomY
Joined: 21 May 2010 Posts: 8
|
Posted: Fri May 21, 2010 10:46 pm Post subject: Making flat data palatable to Virtual Tree |
|
|
I am evaluating Virtual Tree for use in developing an in-house utility and am having a problem binding data from an ArrayList of simple objects. I have done some development with C#, but am still at a low enough level that I learn several new things every day that I work with it. :-p
I have looked at the ProgrammaticBinding sample, but our data is flat and does not have the recursive nesting of the data in that example, so parent/child relationships are not identified by individual rows. I am working with VS2005 and C#.
A simplified representation of our data would look like:
Code: |
MyArrayList
MyObject
Group=A
Name=X
MyObject
Group=A
Name=Y
MyObject
Group=B
Name=Z
|
For what it's worth, the entries in the ArrayList are already sorted by Group -- we would like to see the above represented in a list/tree like:
I could probably get this working with a DataGrid or TreeView control without too much trouble, but the fly in the ointment is that we have the requirement to drag and drop rows to a second control and support re-ordering them in that control. It looks like Virtual Tree should handle this requirement very well.
So do I need to write a class that will let the flat list be presented by Group with a list of the associated Name values for children, or is there some sort of built-in mechanism utilizing flat data? The reason that I ask that is that a lot of data must be pulled from databases in a tabular form and need such processing before loading into Virtual Tree.
Recommended approaches and/or examples from the experienced folks here would be appreciated.
Thank-you. |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Fri May 21, 2010 11:09 pm Post subject: |
|
|
Virtual Tree is designed to work with hierarchical data. You have two alternatives. The first is to parse your flat data and convert it into a hierarchical object model. This will make binding to it and working with it in Virtual Tree very easy (see the simple Tree sample). However if you are pulling a large amount of data from a database then this may be prohibitively expensive in terms of memory and processing.
The second alternative is to use Programmatic Binding. In this case you would handle the GetChildren event and parse your data on the fly to return a list of children for a particular object.
How are extracting the data from the database (are you using ADO.NET)? _________________ Infralution Support |
|
Back to top |
|
|
TomY
Joined: 21 May 2010 Posts: 8
|
Posted: Sat May 22, 2010 9:54 pm Post subject: |
|
|
Thanks for clearing that up.
In this case the data is coming from a flat file and a library object holds the records. It may be that my best approach is to convert the data into hierarchical form when loading it into a new type of object purpose-made for feeding Virtual Tree. The amount of data is not huge so I shouldn't have any trouble holding it all in a list for the processing.
Thanks again for the rapid response. |
|
Back to top |
|
|
|