Checkboxes in Hierarchial data Treeview

5 posts, 1 answers
  1. shahab
    shahab avatar
    22 posts
    Member since:
    Oct 2012

    Posted 20 Sep 2008 Link to this post

    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
  2. -DJ-
    -DJ- avatar
    263 posts
    Member since:
    Oct 2004

    Posted 20 Sep 2008 Link to this post

    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-

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. shahab
    shahab avatar
    22 posts
    Member since:
    Oct 2012

    Posted 20 Sep 2008 Link to this post

    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:



    1  private void LoadWorkoutTreeView()  
    2     {  
    3         WorkoutCollection wo = new WorkoutCollection();  
    4         DataTable dt = new DataTable();  
    5         dt = wo.CustomLoad(2,Convert.ToDateTime(dpFrom.SelectedDate),Convert.ToDateTime(dpTill.SelectedDate));  
    6           
    7         tvwUserWorkout.DataTextField = "Title";  
    8         tvwUserWorkout.DataFieldID = "CategoryID";  
    9         tvwUserWorkout.DataFieldParentID = "ParentId";  
    10           
    11         tvwUserWorkout.DataSource = dt;  
    12         tvwUserWorkout.DataBind();  
    13           
    14           
    15     }  
    16       
    17     public void nodeCreated(object sender,Telerik.Web.UI.RadTreeNodeEventArgs e)   
    18     {  
    19         if (e.Node.Level == 0)  
    20         {  
    21             e.Node.Checkable = false;  
    22         }  
    23     } 


  5. Answer
    -DJ-
    -DJ- avatar
    263 posts
    Member since:
    Oct 2004

    Posted 21 Sep 2008 Link to this post

    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-
  6. shahab
    shahab avatar
    22 posts
    Member since:
    Oct 2012

    Posted 21 Sep 2008 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017