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

RadListBox Selection Isssue

1 Answer 53 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Manishkumar
Top achievements
Rank 1
Manishkumar asked on 25 Feb 2011, 04:26 PM
Hi;
We have use two RadListBox .We have unusal requirement such as Consider the Scenario when user Select on one list box then item of other listbox must not be selected and viceversa . The listBox are DragDrop listBox. we have tried using clientside event
"OnClientSelectedIndexChanging" on both the listbox and tried using the following code

 

 

var RHSBoxControl;

 

 

lstRHSBoxControl = $find(

 

'<%= RHSListBox.ClientID %>');

 

 

 

 

if (RHSBoxControl != null) {

 

 

 

 

var items = RHSBoxControl.get_items();

 

 

 

 

for (var lrhsnumCount = 0; lrhsnumCount < RHSBoxControl.get_items().get_count(); lrhsnumCount++) {

 

 

items.getItem(lrhsnumCount).set_selected(

 

false);

 

 

}

 

} .
but the issue is that when we try to fire this method on both list box . the system get hanged and it gives error such as A script on this page is causing Internet Explorer to run slowly.
If it continues to run , your computer might become unresponsive.

Please help how we can resolve this issue ASAP.
As we have go Live next week 

1 Answer, 1 is accepted

Sort by
0
Dimitar Terziev
Telerik team
answered on 02 Mar 2011, 12:07 PM
Hello Manishkumar,

You could use the following implementation of the OnClientSelectedIndexChanging event handler function, which is one and the same for both listboxes:
<script type="text/javascript">
 
    function OnClientSelectedIndexChanging(sender, args) {
 
        if (sender.get_id() == "RadListBox1") {
 
            var listbox2 = $find("RadListBox2");
            listbox2.set_enabled(false);
        }
        else {
 
            var listbox1 = $find("RadListBox1");
            listbox1.set_enabled(false);
        }                               
 
    }
     
</script>

 The markup on which I've tested is the following:
<telerik:RadListBox ID="RadListBox1" runat="server" OnClientSelectedIndexChanging="OnClientSelectedIndexChanging">
           <Items>
               <telerik:RadListBoxItem runat="server" Text="Item1" />
               <telerik:RadListBoxItem runat="server" Text="Item2" />
               <telerik:RadListBoxItem runat="server" Text="Item3" />
               <telerik:RadListBoxItem runat="server" Text="Item4" />
               <telerik:RadListBoxItem runat="server" Text="Item5" />
           </Items>
       </telerik:RadListBox>
       <telerik:RadListBox ID="RadListBox2" runat="server" OnClientSelectedIndexChanging="OnClientSelectedIndexChanging">
           <Items>
               <telerik:RadListBoxItem runat="server" Text="Item1" />
               <telerik:RadListBoxItem runat="server" Text="Item2" />
               <telerik:RadListBoxItem runat="server" Text="Item3" />
               <telerik:RadListBoxItem runat="server" Text="Item4" />
               <telerik:RadListBoxItem runat="server" Text="Item5" />
           </Items>
       </telerik:RadListBox>

 With this approach, once you selected an item from one of the listboxes, the items in the other listbox will be disabled.

Best wishes,
Dimitar Terziev
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
General Discussions
Asked by
Manishkumar
Top achievements
Rank 1
Answers by
Dimitar Terziev
Telerik team
Share this question
or