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

How to select tree item inside a RadComboBox

2 Answers 52 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Vicenc Masanas
Top achievements
Rank 1
Vicenc Masanas asked on 06 May 2011, 01:05 PM
I have a treeview inside a RadComboBox. I can set the selected node by using this code:
tree.SelectedNodes.Clear();
 
RadTreeNode node = tree.FindNodeByValue(idtema.ToString());
if (node != null)
{
    node.Selected = true;
}

And it works fine. The only problem is that the combo does not display the selected node.
If I expand the combo I see it has the correct node selected, but I want it to be shown on the top, when the combo is closed.
How can this be done?

Thank you.

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 06 May 2011, 01:25 PM
Hello Vicenc,

Try the following approach in the OnClientLoad event

Javascript:
<script type="text/javascript">
    function ClientLoad(sender)
     {
        var comboBox = sender;
        var tree = comboBox.get_items().getItem(0).findControl("RadTreeView1");
        var node = tree.findNodeByText("MyText");
        node.set_selected(true);
        var selectedNode = tree.get_selectedNode();
        if (selectedNode)
        {
            comboBox.set_text(selectedNode.get_text());
        }
    }
</script>

Hope it helps.

Thanks,
Princy.
0
Vicenc Masanas
Top achievements
Rank 1
answered on 06 May 2011, 02:00 PM
Great that was exactly what I needed. Thank you.
Tags
ComboBox
Asked by
Vicenc Masanas
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Vicenc Masanas
Top achievements
Rank 1
Share this question
or