Home - Forums-.NET - FlyTreeView (ASP.NET) - Using NodeSrc

FlyTreeView (ASP.NET)

Technical support and KB related to the FlyTreeView control

This forum related to following products: FlyTreeView for ASP.NET

Using NodeSrc
Link Posted: 06-Nov-2006 00:39
Hi,

I am trying to load about 7500 nodes using the NodeSrc function and Expand Levels. This is working very well with one exception: -

It is very hit or miss as to whether the dynamically loaded nodes will have expand button even if the node should have. Sometimes a node will not have an expand button but on refresh it will.

I have stepped through my code and made sure that the NodeSrc is being added and it is so I am at a loss as to why this is happening.

I really want to use this control but cannot live with it if it will not give consistent results.

Any help would be great here is my code.

foreach(DataRow dr in ds.Tables[0].Rows)
          {
            TreeNode tn = new TreeNode();
            tn.Text = Server.HtmlEncode(dr[\"Text\"].ToString());
            tn.ToolTip = Server.HtmlEncode(dr[\"Text\"].ToString());
            tn.Key = Server.HtmlEncode(dr[\"ID\"].ToString());
            try
            {
              // if folder does not have own children then do not show its NodeSrc
              if (dr[\"HasChildren\"].ToString() != \"0\")
                tn.NodeSrc = \"GetRoleNodes.aspx?ParentID=\" + Server.UrlEncode(dr[\"ID\"].ToString());
              else
                System.Diagnostics.Debug.WriteLine(dr[\"ID\"].ToString());

            }
            catch (Exception ex)
            {
              System.Diagnostics.Debug.WriteLine(dr[\"ID\"].ToString());
              AddExceptionNode(tn.Nodes, ex);

            }
            // adding node to FlyNodeSet
            RoleNodes.Nodes.Add(tn);
          }
        }
        catch (Exception ex)
        {
          System.Diagnostics.Debug.WriteLine(ParentID);
          AddExceptionNode(RoleNodes.Nodes, ex);
        }  
      
    }


Thanks in advance

Oliver
Link Posted: 06-Nov-2006 01:38
Does the page you're loading raise any client-side errors?

I cannot find a reason to render valid XML (with nested nodes) into invalid HTML (with no child nodes). This process is ruled by XSLT stylesheets that are very reliable.

Could you please make some experiment with your code?

Please insert the following code into NodeSrc codebehind somewhere before nodes are populated.
System.Threading.Thread.Sleep(3000); // sleep for several seconds


This way we can detect whether the problem is raised by a significant client-side script load.
Link Posted: 06-Nov-2006 02:26
Hi,

Thanks for your reply, I have tested with this line changing the code to the following.
foreach(DataRow dr in ds.Tables[0].Rows)
          {
            TreeNode tn = new TreeNode();
            tn.Text = Server.HtmlEncode(dr[\"Text\"].ToString());
            tn.ToolTip = Server.HtmlEncode(dr[\"Text\"].ToString());
            tn.Key = Server.HtmlEncode(dr[\"ID\"].ToString());
            try
            {
              // if folder does not have own children then do not show its NodeSrc
              if (dr[\"HasChildren\"].ToString() != \"0\")
                tn.NodeSrc = \"GetRoleNodes.aspx?ParentID=\" + Server.UrlEncode(dr[\"ID\"].ToString());
              else
                System.Diagnostics.Debug.WriteLine(dr[\"ID\"].ToString());

            }
            catch (Exception ex)
            {
              System.Diagnostics.Debug.WriteLine(dr[\"ID\"].ToString());
              AddExceptionNode(tn.Nodes, ex);

            }
            // adding node to FlyNodeSet
            System.Threading.Thread.Sleep(3000);
            RoleNodes.Nodes.Add(tn);
          }


This has not solved the problem, my hierarchy has 8 levels and sometimes I can only get to level 3 and sometimes to level 6.

I wondered if this was a limitation of the trial version?

I did some more tests by setting the Expanded Levels to 0 and clicking through to get child nodes but the same problem exists.

Any more Ideas?

Thanks

Oliver
Link Posted: 06-Nov-2006 03:00
Oliver,

No the trial version does not have such limitation. How many nodes do you load at a time?

Does the built-in filesystem demo (provided within control installer) works correctly?
Link Posted: 06-Nov-2006 07:02
Hi,

Tracked this problem down to a Javascript error. The sample scripts was calling a a few functions that were not included in my project. I'm not sure which call at the moment but I will have another look.

onNodeClientEvent=\"handleNodeEvent();\"


Where do I find the javascript for the examples?

Thanks for your help.

Oliver
Link Posted: 06-Nov-2006 07:14
It seems that you copied flytreeview tags from the sample provided.
The javascript function is included into Demo.aspx file.
Probably you do not need it at this moment. Just delete the onNodeClientEvent and try to open your page again.