473,394 Members | 1,778 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

hierarchical implementation question

Hi,

I want to retrieve the hierarchical structure which is store inside
the database and then display it using treeview control. But now I
got a design issue which I hope that you guys can help me. My
hierarchical structure has five levels which is store in table call
level1, level2,… level5. Each level remember the parent ID e.g. level5
contains a column called level4ID. How should I implement it in order
to get fastest loading?
Currently what I think of is that fill the records in level1,
level2, level3, level4, level5 into the same dataset. Then use nested
loop to implement the treeview.
Can anyone give me more efficient solution? Seems like I am a stupid
programmer.

foreach(DataRow dr in dsAcctChart.Tables[Level1].Rows)
{
treeview1.Nodes.Add(dr["Name"].ToString());
DataRow [] drows=dsAcctChart.Tables[Level2].Select("Level1ID=" +
dr["ID"].ToString());
foreach(DataRow dr1 in drows)
{
if(treeView1.SelectedNode == null)
treeView1.SelectedNode=treeView1.Nodes[Level1NodeCount];
treeView1.SelectedNode.Nodes.Add(dr1["Name"].ToString());
foreach(..Level3)
….
foreach(….Level4)
…..
foreach(… Level5)
}
}
Nov 15 '05 #1
1 1778
"jayson_13" <ja*******@yahoo.com> wrote in message
news:85**************************@posting.google.c om...
Hi,

I want to retrieve the hierarchical structure which is store inside
the database and then display it using treeview control. But now I
got a design issue which I hope that you guys can help me. My
hierarchical structure has five levels which is store in table call
level1, level2,. level5. Each level remember the parent ID e.g. level5
contains a column called level4ID. How should I implement it in order
to get fastest loading?
Currently what I think of is that fill the records in level1,
level2, level3, level4, level5 into the same dataset. Then use nested
loop to implement the treeview.
Can anyone give me more efficient solution? Seems like I am a stupid
programmer.


Loading data-heavy tree-views can be tricky and time-consuming. There's two
things I do which may apply to your situation.

1. Lazy-Loading - on form load, load only the top level treeview nodes.
Then, hook the expand event so that whan the user expands a node, you
quickly load its child nodes from the database and insert them into the
tree. I usually pin data to the Tag of each TreeNode which tells me what
information needs to be loaded for the children of that node. SqlBuddy
(http://sqlbuddy.sourceforge.net) uses this approach to load in the Database
Explorer - and it's pretty darn quick! You can see the idea in the link
below( watch for breaks) - look for the HandleExplandNode function about 1/4
down the page:

http://cvs.sourceforge.net/viewcvs.p...viewcvs-markup

2. Freezing the View - by visually freezing the view and showing an
hourglass, you can at least reduce the impression that loading of the tree
is slow. I think a flickering tree makes the user very aware that things are
taking time! In buddy I used a WinAPI call to freeze the tree as it is
cleared and reloaded. Again, you can see this in the first two lines of the
HandleExpandNode method.

Hope this helps

Tobin Harris
Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Reimar Bauer | last post by:
Hi all, I would like to use a hierarchical group oriented encryption. Is there something implemented or did you know something I could use? For explanaition. If you have a large building...
0
by: Mike N. | last post by:
Hello to all: First let me apologize for the length of this question, I've made an attempt to include as much information as is needed to help with the question. I am having problems putting...
1
by: John | last post by:
Hi, We have XML files (and its XSD) that are dump of our tree-like data structure in memory. These XML files may potentially have unlimited levels of nesting because some elements can contain...
2
by: Dennis Allen | last post by:
Hi. I've been using a simple css based outline on my web site. A section of hyperlinks within <div class>, imitating open/closed folders. Problem. Since the folder is on the lower left of the...
4
by: Daisy | last post by:
Let's say I've got a forum, where users can be moderators of each forum. Tables look like this: USER -------- user_key name FORUM
5
by: clintonG | last post by:
I'm looking for documentation and would not turn my nose up to any code from anybody who thinks they are good at the design of an algorythm that can be used to generated a hierarchical relational...
4
by: Congero | last post by:
I'm trying to find a way to bind hierarchical data to a gridview control. I've been able to do this with some third party controls and was wondering if this functionality is available with the...
2
by: =?Utf-8?B?cndvb2RydWY=?= | last post by:
Hello, I am attempting to utilize the membership provider to do the following: Boss Manager Employee which means that Boss has all the rights of the Manager, the Manager has all the rights...
4
by: Marco Pais | last post by:
Hi there. I am trying to find th best way (best UI control) to present hierarchical data, nested tables. For example, I have a Employees table (id, name) and EmployeesSales (id, idEmp,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.