angulartypescriptkendo-combobox

How to focus kendo-combobox in ngOnInit


Basically I want to achieve this: when user navigates to the page that contains kendo-combobox I need to focus it.

It would be great if I could get instance of that component into a variable, so I could manipulate with it in other parts of code.


Solution

  • After some time I found a very easy solution using DOM manipulation. First I gave my kendo-combobox an ID and later inside ngInit I did this:

    var inputs = document.getElementById('erpDropDown').getElementsByTagName('input');
    // in my case I need my input to be empty and ready to receive scanned value from physical scanner
    $("#" + inputs[0].id).val("");   
    document.getElementById(inputs[0].id).focus(); // this line sets focus to HTML input element