[CLOSED] Treenode link and select

  1. #1

    [CLOSED] Treenode link and select

    Goodevening,

    I have two questions:

    1) How to disable hiperlink in the text of a single node?
    2) How to use the hiperlink when I select the node but not click on the text?

    Thankyou

    Jimmy
    Last edited by Daniil; Jan 17, 2011 at 10:16 AM. Reason: [CLOSED]
  2. #2
    Quote Originally Posted by xeo4.it View Post
    1) How to disable hiperlink in the text of a single node?
    Hi,

    I was able to disable it via the following code:
    TreePanel1.getNodeById("Node1").ui.getAnchor().onclick = function () {return false;}
    Quote Originally Posted by xeo4.it View Post
    2) How to use the hiperlink when I select the node but not click on the text?
    Well, I don't know a way to simulate click on <a href='link'>, so I would suggest you to use open() method.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:TreePanel 
            ID="TreePanel1" 
            runat="server" 
            AutoHeight="true" 
            RootVisible="false">
            <Root>
                <ext:TreeNode Text="Root" Expanded="true">
                    <Nodes>
                        <ext:TreeNode Text="google.com" Href="http://google.com" HrefTarget="_blank" />
                        <ext:TreeNode Text="ext.net" Href="http://ext.net" HrefTarget="_blank" />
                    </Nodes>
                </ext:TreeNode>
            </Root>
            <SelectionModel>
                <ext:DefaultSelectionModel runat="server">
                    <Listeners>
                        <BeforeSelect Handler="open(newNode.attributes.href, newNode.attributes.hrefTarget);" />
                    </Listeners>
                </ext:DefaultSelectionModel>
            </SelectionModel>
        </ext:TreePanel>
        </form>
    </body>
    </html>
  3. #3
    Goodmorning,
    sorry for if I have answered so late but in this period I have been very busy.
    With your suggestions I have resolved the second problem.
    The first point I need to disable hiperlink via codebind, and I need to hide underline of hiperlink: I have tried to use the Cls treeNode property to set "text-decoration: none;" but doesn't work.
    Please help me.
    Thank you for your time.

    Jimmy
  4. #4
    Quote Originally Posted by xeo4.it View Post
    The first point I need to disable hiperlink via codebind, and I need to hide underline of hiperlink: I have tried to use the Cls treeNode property to set "text-decoration: none;" but doesn't work.
    Hi,

    I think there is no way to turn off hyperlink via css.

    Well, in code behind my solution can look like this:

    ResourceManager.GetInstance().AddScript("TreePanel1.getNodeById('Node1').ui.getAnchor().onclick = function () {return false;}");
    or

    //on client side
    var disableHref = function (nodeId) {
        TreePanel1.getNodeById(nodeId).ui.getAnchor().onclick = function () {return false;}
    }
    
    //in code behind
    X.JS.Call("disableHref", "nodeId");
    Last edited by Daniil; Jan 14, 2011 at 11:40 AM.
  5. #5
    Hi Danil,
    I have applied your second example and it work, but It is the same to write:
    newNode.Href = "#";
    I need to disable the underline of the text of the treeNode, I don't want the Hiperlink for some nodes.

    Thanks

    Jimmy
    Last edited by Daniil; Jan 14, 2011 at 10:57 PM. Reason: Removed <font> tags
  6. #6
    Quote Originally Posted by xeo4.it View Post
    Hi Danil,
    I have applied your second example and it work, but It is the same to write:
    newNode.Href = "#";
    Hi Jimmy,

    Yes, you are right, during creation of new node your way is fine.


    Quote Originally Posted by xeo4.it View Post
    need to disable the underline of the text of the treeNode, I don't want the Hiperlink for some nodes.
    Hmm... Could you give some prompt how can I get underlined text in node?

    When I used the following code there is no underlined text:
    <ext:TreeNode Text="ext.net" Href="http://ext.net" HrefTarget="_blank" />
  7. #7
    Hi Daniil,
    all perfect.

    Thank you very much

    Jimmy

Similar Threads

  1. [CLOSED] [1.0] How to select a treenode in codebehind?
    By klaus.schwarz in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Nov 01, 2010, 3:00 PM
  2. Replies: 1
    Last Post: May 04, 2010, 9:54 AM
  3. Replies: 0
    Last Post: Dec 10, 2009, 11:14 AM
  4. How to select TreeNode with Up/Down keys?
    By dbassett74 in forum 1.x Help
    Replies: 0
    Last Post: May 26, 2009, 7:23 PM
  5. [CLOSED] Select TreeNode Programatically
    By Ben in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Feb 04, 2009, 9:45 AM

Posting Permissions