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

TreeView in ComboBox

9 Answers 89 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Kjell
Top achievements
Rank 1
Iron
Kjell asked on 29 Oct 2012, 03:14 PM
I try to combine the example "TreeView in ComboBox" and "TreeView / Programmatic Data Binding"
I use "BindToDataSet(ByVal treeView As RadTreeView)", but i only get  System.NullReferenceException.
Tips on what the problem might be, or is there any example (vb) available?

9 Answers, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 31 Oct 2012, 03:57 PM
Hello Kjell,

I prepared a project that implements the functionality of both provided demos. ComboBoxItem and RadTreeView controls are created runtime and dynamically added to the RadComboBox object.  Please find the sample project attached to this response.

Hope that this will lead you into right direction.

Regards,
Boyan Dimitrov
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 RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Kjell
Top achievements
Rank 1
Iron
answered on 31 Oct 2012, 05:42 PM
Thanks, that works. But...
How to get the selected node to display in the combobox like "TreeView / TreeView in ComboBox" exempel...
And how to get RadComboBox1.SelectedValue from treeView.DataValueField on submit?
I use RequiredFieldValidator to validate the TreeView, but i get I get the error message even though RadTreeView is selected...
0
Boyan Dimitrov
Telerik team
answered on 01 Nov 2012, 04:06 PM
Hello Kjell,

I updated the sample project that I sent you in the last response in order to include the described functionality. I added a RadButton control that submits the RadComboBox selection on the client-side and pops up the selected text and value. You could also find RadTreeView OnClientNodeClickingand  and RadComboBox OnClientDropDownOpened client-side event handlers. 

Please find the modifications explained below:

//Code behind

Private Shared Sub BindToDataSet(treeView As RadTreeView)
       .......
        treeView.DataValueField = "ID"
        .....
    End Sub
 
 
Private Shared Sub ComboBoxBind(comboBox As RadComboBox)
        ......
        treeView.ID = "RadTreeView1"
        treeView.OnClientNodeClicking = "nodeClicking"
       ......
    End Sub

I hope that you will find this helpful.

Regards,
Boyan Dimitrov
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 RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Kjell
Top achievements
Rank 1
Iron
answered on 08 Nov 2012, 12:54 PM
Thanks. A question to ....
I use AutoPostBack="true" because I want to save the value in a database.
But after PostBack drop RadComboBox the tree, RadComboBox is empty.
I want it to work like the example "TreeView / TreeView in ComboBox" after PostBack
The selected node is selected after PostBack....
0
Boyan Dimitrov
Telerik team
answered on 13 Nov 2012, 01:41 PM
Hello Kjell,

I have modified the sample project in order to cover your last requirement. I have added some client-side functionality and hidden input field that keeps the selected node text value. This way we keep track of the last selected node before the post-back.

I hope that this would be helpful.

Regards,
Boyan Dimitrov
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 RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Kjell
Top achievements
Rank 1
Iron
answered on 18 Nov 2012, 06:49 PM
Thanks for all help.
One small problem remains for me, in the example I can save RadComboBox1.Text after x number of postback, but I lose RadComboBox.SelectedValue after one postback.
Guess it's value in OnClientDropDownOpenedHandler that determines it, but my knowledge of the function is not good enough;-)
So I'm hoping for some help again ....
0
Boyan Dimitrov
Telerik team
answered on 21 Nov 2012, 05:41 PM
Hello Kjell,

An easy and convenient way to keep track of the combo box selected value would be to store the selected item value to different hidden field on the page and on each page load to retrieve that value and apply it to the RadComboBox control as follows.

function pageLoad() {
            var comboBox = $find("<%= RadComboBox1.ClientID %>");
            var comboValue = document.getElementById("treeNodeValue").value;
            comboBox.set_value(comboValue);
            console.log(comboBox.get_value());
        }
 
Hope that you will find it helpful.

Regards,
Boyan Dimitrov
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 RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Kjell
Top achievements
Rank 1
Iron
answered on 21 Nov 2012, 09:44 PM
I get a Javascript error...
Dump.
0
Boyan Dimitrov
Telerik team
answered on 23 Nov 2012, 04:57 PM
Hello Kjell,

I modified the project so that the SelectedValue property is updated on each button click as well as  persisted after post-back. I have already responded to the support ticket regarding the same problem, so my suggestion is to continue the discussion there.

All the best,
Boyan Dimitrov
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 RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
TreeView
Asked by
Kjell
Top achievements
Rank 1
Iron
Answers by
Boyan Dimitrov
Telerik team
Kjell
Top achievements
Rank 1
Iron
Share this question
or