Radlistbox get and set selected items

2 posts, 0 answers
  1. Mansi
    Mansi avatar
    63 posts
    Member since:
    Feb 2009

    Posted 28 Jan 2010 Link to this post

    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?
  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 01 Feb 2010 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top