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

[Solved] Selecting an item in Treeview inside a Combobox

1 Answer 117 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 12 Feb 2010, 03:05 PM
I have a hierarchial TreeView inside a combo box. The basic functionality is fine except for the following scenario:
When the edit page is loaded we already know the value of a treeNode. When I click on the drop down button on the combobox,
as it is now, the treeview is displayed with all nodes closed.
I would like the tree view to expand to the proper level with the selected node highlighted. I tried doing this:
       _onClientDropDownOpening: function(sender, e)
        {            
            var selectedNode = this._ObjectiveTypeTreeView.get_selectedNode();
            if (selectedNode != null)
            {
                selectedNode.scrollIntoView();
            }
        },
but it doesn't work. I would appreciate any pointers.
Thanks!


1 Answer, 1 is accepted

Sort by
0
Veronica
Telerik team
answered on 16 Feb 2010, 05:07 PM
Hi Andrew,

Thanks for the question.

From your code snippet I suppose you are using the OnClientDropDownOpening event. If you take a look at this demo you may see that a similar function is used but in OnClientDropDownOpened event.

<telerik:RadComboBox ID="RadComboBox1" runat="server" Style="vertical-align: middle;"
            OnClientDropDownOpened="OnClientDropDownOpenedHandler" EmptyMessage="Choose a destination"
            ExpandAnimation-Type="None" CollapseAnimation-Type="None">

function OnClientDropDownOpenedHandler(sender, eventArgs) {
    var tree = sender.get_items().getItem(0).findControl("RadTreeView1");
    var selectedNode = tree.get_selectedNode();
    if (selectedNode) {
        selectedNode.scrollIntoView();
    }
}

I've made an example similar to the demo above.  You can find it in the attached .zip file.

Please let me know if this was helpful.

Greetings,
Veronica Milcheva
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
ComboBox
Asked by
Andrew
Top achievements
Rank 1
Answers by
Veronica
Telerik team
Share this question
or