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

How to remove the '+' sign for the last level.

4 Answers 54 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
xyz
Top achievements
Rank 1
xyz asked on 08 Oct 2008, 04:00 PM
Hello,
I am using the Treeview and i am going to have only three levels in that tree view.

+Level 1
    + Level 2
         Level 3

This is how my TreeView should look.  For 'Level 3' there will not be any children and its going to be a HyperLink. 

Please Note:  Level 2 will have more than 1 nodes i.e., it will have 'Level 3a',''Level 3b' and so on.  All the levels are query based.

How should i not show a '+' sign for the Level 3?

Please let me know,
-Thank you
Tyra

4 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 08 Oct 2008, 04:03 PM
Hello xyz,

If you are using LoadOnDemand you should set the ExpandMode property to ClientSide for nodes which should not have children. This technique is demonstrated in this online demo (expand to the fourth level).

Regards,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
xyz
Top achievements
Rank 1
answered on 09 Oct 2008, 03:14 PM
Hello Albert,

Here's my code for the aspx and code-behind.

aspx:
-----

 

<telerik:RadTreeView id="RadTreeView1" runat="server" height="300px" width="300px"onnodeexpand="RadTreeView1_NodeExpand" />


code-behind:
----------------

 

 

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

 

 

If Not Page.IsPostBack Then

 

 

 

LoadRootNodes()

 

End If

 

 

 

 

End Sub

--------------------------------------

 

Private

Sub LoadRootNodes()

 

Dim

oradb As String = "Data Source=(DESCRIPTION=(ADDRESS_LIST=" _

 

+

"(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=)))" _

 

+

"(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=)));" _

 

+

"User Id=;Password=;"

 

 

 

 

Dim conn As New OracleConnection(oradb)

 

conn.Open()

 

Dim sql As New OracleCommand("some select statement,conn)

 

 

 

 

Dim adapter As New OracleDataAdapter(sql)

 

 

Dim data As New DataTable()

 

adapter.Fill(data)

 

For Each row As DataRow In data.Rows

 

 

Dim node As New RadTreeNode()

 

node.Text = row(

"GROUP_DESC")

 

node.Value = row(

"GROUP_ID")

 

node.ExpandMode = TreeNodeExpandMode.ServerSideCallBack

RadTreeView1.Nodes.Add(node)

 

Next

 

 

 

conn.Close()

conn.Dispose()

 

End Sub


------------------------------------

 

 

Protected Sub RadTreeView1_NodeExpand(ByVal sender As Object, ByVal e As RadTreeNodeEventArgs) Handles RadTreeView1.NodeExpand

 

Dim

oradb As String = "Data Source=(DESCRIPTION=(ADDRESS_LIST=" _

 

+

"(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=)))" _

 

+

"(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=)));" _

 

+

"User Id=;Password=;"

 

 

 

 

Dim conn As New OracleConnection(oradb)

 

conn.Open()

 

Dim

sql As New OracleCommand("SELECT rug.user_group_id, rug.user_group_desc, rh.code_hotel FROM rpt_user_groups rug, rpt_user_group_xref rugx, rpt_hotels rh WHERE rugx.rpt_user_group_parent_id in :ParentId AND rugx.rpt_user_group_child_id = rug.user_group_id AND rug.user_group_id = rh.user_group_id(+) ORDER BY rug.user_group_desc,rug.user_group_id", conn) ' VB.NET

 

 

 

 

sql.Parameters.Add(

":ParentId", e.Node.Value)

 

 

Dim adapter As New OracleDataAdapter(sql)

 

Dim

data As New DataTable()

 

adapter.Fill(data)

 

Dim cnt As Integer

 

 

 

cnt = data.Rows.Count

 

For Each row As DataRow In data.Rows

 

 

Dim node As New RadTreeNode()

 

node.Text = row(

"GROUP_DESC")

 

node.Value = row(

"GROUP_ID")

 

If

cnt > 0 Then

 

 

 

node.ExpandMode = TreeNodeExpandMode.ServerSideCallBack

 

End If

 

 

 

e.Node.Nodes.Add(node)

 

Next

 

 

 

e.Node.Expanded =

True

 

 

 

 

End Sub



------------------------------------------------------------------------------------------------------

I have tried 

 

node.ExpandMode = TreeNodeExpandMode.ClienSide in LoadRootNodes() and 

 

RadTreeView1_NodeExpand event handler.  That did not help.

Could you please check and let me know where i need to set the property?

Thank you,
xyz

0
Manoj
Top achievements
Rank 1
answered on 17 Dec 2008, 12:34 PM
Hi Albert,
    I followed the same procedure but still the '+' is there .

With Thanks & Regards
Manoj
0
Shinu
Top achievements
Rank 2
answered on 18 Dec 2008, 08:36 AM
Hi Manoj,

Give a try with the following client side code.

JS:
var tree = $find("<%= RadTreeView1.ClientID %>");  
var nodeCount=tree.get_nodes().get_count();  
   for (var i=0; i<tree.get_nodes().get_count();i++)     
   {           
       var node = tree.get_nodes().getNode(i);         
       if(node.get_index()==nodeCount-1)  
       {  
         var toggleElement = node.get_toggleElement();  
          if (toggleElement)  
          toggleElement.style.display = "none";  
       }  
   }  


Shinu
Tags
TreeView
Asked by
xyz
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
xyz
Top achievements
Rank 1
Manoj
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or