Question

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.

Was it helpful?

Solution

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);
       }
  }

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top