ToolTips for treeview nodes

6 posts, 0 answers
  1. Phani Alla
    Phani Alla avatar
    29 posts
    Member since:
    Jun 2009

    Posted 03 Sep 2009 Link to this post

    Hello,

    I'm trying to display a userControl in a tooltip for a treeview control which is displayed for few nodes based on a condition, The tooltip should display textboxes with some attributes of the Node, I'm Using RadToolTipManager following the demo

     <telerik:RadToolTipManager Width="215px" Skin="Sunset" Height="260px" 
                                RelativeTo="Element" AutoTooltipify="false" HideEvent="FromCode" ShowEvent="FromCode" ID="RadToolTipManager2" runat="server" OffsetX="15" Position="MiddleRight" 
                                OnAjaxUpdate="RadToolTipmanager1_AjaxUpdate"
                            </telerik:RadToolTipManager> 

    I'm setting the value of the tooltip to the NodeID
    function OnClientMouseOver(sender, args) { 
             
             var nodeElem = args.get_node(); 
             if (nodeElem.get_level() != 0) { 
                 var node = nodeElem.get_textElement(); 
     
                 var tooltipManager = $find("<%= RadToolTipManager2.ClientID%>"); 
     
                 //If the user hovers the image before the page has loaded, there is no manager created 
                 if (!tooltipManager) return; 
     
                 //Find the tooltip for this element if it has been created  
                 var tooltip = tooltipManager.getToolTipByElement(node); 
     
                 //Create a tooltip if no tooltip exists for such element 
                 if (!tooltip) { 
                      
                     if (nodeElem.get_attributes().getAttribute("userdefined") == "yes") { 
                         tooltip = tooltipManager.createToolTip(node); 
                          
                         tooltip.set_value(nodeElem.get_attributes().getAttribute("NodeID")); 
                         tooltip.show(); 
                     } 
                 } 
             } 
         } 
    On the ToolTipManager AjaxUpdate event I'm trying to get the node from the treeview based on the attribute NodeID.But the treeview always shows just one node (root node) on the tree when it actually has 4 nodes totally.
     protected void RadToolTipmanager1_AjaxUpdate(object sender, ToolTipUpdateEventArgs e) 
            { 
                ColumnDetails details = (ColumnDetails)this.LoadControl("ColumnDetails.ascx"); 
                details.NodeID = e.Value; 
                RadTreeNode oNode = rtvAssignSelectedTree.Nodes[0].Nodes.FindNodeByAttribute("NodeID", e.Value); 
                details.rtvSelectedTree = rtvAssignSelectedTree
                details.rttNodeToolTip = RadToolTipManager2
                string Text = oNode.Text.Substring(0, oNode.Text.IndexOf('(')); 
                string Length = oNode.Text.Substring(oNode.Text.IndexOf(','), oNode.Text.IndexOf(')') - oNode.Text.IndexOf(',')); 
                ((TextBox)details.FindControl("txtColumnName")).Text = Text; 
                ((TextBox)details.FindControl("txtLength")).Text = Length
                e.UpdatePanel.ContentTemplateContainer.Controls.Add(details); 
            } 

    Can someone please help me figure what i'm doing wrong. oNode in the above event is always null, rtvAssignSelectedTree.Nodes[0].Nodes.Count is always 0.

    Thank you,
    Phani
  2. Svetlina Anati
    Admin
    Svetlina Anati avatar
    2795 posts

    Posted 08 Sep 2009 Link to this post

    Hello Phani,

    I am afraid that I could not completely understand the problem and your scenario. As far as I understand from your explanations, you have one root node for the treeview and 4 child nodes for this root node. However, in your client code you have the following line:

    if (nodeElem.get_level() != 0) 
    {
      //code for creating tooltip
    ..............

    }

    This means that a tooltip will b created only when a node which is not the root one is hovered. If so, you will get a child node and not the root node. If this is the problem and you want to get the root node instead, you should change your logic in the above explained event.

    If this is not what you meant, please provide more detailed explanations about the exact scenario and goal and I will do my best to help once I get a better understanding on the problem. 


    All the best,
    Svetlina
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Phani Alla
    Phani Alla avatar
    29 posts
    Member since:
    Jun 2009

    Posted 08 Sep 2009 Link to this post

    Hi Svetlina, Thank you for your reply. I'm sorry I couldn't explain my problem properly.
    I'm trying to access the treeview on RadToolTipmanager1_AjaxUpdate event in the code behind and I'm unable to see any nodes that have tool tips meaning when i say rtvSelectedTree.Nodes[0].Nodes the count is always zero in that event, it is supposed to be 3. Any way I could access the treeview in that event?

    Thank you,
    Phani
  5. Phani Alla
    Phani Alla avatar
    29 posts
    Member since:
    Jun 2009

    Posted 08 Sep 2009 Link to this post

    Hi, My problem is similar to the following post,

    In my case i cannot retrieve the treeview nodes. I'm creating the tooltip on OnClientMouseOver and I'm using RadToolTipManager1_AjaxUpdate (Please refer to my first post on this thread). Please help me, I'm unable to find my way out. 
    This is what I'm trying to do. I want the user to be able to modify the node name by entering a new node name in the textbox on the tooltip...By clicking on a button OK on the tool tip, the tooltip must be closed and the nodename updated.I tried to call a javascript function, that takes the text entered in the tooltip and updates the node in the treeview, but there too the treeview nodes are always null.

    Here is the code for the OK button
     protected void btnAddColumn_Click(object sender, EventArgs e) 
            { 
                rtvSelectedTree = (RadTreeView)Session["SelectedTree"]; 
                //RadTreeNode oNode =  rtvSelectedTree.Nodes[0].Nodes.FindNodeByAttribute("NodeID", NodeID); 
                //string sName = oNode.Text; 
                string sType = NodeName.Substring(NodeName.IndexOf('(') + 1, NodeName.IndexOf(',') - (NodeName.IndexOf('(') + 1)); 
                NodeName = txtColumnName.Text + "(" + sType + "," + txtLength.Text + ")"; 
                //oNode.Attributes.Add("attlength", txtLength.Text); 
                string strScript = string.Empty; 
                strScript += "UpdateNodeName('" + NodeID + "','" + NodeName + "','" + txtLength.Text + "');"; 
                ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "WebUserControlScript", "CloseActiveToolTip();" + strScript, true); 
            } 
     

    Here is the UpdateNodeName function
     function UpdateNodeName(nodeID, nodeName, attLength) { 
             debugger; 
           var SelectedTree=$find("<%=rtvAssignSelectedTree.ClientID%>"); 
           if (SelectedTree != null) { 
               var RootNode = SelectedTree.get_nodes().getNode(0); 
               if (RootNode != null) { 
                   var Node = FindNodeByNodeID(RootNode, nodeID); 
                   if (Node != null) { 
                       Node.set_text(nodeName); 
                       Node.get_attributes().setAttribute("attlength", attLength); 
                   } 
               } 
           } 
         } 
     

    Here RootNode is supposed to have several child nodes, but it always shows it has 0 nodes.
    Please let me know if I'm still not clear. 
    Thank you,
    Phani
  6. Phani Alla
    Phani Alla avatar
    29 posts
    Member since:
    Jun 2009

    Posted 08 Sep 2009 Link to this post

    Hi Svetlina,

    I have all this in a usercontrol and had multiple instances of teh user control on my page. I figured it was due to this, i moved the javascript functions into a separate js file and it worked fine. I have another issue though. No matter on what node I hover on, it shows me the same set of details, when I try to debug on the RadToolTipManager1_AjaxUpdate event i see the right values getting passed to the tool tip usercontrol but when it loads it still shows the previous tool tip's values. I would really appreciate if you could help me figure a solution for this. Thank you very much

    Phani
  7. Phani Alla
    Phani Alla avatar
    29 posts
    Member since:
    Jun 2009

    Posted 09 Sep 2009 Link to this post

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017