Treeview checkboxes with FormDecorator

2 posts, 1 answers
  1. Phani Alla
    Phani Alla avatar
    29 posts
    Member since:
    Jun 2009

    Posted 10 Jul 2009 Link to this post

    Hello, I have a treeview with OnClientNodeChecked event, I'm unable to check or uncheck the checkboxes in the tree. I have another tree which does not have an OnClientNodeChecked event, the checkboxes on this work fine, i'm able to check or uncheck.
    Here is my OnClientNodeChecked event. each time I click on the checkbox the event is fired and it does return checked nodes, but i can't see them checked or unchecked on the UI. any help please?
    function clientNodeChecked(sender, eventArgs) { 
        var node = eventArgs.get_node(); 
        var tree = node.get_treeView(); 
        var checkedNodes = tree.get_checkedNodes(); 
        var radioNodes; 
        for (var i = 0; i < checkedNodes.length; i++) { 
            if (checkedNodes[i] != node) { 
                if (checkedNodes[i].get_parent() == node.get_parent()) { 
                 if(checkedNodes[i].get_parent().get_attributes().getAttribute("radio")=="yes") 
                    oldNode = checkedNodes[i]; 
                } 
            } 
        } 
        if (oldNode != null) { 
            if (oldNode.get_parent() == node.get_parent()) { 
                oldNode.set_checked(false); 
                oldNode.set_expanded(false); 
            } 
            } 
            node.set_checked(true); 
            node.set_expanded(true); 
            oldNode = node
        } 

    thank you,
    Phani
  2. Answer
    Yana
    Admin
    Yana avatar
    4985 posts

    Posted 13 Jul 2009 Link to this post

    Hi Phani,

    Please remove node node.set_checked(true); line as this node is already checked and it will work:

    function clientNodeChecked(sender, eventArgs) {
    var node = eventArgs.get_node();
    var tree = node.get_treeView();
    var checkedNodes = tree.get_checkedNodes();
    var radioNodes;
    for (var i = 0; i < checkedNodes.length; i++) {
    if (checkedNodes[i] != node) {
    if (checkedNodes[i].get_parent() == node.get_parent()) {
    if(checkedNodes[i].get_parent().get_attributes().getAttribute("radio")=="yes")
    oldNode = checkedNodes[i];
    }
    }
    }
    if (oldNode != null) {
    if (oldNode.get_parent() == node.get_parent()) {
    oldNode.set_checked(false);
    oldNode.set_expanded(false);
    }
    }
    // node.set_checked(true);
    node.set_expanded(true);
    oldNode = node;
    }


    Best regards,
    Yana
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top