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

Cascading ComboBox values after model error

2 Answers 43 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.
dani
Top achievements
Rank 1
dani asked on 26 Apr 2012, 04:35 PM
I have 2 Cascading DropDownLists:

@Html.Telerik().DropDownListFor(m => m.nCountryID).BindTo(Model.Countries).Placeholder("Select Country").CascadeTo("nStateID")
@(Html.Telerik().DropDownListFor(m => m.nStateID).Name("nStateID")
.DataBinding(binding => binding.Ajax().Select("_GetDropDownListStates", "User")).Placeholder("Select State")

If I post the form they are in , and there is an error on the form, I'm calling the view again with the same ViewModel
(populating correctly the Model.Countries.

How can I reBind the State DropDown list with the list of right states and on the same state that was submitted ?
(The value is in the Model.nStateID)

2 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 01 May 2012, 12:29 PM
Hi Dani,

You can use the OnLoad event of the second combobox and call the fill method of its client object.
e.g.
function onSecondComboLoad()
{
    $(this).data('tComboBox').fill();
}
This will force the ComboBox to fetch its data from the server.

All the best,
Petur Subev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
0
Maks
Top achievements
Rank 1
answered on 04 May 2012, 05:43 PM
function onSecondComboLoad()
{
    $('#FirstCombo').trigger('valueChange');
}
Tags
ComboBox
Asked by
dani
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Maks
Top achievements
Rank 1
Share this question
or