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

Treeview in ComboBox remembering expanded state

3 Answers 69 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Jeff Bradshaw
Top achievements
Rank 1
Jeff Bradshaw asked on 29 Mar 2011, 09:28 PM
I've got a TreeView in a combo box that works fine. What I'd like to do is keep track of which nodes are expanded in the treeview between pages (I use the control on multiple pages) I've seen code to do a treeview in a combobox and saving a treeview to a session variable but can't seem to get the combination of the two to work correctlty.

Anybody have any suggestions?

TIA - Jeff.

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 30 Mar 2011, 02:15 PM
Hello Jeff,

One suggestion I found from one of the forum is to use the GetXML() method to get the current state of RadTreeView as XML string and save the XML string. When you decide to restore your Treeview, call the LoadXmlString() method to populate the treeview from the previously stored XML String.

Also checkout the code library which would help you in achieving the functionality: Save the expanded state of the TreeNodes when the treeview is being bound upon each postback


Could you paste the code that you tried if this does not help?


-Shinu.
0
Jeff Bradshaw
Top achievements
Rank 1
answered on 30 Mar 2011, 02:44 PM
But how can you get at the treeview? When you edit the code, Visual Studio doesn't seem to know about that control (I assume because it's actually a subcontrol of the combo box.) If I could get at the treeview directly, I would try the GetXML/LoadXML but can't figure out how to get at the treeview.
0
Shinu
Top achievements
Rank 2
answered on 31 Mar 2011, 06:05 AM
Hello Jeff,

You can access the controls which is inside RadCombo ItemTemplate like below.

  • Find the RadTreeView server-side:
    RadTreeView tree = (RadTreeView)RadComboBox1.Items[0].FindControl("RadTreeView1")

  • Find the RadTreeView client-side:
    var combo = $find("<%= RadComboBox1.ClientID %>");
    var tree = combo.get_items().getItem(0).findControl("RadTreeView1");
    tree.get_nodes().getNode(1).select();
Take a look at the following documentation for more on this.
Accessing Controls Inside Templates

Thanks,
Shinu.
Tags
TreeView
Asked by
Jeff Bradshaw
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Jeff Bradshaw
Top achievements
Rank 1
Share this question
or