Hi
I want to have 2 dropdownlists but I want to hide the second list if nothing gets populated into it.
You would first choose from Dropdown A, if the selection of Dropdown A does not populate anything into Dropdown B then I want to hide Dropdown B, If something is populated into Dropdown B then I want to show it.
I thought DataBound Event would do this and be fired each time something switched in A but what I am noticing, that if I say make a choice in dropdown A which renders a result in Dropdown B then the databound event is triggered, then if I go and make another choice on dropdown A which renders no result in B the databound event is triggered.
However after that no databound event is triggered.
@(Html.Kendo().DropDownListFor(x => x.Country) .OptionLabel("Select country...") .DataValueField("Code") .DataTextField("Name") .Filter(FilterType.Contains) .DataSource(ds => ds.Read(r => r.Action("GetCountries", "Countries"))) )
@(Html.Kendo().DropDownListFor(x => x.State) .OptionLabel("Select State") .DataValueField("Code") .DataTextField("Name") .Filter(FilterType.Contains) .DataSource(ds => ds.Read(r => r.Action("GetStates", "States").Data("getCountryCode"))) .CascadeFrom("Country") .Enable(false) .Events(e => { e.DataBound("onStateDataBound"); }) )
function onStateDataBound(e) { if (e.sender.dataSource.data().length <= 0) { // hide } else {// show}}
