Prevent combobox popup when user is typing

170 Views Asked by At

Is it possible to prevent a kendo combobox from opening it's popup when the user is typing text? I still want allow the user to click on the arrow button. The open event can prevent the popup from opening but there's no way to know what triggered the event.

$("#customers").kendoComboBox({
    dataTextField: "ContactName",
    dataValueField: "CustomerID",
    //delay: 999999,  WORKAROUND #1
    //enforceMinLength: true,  WORKAROUND #2
    //minLength: 999999,  WORKAROUND #2
    dataSource: {
        type: "odata",
        transport: {
            read: "..."
        }
    },
    open: function (e) {
      //Triggered by user click or by user input?
      if (triggeredByUserInput) {
        e.preventDefault();
      }
    }
})

The only workarounds I've found so far is to set a very long delay or to enforce the minLength with a long length. While they both work, I think it's a very odd way to fix the problem in the first place so I was wondering if there was a more specific solution.

1

There are 1 best solutions below

1
Aleksandar On BEST ANSWER

The open event still provides a reference to the original event, so you can check if the user clicked on the arrow button or not - example:

open:function(e) {
    if(!$(event.target).hasClass("k-button-icon")){
        e.preventDefault();
    }
}

or even

open:function(e) {
    if(!(event.type == "click")){
        e.preventDefault();
    }
}