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

[Solved] Determine if there is a node selected in the TreeView with Javascript

1 Answer 225 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Greg Smith
Top achievements
Rank 1
Greg Smith asked on 09 Feb 2010, 08:05 PM
Is there a way to either get the count or search the TreeView recursively using Javascript to know if there is one or more selected nodes?

I have a multi-select TreeView and I need to disable a button when no nodes are selected.


Thanks
Greg

1 Answer, 1 is accepted

Sort by
0
Greg Smith
Top achievements
Rank 1
answered on 09 Feb 2010, 08:31 PM
I always feel like a schmuck when I solve my own problems :s

<script type="text/javascript"
 
    // Are there selected items in the TreeView? 
    function ItemsSelectedInTree() 
    { 
        var tree = $find("<%= RadTreeView1.ClientID %>"); 
        var selectedNode = tree.get_selectedNode(); 
 
        if (selectedNode != null) 
        { 
            // there is one or more selected nodes 
            return true; 
        } 
 
        return false; 
    } 
</script>  

Tags
TreeView
Asked by
Greg Smith
Top achievements
Rank 1
Answers by
Greg Smith
Top achievements
Rank 1
Share this question
or