Home - Forums-.NET - FlyTreeView (ASP.NET) - RE: script error using tooltip

FlyTreeView (ASP.NET)

Technical support and KB related to the FlyTreeView control

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

RE: script error using tooltip
Link Posted: 08-Aug-2006 02:44
TreeView operates correctly with nodes populated on demand, however, I wish to programmatically populate nodes if needed (eg: if a search reveals the node in question has not yet been rendered/populated then I wish to populate this node without user click...).

error initially in function call:
onmouseenter=\"CFlyTreeNode_mouseover(this);...

error line in function (because _fv50._fv148._fv32 is null):
_fv50._fv32=_fv50._fv148._fv32.childNodes.item(_fv50.i);

Occurs when trying to dynamically create/add nodes as follows (tried this with/without onPopulateNodes=\"...\"):

tried:
oNode.ExpandLevel = 99;
oNode.PopulateNodesOnDemand = Convert.ToBoolean(hasChild);



also tried:
GetNodeChildren(oNode);

where:
public void GetNodeChildren(FlyTreeNode oNodeIn)
{
        
      FlyTreeNode nodeGroup;

      //Populate the TreeView from the DataSet.
      foreach (oNodeRow in oNodeDS)
      {
          nodeGroup = new FlyTreeNode(oNode.Name, Convert.ToString(oNode.ID));                

          nodeGroup.Tag = ...
          nodeGroup.ImageUrl = ...
          nodeGroup.IsCheckbox = ...
          nodeGroup.NavigateTarget = ...

          if (ShowCheckBoxes)
          {
        //assign to tooltip instead of navigateURL
        //as we dont want selecting node to render an target  
              nodeGroup.ToolTip = ...
          }
          else
          {
              nodeGroup.NavigateUrl = ...
          }                

    //tried with and without the following line
          //nodeGroup.PopulateNodesOnDemand = Convert.ToBoolean(hasChild);
    //

          GetNodeChildren(nodeGroup);
          oNodeIn.ChildNodes.Add(nodeGroup);
      }
            
}
Link Posted: 08-Aug-2006 08:51
Do you use any client-side code to add nodes?
What FlyTreeView event handlers do you use add nodes?
Also, what exact version of FlyTreeView do you use (icluding build number)
Link Posted: 08-Aug-2006 21:53
I am using a demo version for ASP.NET 2.0 (v4.0 build 131) all code to add these nodes is server-side. I get the same error if I try to create the entire tree at page load  - the error appears when the mouseover script fires.

Cheers
McNulty
Link Posted: 08-Aug-2006 22:29
Sorry, I thought more info might help (I have also upgraded the demo version to build 132)...

error occurs in file: node_01_init.js
in function: CFlyTreeNode.getInstance=function(_fv12)
at line: _fv50._fv32=_fv50._fv144._fv32.childNodes.item(_fv50.i);
because: _fv50._fv144._fv32 is null

To try and simplify things, I have completely left out dynamic node population (which works a treat), so all I want to do is populate the entire tree from the server.

Tree source is:
ExpandLevel=\"1\" BorderColor=\"Silver\" BorderWidth=\"1px\" Height=\"400px\" Width=\"425px\">

Server Page.Load (using strongly typed datasets) is:

...
   FlyTreeNode nodeGroup;

   FlyTreeNode oRootNode = new FlyTreeNode(\"Root\",\"Root\");
   tv.Nodes.Add(oRootNode);

   //Populate the TreeView from the DataSet.
   foreach (BMSRootNodes.spSelectRootNodesRow rootNode in rootNodes)
   {
      nodeGroup = new FlyTreeNode();
      nodeGroup.Text = rootNode.Name;
      nodeGroup.Value = Convert.ToString(rootNode.ID);

      oRootNode.ChildNodes.Add(nodeGroup);

      //finally, get the children for each root
      GetNodeChildren(nodeGroup);
   }
...


where:

public void GetNodeChildren(FlyTreeNode oNodeIn)
{
...
   FlyTreeNode nodeGroup;

   //Populate the TreeView from the DataSet.
   foreach (BMSRootNodes.spSelectRootNodesRow oNode in oNodes)
   {
      nodeGroup = new FlyTreeNode(oNode.Name, Convert.ToString(oNode.ID));              
      oNodeIn.ChildNodes.Add(nodeGroup);

      if (Convert.ToBoolean(oNode.hasChild)) GetNodeChildren(nodeGroup);
   }
...
}
Link Posted: 08-Aug-2006 22:59
OK, I have found the problem. There appears to be an issue in the treeview when you include a tooltip which contains the '/' char.

The server-side source is:
nodeGroup.ToolTip = oNode.NavigateURL;


which I use to temp hold the URL I will use later (this is an admin operation so I don't want the target/URL etc to be active as such).

The rendered code is:

Infrastructure


It the tooltip is removed, the error disappears...If the tooltip is changed so there are no slashes in it the error disappears. I tried to HTML encode the tooltip but still no luck.

At least I now know what the problem is so can work around it...

Cheers
McNulty
Link Posted: 09-Aug-2006 21:58
I've partially created a page with your code and sample datasets. I do not experience any problems with it.
Could you please add any code that will break flytreeview?

This is code-behind. ASPX is quite the same as you posted.

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using NineRays.WebControls;

public partial class Tooltip_Test : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            FlyTreeNode nodeGroup;

            FlyTreeNode oRootNode = new FlyTreeNode(\"Root\", \"Root\");
            tv.Nodes.Add(oRootNode);

            DataTable rootNodes = new DataTable();
            rootNodes.Columns.Add(\"ID\", typeof(string));
            rootNodes.Columns.Add(\"Name\", typeof(string));
            rootNodes.Columns.Add(\"NavigateUrl\", typeof(string));

            rootNodes.Rows.Add(\"1\", \"name1\", \"name1/name1.htm\");
            rootNodes.Rows.Add(\"2\", \"name2\", \"name2/name2.htm\");
            rootNodes.Rows.Add(\"3\", \"name3\", \"name3/name3.htm\");

            foreach (DataRow rootNode in rootNodes.Rows)
            {
                nodeGroup = new FlyTreeNode();
                nodeGroup.Text = (string)rootNode[\"Name\"];
                nodeGroup.Value = (string)rootNode[\"ID\"];
                nodeGroup.NavigateUrl = (string)rootNode[\"NavigateUrl\"];
                nodeGroup.ToolTip = nodeGroup.NavigateUrl;

                oRootNode.ChildNodes.Add(nodeGroup);

                //finally, get the children for each root
                GetNodeChildren(nodeGroup);
            }


        }



    }
    public void GetNodeChildren(FlyTreeNode oNodeIn)
    {

        DataTable oNodes = new DataTable();
        oNodes.Columns.Add(\"ID\", typeof(string));
        oNodes.Columns.Add(\"Name\", typeof(string));
        oNodes.Columns.Add(\"Value\", typeof(string));

        oNodes.Rows.Add(\"1\", \"name1\", \"value1\");
        oNodes.Rows.Add(\"2\", \"name2\", \"value2\");
        oNodes.Rows.Add(\"3\", \"name3\", \"value3\");

        FlyTreeNode nodeGroup;

        //Populate the TreeView from the DataSet.
        foreach (DataRow oNode in oNodes.Rows)
        {
            nodeGroup = new FlyTreeNode((string)oNode[\"Name\"], (string)oNode[\"Value\"]);
            oNodeIn.ChildNodes.Add(nodeGroup);

//            if (Convert.ToBoolean(oNode.hasChild)) GetNodeChildren(nodeGroup);
        }

    }
}