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

Checkboxes in Hierarchial data Treeview

4 Answers 107 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
shahab
Top achievements
Rank 1
shahab asked on 20 Sep 2008, 01:36 PM
Hi could anyone please point me into the correct direction of how I can display the checkboxes for only the child nodes in the tree view.I am using exactly the same sample of the hierarchial data as of telerik demos but when I set the checkboxes = true it renders checkboxes in the parent node as well. any suggestions would be greatly appreciated.
thanks

4 Answers, 1 is accepted

Sort by
0
-DJ-
Top achievements
Rank 1
answered on 20 Sep 2008, 02:48 PM
Hi Shahab,

This should work:

Sub nodeCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadTreeNodeEventArgs) Handles treeview1.NodeCreated

    
If e.Node.Level = 0 Then
        
e.Node.Checkable = False
    
End If

End Sub


Regards,
-DJ-

0
shahab
Top achievements
Rank 1
answered on 21 Sep 2008, 12:08 AM
Thank you so much and it seems to have done the trick, but the checkboxes appear below each node's text for some reason. I would prefer the checkboxe appear adjacent to the text of the node on the left. here is the code below for databing the treeview:



 private void LoadWorkoutTreeView()  
    {  
        WorkoutCollection wo = new WorkoutCollection();  
        DataTable dt = new DataTable();  
        dt = wo.CustomLoad(2,Convert.ToDateTime(dpFrom.SelectedDate),Convert.ToDateTime(dpTill.SelectedDate));  
          
        tvwUserWorkout.DataTextField = "Title";  
        tvwUserWorkout.DataFieldID = "CategoryID";  
        tvwUserWorkout.DataFieldParentID = "ParentId";  
          
        tvwUserWorkout.DataSource = dt;  
        tvwUserWorkout.DataBind();  
          
          
    }  
      
    public void nodeCreated(object sender,Telerik.Web.UI.RadTreeNodeEventArgs e)   
    {  
        if (e.Node.Level == 0)  
        {  
            e.Node.Checkable = false;  
        }  
    } 


0
Accepted
-DJ-
Top achievements
Rank 1
answered on 21 Sep 2008, 12:57 PM
Hi Shahab,

I don't think that problem is related to the databinding, it's likely something in the treeview declaration itself or the skin css.

  1. Did you state a specific width for the treeview, or add some declaration to it's style element?
  2. Are you using a custom skin, if so go through the skin css and see if you can find the explanation there, if not, what skin are you using?

Regards,
-DJ-
0
shahab
Top achievements
Rank 1
answered on 21 Sep 2008, 11:51 PM
Thank DJ for your time and effort. Yes you were correct the issue was CSS related as I did't realise the div had a fixed width.
Thank you again.
Tags
TreeView
Asked by
shahab
Top achievements
Rank 1
Answers by
-DJ-
Top achievements
Rank 1
shahab
Top achievements
Rank 1
Share this question
or