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

Radlistbox get and set selected items

1 Answer 505 Views
ComboBox and ListBox (obsolete as of Q2 2010)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Mansi
Top achievements
Rank 1
Mansi asked on 28 Jan 2010, 09:35 AM
Hi,

I need to select/deselect items from one listbox to another.
For that I am using two radlistboxes, both are having same items. Both listbox's selectionmode="Multiple".

When user selects items in first list, I need to select them in second listbox through Javascript.
For that, I tried some code, but it works for single item only.

 
           var ctl1= $find('<%= lstTestcategory2.Clientid %>'); 
              var ctl= $find('<%= lstTestcategory.Clientid %>'); 
           
    for(var i = 0; i<= ctl.get_items().get_count()-1; i++)   
    {  
     
          var item1 = ctl.get_items().getItem(i);    
           alert(item1.get_text());  
          alert(item1.get_selected()); 
             check = 1;  
      for(var i = 0; i<= ctl1.get_items().get_count()-1; i++)   
        {  
      //     alert('in');  
           
                var item = ctl1.get_items().getItem(i);       
                if(item.get_text() == e.get_item().get_text())  
                {  
           //    alert('in1');   
                    item.set_selected(true); 
                    check = 1;  
                }  
               else 
               { 
                  item.set_selected(false); 
                } 
        }   

At present I am using it on "OnClientSelectedIndexChanging" event.

What should I do to work it for multiple items too?

1 Answer, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 01 Feb 2010, 01:28 PM
Hello Mansi,

You are right that OnClientSelectedIndexChanged event is fired for every selected item, so you should select the items in the other listbox separately.

Regards,
Yana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
ComboBox and ListBox (obsolete as of Q2 2010)
Asked by
Mansi
Top achievements
Rank 1
Answers by
Yana
Telerik team
Share this question
or