Hi Cholet,
Thanks for contacting Syncfusion Support.
Currently it is not possible to cascade between the DropDownList and Autocomplete controls. But we can achieve this requirement manually using the ClientSide “select” event of Dropdownlist. And then in AJAX call take the value from the argument and then pass the to the code behind and do the filtering in the server side with the passed DropDownListValue. Finally in the AJAX success will get the JSON data and then pass the value to data Source from controller using this object.
CSHTML:
@Html.EJ().DropDownList("groupsList").Datasource((IEnumerable<groups>)ViewBag.datasource).DropDownListFields(f => f.Value("parentId").Text("text")).ClientSideEvents(e => e.Select("onselect")).WatermarkText("Select")
<script>
function onselect(args) {
$.ajax({
url: '@Url.Action("AutocompleteFeaturesNew", "Autocomplete")',
data: { searchstring: args.value },
type: 'POST',
dataType: "json",
success: function (result) {
var data = eval(result);
var obj = $('#autocomplete').data("ejAutocomplete");
obj.option("watermarkText", "select a Country");
obj.option("dataSource", data);
}
});
}
</script>
Controller:
public JsonResult AutocompleteFeaturesNew(string searchstring)
{
if (searchstring == "")
{
return null;
}
else
{
var Data = SearchData();
var search = from n in Data where n.Country.ToLower().StartsWith(searchstring.ToLower()) select n;
return Json(search, JsonRequestBehavior.AllowGet);
}
} |
Please find the sample below for your reference:
If the above sample and details do not meet your requirement, please give us more information that will help us provide the solution.
Regards,
Arun P.