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

ComboBox looses elements until refocus

2 Answers 45 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Casper
Top achievements
Rank 1
Casper asked on 28 May 2015, 01:18 PM

Hi,

I have a RCB that is configuresd

 

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

 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

Casper 

2 Answers, 1 is accepted

Sort by
0
Accepted
Ivan Danchev
Telerik team
answered on 02 Jun 2015, 10:25 AM
Hello,

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.

Regards,
Ivan Danchev
Telerik
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
0
Casper
Top achievements
Rank 1
answered on 02 Jun 2015, 11:02 AM

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.

Regards

Casper

Tags
ComboBox
Asked by
Casper
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Casper
Top achievements
Rank 1
Share this question
or