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

Select text, IE / Firefox

4 Answers 46 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Jan-Åge
Top achievements
Rank 1
Jan-Åge asked on 10 Jun 2009, 11:58 AM

In Opera (9.63)  the user can select (and copy) the nodes text. In Firefox 3.0.8 it seems that you cant select the text at all. And in IE 7.0 the user must (start) select from the left outside the node. We are using the RadTreeView in a forum and the users need to be able to copy text. Any solutions?

Regards

Jan

4 Answers, 1 is accepted

Sort by
0
Paul
Telerik team
answered on 11 Jun 2009, 08:54 AM
Hello Jan-Åge,

The text selection under Firefox is disabled intentionally as there are unwanted effects when you try to drag the nodes. Still, you can enable the text selection by using the following CSS style.

 <style type="text/css">  
    .RadTreeView .rtLI  
    {  
        -moz-user-select: text !important;  
    }  
    </style> 

Alternatively, you can use the following approach:

ASPX:
<form id="form1" runat="server">  
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">  
    </telerik:RadScriptManager> 
 
    <script type="text/javascript">  
        function OnClientNodeEditStart(sender, eventArgs) {  
            var node = eventArgs.get_node();  
            if (node.get_text() != "") {  
                eventArgs.get_node().get_inputElement().readOnly = true;  
            }  
        }  
    </script> 
 
    <telerik:RadTreeView ID="RadTreeView1" runat="server" AllowNodeEditing="true" OnClientNodeEditStart="OnClientNodeEditStart">  
        <NodeTemplate> 
            <%# Container.Text %> 
        </NodeTemplate> 
        <Nodes> 
            <telerik:RadTreeNode runat="server" Text="Root RadTreeNode1">  
                <Nodes> 
                    <telerik:RadTreeNode runat="server" Text="Child RadTreeNode 1">  
                    </telerik:RadTreeNode> 
                    <telerik:RadTreeNode runat="server" Text="Google">  
                    </telerik:RadTreeNode> 
                    <telerik:RadTreeNode runat="server" Text="Child RadTreeNode 3">  
                    </telerik:RadTreeNode> 
                </Nodes> 
            </telerik:RadTreeNode> 
        </Nodes> 
    </telerik:RadTreeView> 
    </form> 

Code-behind:
    protected void Page_Load(object sender, EventArgs e)  
    {  
        RadTreeView1.DataBind();  
    } 


Regards,
Paul
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Jan-Åge
Top achievements
Rank 1
answered on 15 Jun 2009, 09:28 AM
Thank you!
That worked just fine. But are there any possible solutions for Internet Explorer?

Regards

 

Jan

0
Paul
Telerik team
answered on 16 Jun 2009, 07:28 AM
Hi Jan-Åge,

The node's text selection works under IE (though in a bit different way) and there's nothing more we can do on the matter.

Kind regards,
Paul
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Sargis
Top achievements
Rank 1
answered on 09 Jun 2010, 10:15 AM
For the allowing IE to select text on the RadTreeView you can try the following JavaScript.

setTimeout(

'EnabelRadTreeViewTextSelection()', 100);

 

function

 

EnabelRadTreeViewTextSelection()

 

{

 

var RadTreeView1 = document.getElementById("<%=RadTreeView1.ClientID %>");

 

 

if (RadTreeView1 == null) setTimeout('EnabelRadTreeViewTextSelection()', 100);

 

 

var arrayElement = RadTreeView1.getElementsByTagName("span");

 

 

var arrayElement_A_tabs = RadTreeView1.getElementsByTagName("a");

 

replaceTreeNodeClassName(arrayElement);

replaceTreeNodeClassName(arrayElement_A_tabs);

}

function

 

replaceTreeNodeClassName(arrayElement)

 

{

 

if (arrayElement == null) return;

 

 

for (var i=0; i<arrayElement.length; i++)

 

{

 

if (arrayElement[i].className == "rtIn")

 

{

arrayElement[i].className =

"";

 

}

}

}

Tags
TreeView
Asked by
Jan-Åge
Top achievements
Rank 1
Answers by
Paul
Telerik team
Jan-Åge
Top achievements
Rank 1
Sargis
Top achievements
Rank 1
Share this question
or