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

Why OnClientSelectedIndexChanged fires when control loose focus?

1 Answer 32 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
tomekm
Top achievements
Rank 1
tomekm asked on 29 Oct 2010, 10:25 AM

I have several related comboboxes that i populate through javascript. The purpose is to have them all populated and that each has selected value.

1.<telerik:RadComboBox ID="FirstComboBox" EnableLoadOnDemand="false" runat="server"
AllowCustomText="true" MarkFirstMatch="true"
OnClientSelectedIndexChanged="FirstComboSelectedIndexChanged" >
<WebServiceSettings Method="GetFirstItems" Path="ComboboxService.svc" /> </telerik:RadComboBox>
2. 
3.<telerik:RadComboBox ID="SecondComboBox" EnableLoadOnDemand="false" runat="server"
AllowCustomText="true" MarkFirstMatch="true"
OnClientSelectedIndexChanged="SecondComboSelectedIndexChanged" />
<WebServiceSettings Method="GetSecondItems" Path="ComboboxService.svc" /> </telerik:RadComboBox>
4. 
5.<telerik:RadComboBox ID="ThirdComboBox" EnableLoadOnDemand="false" runat="server"
AllowCustomText="true" MarkFirstMatch="true"
OnClientSelectedIndexChanged="ThirdComboSelectedIndexChanged" />
<WebServiceSettings Method="GetSecondItems" Path="ComboboxService.svc" /> </telerik:RadComboBox>

Here is script to populate data and select selected item.

all works great and all combo boxes have proper items and proper value and text. 

01.function pageLoad() {
02.firstComboBox.requestItems(some argument);
03.firstComboBox.set_value(some webService result);                
04.secondComboBox.requestItems(some argument);
05.secondComboBox.set_value(some webService result);          
06.and so on...           
07.                  
08.              
09.  
10.}

The problem is when I focus on a combobox and press TAB key and a combo loose focus. The OnClientSelectedIndexChanged event fires
even though selection did not changed! Why that happens?
I suspect that ComboBox.set_value() function does not set selected index and after loosing focus controls thinks
it has changed but how to fix it?


1 Answer, 1 is accepted

Sort by
0
tomekm
Top achievements
Rank 1
answered on 29 Oct 2010, 12:49 PM

I found solution

It should be :

var item = comboBox.findItemByValue(some webService result);

item.select();

instead of set_value()

Tags
ComboBox
Asked by
tomekm
Top achievements
Rank 1
Answers by
tomekm
Top achievements
Rank 1
Share this question
or