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

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

4 Answers 584 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
parimal
Top achievements
Rank 1
parimal asked on 25 Nov 2008, 02:21 AM

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

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 25 Nov 2008, 07:43 AM
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.
0
parimal
Top achievements
Rank 1
answered on 25 Nov 2008, 08:17 AM
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
0
Yana
Telerik team
answered on 27 Nov 2008, 11:45 AM
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.
0
Bohdan
Top achievements
Rank 1
answered on 04 Feb 2021, 07:09 AM
Here's example of solution with Angular

  <kendo-treeview [nodes]="nodes" textField="name"
    childrenField="children" [(expandedKeys)]="expandedKeys">
    <ng-template kendoTreeViewNodeTemplate let-dataItem>


      <span *ngIf="dataItem.children.length === 0">Round circle</span>



      {{ dataItem.name }}
    </ng-template>
  </kendo-treeview>

Check for data item that has not children
Tags
TreeView
Asked by
parimal
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
parimal
Top achievements
Rank 1
Yana
Telerik team
Bohdan
Top achievements
Rank 1
Share this question
or