Why OnClientSelectedIndexChanged fires when control loose focus?

2 posts, 0 answers
  1. tomekm
    tomekm avatar
    38 posts
    Member since:
    Mar 2009

    Posted 29 Oct 2010 Link to this post

    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?


  2. tomekm
    tomekm avatar
    38 posts
    Member since:
    Mar 2009

    Posted 29 Oct 2010 Link to this post

    I found solution

    It should be :

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

    item.select();

    instead of set_value()

Back to Top