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

Open dropdown on keyboard input with filtering

3 Answers 104 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 06 Mar 2012, 05:25 PM
We would like the dropdown to automatically open for our comboboxes.  

I have already looked into OpenDropdownOnFocus, but that behavior is not satisfactory for our project.  We need dropdown on keyboard input specifically.

I managed to get it to work by overriding the OnKeyDown as below, but there is a problem.  The filtering doesn't work the first time you open the combobox in this manner.  Every subsequent time, it works, just the first time is a problem.  I suspect that you are lazily loading the items for the dropdown and that is causing the filtering to not function, which is good for efficiency but we really need this behavior for our app.

We are binding to a simple collection so i wouldn't expect the delay of loading items to be very long.

Do you have any suggestions to work around this problem?  Is there an event we can listen to for when the items are loaded where we can trigger it to filter again?

protected override void OnKeyDown(KeyEventArgs e)
{
  if (!IsDropDownOpen && LettersAndNumbers.Contains(e.Key))
  {
    IsDropDownOpen = true;
  }
  base.OnKeyDown(e);
}

3 Answers, 1 is accepted

Sort by
0
Boyan
Telerik team
answered on 09 Mar 2012, 04:21 PM
Hello,

This can't be achieved with the current implementation of RadComboBox. The problem comes from the fact that when the DropDown is opened the filter is being reset and this can't be workarounded.

Greetings,
Boyan
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Ryan
Top achievements
Rank 1
answered on 09 Mar 2012, 05:11 PM
Hi, Thanks for the reply.

I know the filter gets reset when the dropdown is opened.  That's why i made sure to listen for the keydown event and process it before the underlying control processes it, so these things should happen in order:

(1) my child class gets the event and opens the dropdown
(2) my child class calls the base implementation
(3) RadComboBox does its filtering after the dropdown is open

Unfortunately, it seems this doesn't quite work out when the data is first being loaded.  I was hoping there was a workaround or some event where i can set the filter back to the value it had before it was cleared when that happens.
0
Boyan
Telerik team
answered on 14 Mar 2012, 01:42 PM
Hi,

We can't think of a workaround with the current implementation. We will consider implementing property that will fulfill this scenario so this behavior can be achieved out of the box.

All the best,
Boyan
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
ComboBox
Asked by
Ryan
Top achievements
Rank 1
Answers by
Boyan
Telerik team
Ryan
Top achievements
Rank 1
Share this question
or