Don't Expand RadComboBox DropDown On Focus

2k views Asked by At

RadComboBox(autocomplete) is expanding dropdown list when focused. I want to prevent it when there is no text in autocomplete box.

I tried smth like this

function OnClientTextChange (sender, eventArgs) {
  if (false && sender.get_text() == "") {
  showDropDown(sender, null);
}

but "OnClientTextChange doesn't fire until the user hits Enter or clicks outside the combobox."

I need different way to prevent expanding dropdown when its text is empty.

2

There are 2 answers

0
levi On BEST ANSWER

I fixed it by reading json value which is generated and saved in hidden field

function OnClientDropDownOpening(sender, eventArgs) {
    if ($("#RadComboBox1_ClientState").val() != "") {
       var obj = jQuery.parseJSON($("#RadComboBox1_ClientState").val());
       if (obj.text === "") {
         sender.set_cancel(true);
       }
    } else {
         eventArgs.set_cancel(true);
       }
  }
1
Brian Mains On

I assume the TextChanged event is referring to the autocomplete textbox? OnClientTextChanged fires from the client-side onblur event, which fires when another control receives the focus. You are looking for a key event, either keydown, keyup, or keypress. When a key event (keydown/keyup/keypress) fires in the autocomplete, you can then show the dropdown.