ComboBox looses elements until refocus

3 posts, 1 answers
  1. Casper
    Casper avatar
    24 posts
    Member since:
    Mar 2015

    Posted 28 May 2015 Link to this post


    I have a RCB that is configuresd


    <telerik:RadComboBox ID="RadComboBoxPlan" runat="server" AutoPostBack="True"
                            OnSelectedIndexChanged="OnPlanTextChanged" ChangeTextOnKeyBoardNavigation="True"
                            EnableLoadOnDemand="True" Filter="StartsWith" DataSourceID="PlanSqlSource" DataTextField="name"      DataValueField="plan_id"
                            OnItemsRequested="RadComboBoxPlan_OnItemsRequested" ViewStateMode="Enabled">
                            <DefaultItem Text="Choose plan" Value="-1" />

     OnPlanTextChanged updates a radgrid that is dependent ​on the value of the RCB asn the RadComboBoxPlan_OnItemsRequested updates the select statement of the sql source. It works fine when selecting a value for the first time, but if the dropdown button is clicked again the list will be empty save for the currently selected item. If focus is lost to the RCB and the dropdown button is clicked again the list will populate as expected.

    Is there a way i can make sure the list is populated correctly the first time?


    Kind regards


  2. Answer
    Ivan Danchev
    Ivan Danchev avatar
    1268 posts

    Posted 02 Jun 2015 Link to this post


    If you are updating the select statement in the RadComboBoxPlan_OnItemsRequested event handler you have to make sure the OnItemsRequested event is fired at the right time when you need it. This event fires when the user starts typing text in the input field, while clicking on the RadComboBoxItems would fire the OnSelectedIndexChanged event.

    Placing break points in the event handlers to track when each of them is fired, would help you plan which user action should cause the select statement to be updated and the corresponding event handler the code should be executed in.

    You can find a list of the RadComboBox server-side events in our Server Side Events documentation article, and the corresponding articles provide more details on the conditions under which the events are fired.

    Ivan Danchev
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. Casper
    Casper avatar
    24 posts
    Member since:
    Mar 2015

    Posted 02 Jun 2015 in reply to Ivan Danchev Link to this post

    Thank you! it pointed me in the right direction.

    For closure to anyone who might be reading this, postbacks resets the selectCommand string to the one declared in the markup. This means that each event where a lookup to the database is needed, the selcetCommand needs to be updated.



Back to Top