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

[Solved] Check only one node

1 Answer 123 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jaymie
Top achievements
Rank 1
Jaymie asked on 21 Dec 2011, 04:06 PM
I have this code:

function onChecked(e) {
    var treeView = $("#TreeView").data("tTreeView");
    var childNodes = $('#TreeView').find("li").find('> div > .t-checkbox :checkbox')
 
    childNodes.each(function (index, element) {
        treeView.nodeCheck(element, false);
    });
}

What it is supposed to do is to uncheck all items and just keep the one I selected (i.e. only have one node selected at any time.
It appears to work in IE, but in firefox it doesn't seem to fire (I have added an alert at the beginning of the function for testing and that is not getting hit).

Any help would be appreciated.

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 22 Dec 2011, 09:33 AM
Hi Jaymie,

Your fucntion works correctly on my side. Please check for JS errors.

However, the provided code can undergo a couple of improvements and optimization. For example, you can execute the handler only if the user is currently checking a checkbox (e.checked == true) and do nothing while unchecking. Also, you can iterate only through the checked checkboxes (:checked jQuery selector), not all of them.

Regards,
Dimo
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
Tags
TreeView
Asked by
Jaymie
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or