view check box just in leaf

5 posts, 1 answers
  1. Mojtaba
    Mojtaba avatar
    32 posts
    Member since:
    Feb 2009

    Posted 08 Sep 2009 Link to this post

    Is there any way to view rad tree nodes just in leaves?
    I wrote this code but all nodes was checkbox.
    <telerik:RadTreeView ID="RadTreeView1" runat="server" CheckBoxes="True"/> 

  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 08 Sep 2009 Link to this post

    Hello,

    I tried following client side code in order to achieve required scenario. Give a try with this:

    ASPX:
     
    <telerik:RadTreeView ID="RadTreeView1" OnClientLoad="OnClientLoad" runat="server" CheckBoxes="True" CheckChildNodes="True">  
      . . .  
    </telerik:RadTreeView> 

    JavaScript:
     
    <script type="text/javascript">  
    function OnClientLoad(sender, args)  
    {  
        var allNodes = sender.get_allNodes();  
        for(var i =0; i< sender.get_allNodes().length ; i ++)  
        {  
            if(allNodes[i].get_nodes().get_count() != 0)  
            {  
                allNodes[i].get_checkBoxElement().style.display = "none";  
            }  
        }  
    }  
    </script> 

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mojtaba
    Mojtaba avatar
    32 posts
    Member since:
    Feb 2009

    Posted 09 Sep 2009 Link to this post

    Hi Princy,
    thank you for answer.
  5. Mahdi
    Mahdi avatar
    30 posts
    Member since:
    Oct 2006

    Posted 10 Sep 2009 Link to this post

    I have same problem but your script doesn't solve it.
    I guess this is because my treeview is ondemand.
    <script type="text/javascript"
    function TreeOnClientLoad(sender, args) { 
            var allNodes = sender.get_allNodes(); 
            debugger; 
            for (var i = 0; i < sender.get_allNodes().length; i++) { 
                if (allNodes[i].get_nodes().get_count() != 0) { 
                    allNodes[i].get_checkBoxElement().style.display = "none"
                } 
            } 
        }   
    </script> 
     
    <telerik:RadTreeView runat="server" ID="rtvClasses" OnClientLoad='TreeOnClientLoad' 
                            dir="rtl"
                        </telerik:RadTreeView> 
    and the code behind is:
    protected void Page_Load(object sender, EventArgs e) 
        { 
            if (!IsPostBack) 
            { 
                rtvClasses.Nodes.Clear(); 
                RadTreeNode node = new RadTreeNode(); 
                node.Text = TreeFirstElementName; 
                node.Value = "0"
                node.ExpandMode = TreeNodeExpandMode.ServerSideCallBack; 
                rtvClasses.Nodes.Add(node); 
                rtvClasses.CheckBoxes = TreeCheckable; 
                rtvClasses.CheckChildNodes = TreeCheckable; 
            } 
        } 
    void rtvClasses_NodeExpand(object sender, RadTreeNodeEventArgs e) 
        { 
            ClassManagerClient service = new ClassManagerClient(); 
            RadTreeNodeData[] list = service.GetClassesByParentIdAndType(Convert.ToInt64(e.Node.Value), ClassType.Project); 
            service.Close(); 
            e.Node.Nodes.Clear(); 
            e.Node.Nodes.AddRange(PublicFunctions.GetRadTreeNodes(list.ToList())); 
            e.Node.Expanded = true
        } 
     
    Thanks in advance
  6. Mahdi
    Mahdi avatar
    30 posts
    Member since:
    Oct 2006

    Posted 17 Sep 2009 Link to this post

    No Answer!?
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017