Kendo UI Autocomplete event when the suggestion list doesn't open yet

686 Views Asked by At

I'm using Kendo UI Autocomplete select. I want to handle some cases where the input value doesn't match the suggested ones so the dropdown wouldn't show up. For example when my list contains :

values=[1xx,2xxx,3xx,4x,5xx]

When the user insert some value in textbox like 6 as a first digits in meanwhile an event will be triggered. Is there any way using JQuery

1

There are 1 best solutions below

0
On

You could write some custom functionality on the filtering event of the Kendo Autocomplete control.

  1. Firstly, you would need to check that the user has only input 1 character so far
  2. Then iterate over the dataSource of the Autocomplete control
  3. Check if the first character of any of the dataSource items match the input value - using a boolean to determine if true or false
  4. Then use e.preventDefault() to stop the Autocomplete control from carrying out any further functionality (if a match has not been found based on the input value)
  5. And finally, trigger a close on the Autocomplete control (to cover the scenario where a user enters a value, removes it and enters another which is not a match)

All neatly packaged in a Dojo example which should just about cover it!