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

How to display checked treeview nodesas combobox text?

3 Answers 93 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Neha
Top achievements
Rank 1
Neha asked on 25 Jul 2011, 03:58 PM
I was referring telerik demo for such functionality - http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/templates/defaultcs.aspx

The only change is i am using treeview with checkbox in RadComboBox. I wanted to display checked items of combobox as comobobox text with comma on collapse.

How to do that?

3 Answers, 1 is accepted

Sort by
0
Thad
Top achievements
Rank 2
answered on 26 Jul 2011, 12:03 AM
Hi Neha,

This should get you most of the way there.  It assumes that you only have one RadComboBoxItem where the ItemTemplate lives.

I'm just typing this in the browser - so this code is not tested.  :-)

function RadComboBox_OnClientDropDownClosing(sender, eventArgs) {
    var item = sender.get_items().getItem(0);// Get the first RadComboBoxItem
    var treeView = item.findControl('putTreeViewNameHere');// Find your RadTreeView
    var checkedNodes = treeView.get_checkedNodes();// Retrieve the checked items in the RadTreeView
 
    var newText = '';
    checkedNodes.forEach(function(node) {  // Loop through the checked nodes. Requires jQuery!
       if (newText != '') {newText += ', ';}
       newText += node.get_text();
    });
    sender.set_text(newText);// Set the RadComboBox text
    if ($.browser.msie) { // IE sometimes takes two tries for it to respond to new text
        sender.set_text(newText);
    }
}

Good luck!
Thad
0
Teoman
Top achievements
Rank 1
answered on 21 Sep 2011, 04:26 AM
hi,
i used your code.when i checked value first time in treeview there is no text in the combobox but when i click combobox again when it closed it shows me the values in combobox.?what can we the problem?
0
Teoman
Top achievements
Rank 1
answered on 29 Feb 2012, 12:39 AM
hi thad,

can you help me about your code please!

i am trying your code its working in chrome and firefox but its not working on ie.

ie give js error at line 14

Message: Object doesn't support this property or method
Line: 14
Char: 9
Code: 0

this is line which i get the error.

checkedNodes.forEach(function (node) { // Loop through the checked nodes. Requires jQuery!
Tags
ComboBox
Asked by
Neha
Top achievements
Rank 1
Answers by
Thad
Top achievements
Rank 2
Teoman
Top achievements
Rank 1
Share this question
or