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

Blur handling for drop down

3 Answers 286 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 25 Apr 2019, 04:40 PM

I have a drop down that responds to type-ahead. If I have a list of items 'Aitem, Bitem, Citem' and I type in the dropdown 'C' I get the input box filled in with 'Citem'. That works just fine. Is what I want is if 'Citem' is in the drop down list and focus is lost an 'automatic' selection occurs. From various documentation I have come up with

        var wrapper = kendoDropDownList.wrapper;
        wrapper.blur(function (e) {

// What goes here?

        });

I have found that this function does get called when I lose focus and the argument 'e' is not undefined. But I am not sure how to get what is in the input box currently or a reference to the dropdown options. Any idea how I would do that?

 

Thank you.

3 Answers, 1 is accepted

Sort by
0
Ianko
Telerik team
answered on 29 Apr 2019, 07:09 AM
Hello Kevin,

My suggestion is to check whether using close or change events would be a better solution as they are built-in events and are more reliable. Using the blur event will not retrieve you the event arguments that a built-in event would. Therefore, you will need to get the widget instance through the DOM element that triggered the event. 

Here you are a dojo example where you can compare the DOM blur event and the widget's close event: https://dojo.telerik.com/EnIbeXaj/3

Regards,
Ianko
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Kevin
Top achievements
Rank 1
answered on 03 May 2019, 04:25 PM

Thank you very much. This went a long way to solving the problem. What I want to do turns out is more.

I have a drop-down that has type ahead functionality. So when I type the first few letters of one of the options in the drop-down the full text for the option is filled in the input field, but it is not selected. The idea of handling the blur event is to automatically select what is in the input field when the user changes focus. The problem comes when an item from the drop-down is selected the input field is also filled in and this time it is also selected. When the user changes focus the input field is essentially selected again (via the blur handling). I was wondering if there was something that I could look at that would tell me that the value in the input field is the result of selection or type ahead?

0
Veselin Tsvetanov
Telerik team
answered on 07 May 2019, 11:20 AM
Hello Kevin,

May I ask you to prepare and send us a small isolated runnable sample implementing the scenario in question? That would allow us to better understand the case and to provide you with the most appropriate assistance.

Regards,
Veselin Tsvetanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
DropDownList
Asked by
Kevin
Top achievements
Rank 1
Answers by
Ianko
Telerik team
Kevin
Top achievements
Rank 1
Veselin Tsvetanov
Telerik team
Share this question
or