How to apply CSS [cursor="hand"] to last nodes using Javascript

2 posts, 0 answers
  1. parimal
    parimal avatar
    138 posts
    Member since:
    Feb 2007

    Posted 24 Nov 2008 Link to this post

    Hi,

    I have dynamically generated treeview and i wish to apply defined css class to last node of each parent node using js on 

    OnClientNodeExpanded event.

     

    <

     

    script language="javascript" type="text/javascript">

     

     

     

     

     

     

    function ApplyCSS(sender, eventArgs)

     

    {

     

    ////var treeView = $find("<%=tvCategories.ClientID%>");

     

     

     

     

     

     

    //var selectedNode = treeView.get_selectedNode();

     

     

     

     

     

     

    var node =eventArgs.get_node();

     

    alert(node.get_nodes().get_count());

     

    if(node.get_nodes().get_count()>0)

     

    {

     

    for(var i = 0; i < node.get_nodes().get_count(); i++){

     

     

    //WHAT SHOULD BE THE CODE HERE?
     i tried but gives error.

     

    node.get_nodes().getNode(i).style.cursor = 'hand'; ;

    }

    }

     

    }

    regards,
    Parimal

  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 25 Nov 2008 Link to this post

    Hi parimal,

    The error occurs because the client-side object representing a tree node does not have a "style" property. Only DOM elements have it. You can try this instead:

    node.get_nodes().getNode(i).get_element().style.cursor = 'pointer'; ;

    Also you should use cursor="pointer" for cross browser reasons.

    Regards,
    Albert
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top