Your ComboBox Cascade examples use the Html.Kendo().ComboBox() approach. However, for simple binding I typically use Html.Kendo().ComboBoxFor() for data binding.
Two approaches to solving my issue:
- How do I cascade with Html.Kendo().ComboBoxFor()?
- How do I bind with Html.Kendo().ComboBox()?
This gives me the cascading behavior I'm after but no binding on CountryCode:
<div class="form-group">
<label asp-for="Item.CountryCode" class="col-form-label"></label><br />
<span asp-validation-for="Item.CountryCode" class="text-danger"></span>
@(Html.Kendo().ComboBox()
.Name("countries")
.Placeholder("Select Country...")
.DataTextField("Name")
.DataValueField("Code")
.Filter(FilterType.Contains)
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetCountries", "Persons");
});
}).HtmlAttributes(new { style = "width: 100%" }))
</div>
<div class="form-group">
<label asp-for="Item.TimeZoneName" class="col-form-label"></label><br />
<span asp-validation-for="Item.TimeZoneName" class="text-danger"></span>
@(Html.Kendo().ComboBoxFor(x => x.Item.TimeZoneName)
.Placeholder("Select Time Zone...")
.DataTextField("DisplayName")
.DataValueField("Name")
.Filter(FilterType.Contains)
.CascadeFrom("countries")
.Enable(false)
.AutoBind(false)
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetTimeZones", "Persons")
.Data("filterTimeZones");
}).ServerFiltering(true);
}).HtmlAttributes(new { style = "width: 100%" }))
</div>
function filterTimeZones() {
var countryCode = $("#countries").val();
//alert(countryCode);
return { countryCode: countryCode }
}