Open dropdown on keyboard input with filtering

4 posts, 0 answers
  1. Ryan
    Ryan avatar
    4 posts
    Member since:
    Feb 2012

    Posted 06 Mar 2012 Link to this post

    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);
    }
  2. Boyan
    Admin
    Boyan avatar
    758 posts

    Posted 09 Mar 2012 Link to this post

    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 >>
  3. DevCraft banner
  4. Ryan
    Ryan avatar
    4 posts
    Member since:
    Feb 2012

    Posted 09 Mar 2012 Link to this post

    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.
  5. Boyan
    Admin
    Boyan avatar
    758 posts

    Posted 14 Mar 2012 Link to this post

    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 >>
Back to Top