Welcome Guest Search | Active Topics | Sign In | Register

Large Treeview : Error Message! Options
Matt
Posted: Monday, February 2, 2009 12:53:30 AM
Rank: Newbie
Groups: Member

Joined: 1/29/2009
Posts: 4
I have had alot of success with your product while trying it out last week. Once I set it up to my full datatable however it has started to cause issues. I may not be populating my dataset in the most efficient way or their might be an easy fix that you know of. Please advise.

Issue: When I load my companies orginizational structure (employee / supervisor) info into my treeview I get the following message:

Stop running this script? A script on this page is causing Internet Explorer to run slowly. If it continues to run, your compute may become unresponsive.

(Datatable contains 5,000 employee/supervisors)

This is how I am currently loading the treeview:

Int64 ThisID;
String ThisName;
DataRow[] children = OrgLoads.Select("SUPERVISOR=" + IntParent);

//no child nodes, exit function
if (children.Length == 0) return;

foreach (DataRow child in children)
{
ThisID = Convert.ToInt64(child.ItemArray[3]);
ThisName = Convert.ToString(child.ItemArray[8]);
EO.Web.TreeNode NewNode = new EO.Web.TreeNode(ThisName);
NewNode.Value = ThisID.ToString();
nodes.Add(NewNode);
NewNode.Expanded = true;
if (Convert.ToString(child.ItemArray[13]) == "false")
{
NewNode.LookID = "look1";
}
BuildEmployeeList3(NewNode.ChildNodes, ThisID);
}

Where OrgLoads is my datatable. I cannot disable this option in IE on all my clients so I will need another solution. Please advise.

Thanks
eo_support
Posted: Monday, February 2, 2009 7:26:33 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

That is normal. The reason is that you are populating the whole database into the TreeView and that is simply too many. When you populating two many nodes to the client side, it is unlikely that user will uses them all. So it's a huge performance waste.

The standard solution for this situation is to use populate on demand. With populate on demand you only load child nodes when user expanded a parent node. You can see an example here:

http://demo.essentialobjects.com/Default.aspx?path=TreeView\_i1\_i1

Hope this helps.

Thanks!
Matt
Posted: Monday, February 2, 2009 5:37:25 PM
Rank: Newbie
Groups: Member

Joined: 1/29/2009
Posts: 4
This may work for me but I have an issue still.
This example is for viewing files in a directory type enviornment.
I need to know what it is suggested for best practices with your control when populating through a SQL call of some sort to a table as I described for example with employees column and boss column.
I can find no examples of using the populate on demand with database ?

Please advise
eo_support
Posted: Monday, February 2, 2009 6:14:06 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

You will basically replace the following calls:

Code: C#
Directory.GetDirectories(parentDirectory);


with your own code that would read your database to get all employees for a given boss. For example, you can write some code like this:

Code: C#
Employee[] employees = GetEmployees(bossId);
foreach (Employee employee in employees)
{
    EO.Web.TreeNode dirNode = new EO.Web.TreeNode(employee.Name);
    ......
}


The above code assumes that you already have an Employee class that contains all employee data, and a GetEmployees function that can get all employees for a given boss Id. If you do not already have those, you can simply call SqlCommand.ExecuteReader with a SELECT sql statement. The function returns an IDataReader for you and you will be able to loop through it like this:

Code: C#
SqlCommand cmd = new SqlCommand("select .....", cn);
IDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
    string employeeName = reader["employeeName"];
   
    EO.Web.TreeNode dirNode = new EO.Web.TreeNode(employeeName);
    ......
}


The above code assumes that you already have a SQL connection "cn", and the field name for employee name is "employeeName". Obviously you may need to change this accordingly.

In order for the code to work, you will need to store "bossId" in your TreeNode, you would usually store it into the TreeNode's Value property. This is similar to the sample code storing the path information into the node's Value property.

Hope this helps.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.