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

Treeview checkboxes with FormDecorator

1 Answer 39 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Phani Alla
Top achievements
Rank 1
Phani Alla asked on 10 Jul 2009, 06:37 PM
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

1 Answer, 1 is accepted

Sort by
0
Accepted
Yana
Telerik team
answered on 13 Jul 2009, 02:32 PM
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.
Tags
TreeView
Asked by
Phani Alla
Top achievements
Rank 1
Answers by
Yana
Telerik team
Share this question
or