Implementing CSS class for the last child node in the treeview control

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

    Posted 24 Nov 2008 Link to this post

    Hi,

    We are dynamically generating RAD Treeview control with data. We need to have a hover=hand and other stylesheets effect on the last node of all the parent nodes. Any code to traverse through all nodes and applying CSS will be helpful.

    Node1-->NO style sheet
        Node2-->NO style sheet
            Node3-->Need to apply style sheet
            Node4-->Need to apply style sheet

    Node11-->NO style sheet
        Node22-->Need to apply style sheet

    +Node22
    +Node44

     

    regards,

     

    Parimal

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 25 Nov 2008 Link to this post

    Hi Parimal,

    One suggestion would be to set the Value Property of the last tree node to some custom text and in the PreRender event of RadTreeView loop through all tree nodes and set CssClass to the Treenode with desired Value .

    CS:
    protected void RadTreeView1_PreRender(object sender, EventArgs e) 
        { 
            foreach (RadTreeNode node in RadTreeView1.GetAllNodes()) 
            { 
                if (node.Value== "Last") 
                { 
                    node.CssClass = "MyClass"
                } 
            } 
        } 

    css:
    <head runat="server"
        <title>Untitled Page</title> 
        <style type="text/css"
          .MyClass 
          { 
            cursor:crosshair; 
            background-color: Red ; 
            
          } 
        </style> 
    </head> 


    Regards
    Shinu.
  3. parimal
    parimal avatar
    138 posts
    Member since:
    Feb 2007

    Posted 25 Nov 2008 Link to this post

    Hi,

    Thanks for the response. But due to application design and requirement, can't set any custom value to tree node.

    Please let me know if there is any other suggestions?

    regards,

    Parimal
  4. Yana
    Admin
    Yana avatar
    4831 posts

    Posted 27 Nov 2008 Link to this post

    Hi Parimal,

    As I understood, you need to apply style to the leaf nodes of the tree, those that have no children, is that the case?

    Best wishes,
    Yana
    the Telerik team

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