This is a migrated thread and some comments may be shown as answers.

Tree Elements -- Bookmarks and Links

4 Answers 86 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
SorinC
Top achievements
Rank 1
SorinC asked on 18 Nov 2010, 06:58 PM
Hello All,

I searched the forum but could not find the answers to the following questions...

1.
LoadXMLString is used to load the treeView controls discussed below.
On a web page with three treeView controls, some elements (branch or leaf) have a link and a ToolTip.
When I right-click the element and create a bookmark, the name of the bookmark is using the text in the ToolTip rather than the label on the element, e.g. if the label's Text attribute in XML is ABC and the Tooltip is 123, the bookmark created will have 123 as the name instead of ABC.

Is there a way to configure the tree to use the Text instead of the Tooltip?

2.
Here is a sample of the XML used to load one of the trees:
<Node H="10.00.00.00" NavigateUrl="~/Default.aspx?ID=10.00.00.00" 
Target="_blank" Text="Energy (551)" Image="./Images/2_1.gif" 
Tooltip="Energy">
<Node H="10.10.00.00" Text="Energy">

As you may notice, the second node does not have a NavigateUrl tag, yet it still shows as a link in the tree i.e. when I hover the mouse over the label, the pointer changes to a hand and the text becomes underlined. Of course, when clicking on it, nothing happens.

Is there a way of preventing elements from showing as a hyperlink when NavigateUrl is null?

Thank you.
Sorin

4 Answers, 1 is accepted

Sort by
0
SorinC
Top achievements
Rank 1
answered on 22 Nov 2010, 04:44 PM
Hello,

Could someone from the Telerik team please respond to my two questions? It's just a simple matter of "Yes, it's possible, here is how" or "No, that cannot be done" that should not take more than a few minutes..

Thank you.
0
Peter
Telerik team
answered on 24 Nov 2010, 09:06 AM
Hello SorinC,

1. This is the default browser behavior. You can test it with a simple link element (<a />) that has its title attribute specified. You should get the same behavior.

2. I couldn't not replicate this behavior, but anyway, you can consistently achieve it like this:

protected void RadTreeView1_NodeCreated(object sender, RadTreeNodeEventArgs e)
        {
            if (e.Node.NavigateUrl == String.Empty)
            {
                e.Node.CssClass = "CustomCss";              
            }
        }


.CustomCss:hover
   {
       text-decoration:none !important;
       cursor:default !important;
   }


Kind regards,
Peter
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
SorinC
Top achievements
Rank 1
answered on 25 Nov 2010, 04:56 PM
Hi Peter,

Thank you for your reply.
While I can confirm the first item (standard browser behaviour), the second one is still under debate

Here's what my code looks like:
protected void RadTreeView1_NodeCreated(object o, Telerik.WebControls.RadTreeNodeEventArgs e)
{
    if (string.IsNullOrEmpty(e.NodeCreated.NavigateUrl))
    {
        e.NodeCreated.CssClass = "CustomCss";
    }
}

Issues:
a. My RadTreeNodeEventArgs seems to have an object model a bit different than yours. There is no .Node object, only a .NodeCreated -- do we use different versions of the control? I have 6.3.8.0.

b. It does not seem to work, After creating the event, I put a bookmark on the CssClass assignment to make sure it assigns CustomCss when NavigateUrl is empty. However, there is nothing in the generated code for the tree items on the page and I still get a hand cursor on items that do not have a link underneath.

Here is the relevant generated code, starting with the style declaration:
<head id="ctl00_hdrPage">
    <link rel="stylesheet" type="text/css" href="App_Themes/MyTheme/StyleSheet.css" />
    <style type="text/css">
        .CustomCss:hover
        {
           text-decoration:none !important;
           cursor:default !important;
        }
    </style>
...
</head>

JavaScript
<script type="text/javascript">
// First node 'Energy (551)' should have a link, while the second one 'Energy' should not CustomCss is nowhere to be found
    window["ctl00_ContentPlaceHolder1_WebPartManager1_gwpRadTreeView1_RadTreeView1ClientData"] = [
    ['ctl00_ContentPlaceHolder1_WebPartManager1_gwpRadTreeView1_RadTreeView1_t0','Energy (551)','','',11,10,13,0,0,0,1,0,'','','',true,0,0,1,1,0,'','',0,'t0',0,1,{H:'10.00.00.00'}],
    ['ctl00_ContentPlaceHolder1_WebPartManager1_gwpRadTreeView1_RadTreeView1_t0_t0','Energy','','',2,1,0,0,0,0,1,0,'','','',true,0,1,1,1,0,'','',1,'t0',0,1,{H:'10.10.00.00'}],
...
</script>

<div id="ctl00_ContentPlaceHolder1_WebPartManager1_gwpRadTreeView1_RadTreeView1_t0">
    <img src="javascript:false" id="ctl00_ContentPlaceHolder1_WebPartManager1_gwpRadTreeView1_RadTreeView1_t0c" alt="" style="display: none; cursor: pointer;" class="11" />
    <img src="javascript:false" id="ctl00_ContentPlaceHolder1_WebPartManager1_gwpRadTreeView1_RadTreeView1_t0i" alt="" style="display: none;" class="13" />
    <a href="/MyFolder/Default.aspx?ID=10.00.00.00" target="_blank" class="TreeNode" title="Energy">
        <span class="TreeNode" title="Energy">Energy (551)</span>
    </a>
</div>
<div id="ctl00_ContentPlaceHolder1_WebPartManager1_gwpRadTreeView1_RadTreeView1_t0_t0">
    <img src="javascript:false" alt="" style="display: none;" class="4" />
    <img src="javascript:false" id="ctl00_ContentPlaceHolder1_WebPartManager1_gwpRadTreeView1_RadTreeView1_t0_t0c" alt="" style="display: none; cursor: pointer;" class="2" />
    <span class="TreeNode">Energy</span>
</div>

The generated code is correct, i.e. the second node (Energy) is not a hyperlink (<a></a>). However, as mentioned above, it shows like one on the page (wish I could post a screenshot). Could it be due to the TreeNode class? What am I missing?

Thanks.
0
Peter
Telerik team
answered on 01 Dec 2010, 11:05 AM
Hello SorinC,

You are using the classic RadTreeView. I recommend you upgrade to RadTreeView for ASP.NET AJAX, but if this is not an option then you can try the following code:

protected void RadTreeView1_DataBound(object sender, EventArgs e)
   {
       foreach (RadTreeNode node in RadTreeView1.GetAllNodes())
       {
           if (string.IsNullOrEmpty(node.NavigateUrl))
           {
               node.CssClassOver = "CustomCss";
           }
       }
   }

.CustomCss
  {
      text-decoration:none !important;
      cursor:default !important;
      font-size: 12px !important;
        
  }

Note that  you might also need to set the font-family and other attributes for CustomCss depending on your skin.


Regards,
Peter
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
TreeView
Asked by
SorinC
Top achievements
Rank 1
Answers by
SorinC
Top achievements
Rank 1
Peter
Telerik team
Share this question
or