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

[Solved] Clear ComboBox

3 Answers 196 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Cyndie
Top achievements
Rank 1
Cyndie asked on 16 Sep 2010, 03:16 PM
I'm using the method here to create cascading dropdowns with ComboBoxes:
http://www.telerik.com/community/forums/aspnet-mvc/combobox/load-on-demand-combobox-items.aspx

I have four ComboBoxes in the cascade and would like to clear the third and forth ComboBox if the user changes the selection in the first ComboBox (otherwise the user is presented with incorrect selectable values until the user makes selections in the second and third ComboBoxes to requery the data).  I've tried using the reload() method, but a get the following error:

"Microsoft JScript runtime error: Object doesn't support this property or method"

I can clear the available items in the dropdowns by rebinding the data with null values, but cannot seem to clear the previously selected value from the textbox of the ComboBox.  Is there a way to do this?  (ie. the dropdown has no items to select but it still shows the old selected value in the textbox part of the ComboBox)

Thanks for any help.

3 Answers, 1 is accepted

Sort by
0
Accepted
Joan Vilariño
Top achievements
Rank 2
answered on 16 Sep 2010, 03:21 PM
Hi Cyndie!

Use this:
 
$('#myCombo').data('tComboBox').value('');
$('#myCombo').data('tComboBox').text('');

I hope it helps

Cheers
0
Cyndie
Top achievements
Rank 1
answered on 16 Sep 2010, 03:27 PM
I tried using .value("") previously, but didn't use .text("") and that worked.  Thank you very much!
0
Nayab
Top achievements
Rank 1
answered on 29 Apr 2011, 08:06 AM
Hi,
I have a combobox and AutoComplete and a button "Clear" in my partial view. I want to clear both controls when I click on Clear button,
Button code:
<button class="t-button t-button-icontext" type="button" onclick='clearControl()'><span class="t-icon t-update"></span>Clear</button>

Javascript:
function clearControl() {
    $('#Combo_Orders').data('tComboBox').value('');
    $('#Combo_Orders').data('tComboBox')..text('');

    $('#AC_Emp').data('tAutoComplete').value('');
    $('#AC_Emp').data('tAutoComplete').text('');
}

when I run application and click on Clear button, An error message appears
"Microsoft JScript runtime error: Unable to get value of the property 'value': object is null or undefined"
and asks for Break, Continue, Ignore.
I'm using 2011.1.315 and have included Script Registrar in my partial view.
@Html.Telerik().ScriptRegistrar().DefaultGroup(group => group
        .Add("telerik.common.min.js")
        .Add("telerik.list.min.js")
        .Add("telerik.combobox.min.js")
        .Add("telerik.autocomplete.min.js")       
        .Combined(true).Compress(true))

when i debug through firefox firebug, it says 
$("#Combo_Orders").data("tComboBox") is undefined

I'm not sure what is missing..

Anyone...????
Tags
ComboBox
Asked by
Cyndie
Top achievements
Rank 1
Answers by
Joan Vilariño
Top achievements
Rank 2
Cyndie
Top achievements
Rank 1
Nayab
Top achievements
Rank 1
Share this question
or