I have multiple autocomplete boxes and they all filter through the same AJAX datasource. I want to somehow pass the ID of the specific box to the AdditionalData javascript function so that I don't have to write like five different JavaScript functions with pretty much the same logic. I didn't see anything in the documentation and passing "e" in the AdditionalData function just passes the filter.
Razor:<strong>To:</strong> Html.Kendo().AutoComplete().Name("ToAddress")
.DataTextField("Email")
.Separator(";").MinLength(4).Filter(FilterType.Contains)
.DataSource(source =>
{
source.Read(r =>
{
r.Action("SearchAD", "Home").Data("AdditionalData");
})
.ServerFiltering(true);
}))
<strong>CC:</strong> Html.Kendo().AutoComplete().Name("ccAddress")
.DataTextField("Email")
.Separator(";").MinLength(4).Filter(FilterType.Contains)
.DataSource(source =>
{
source.Read(r =>
{
r.Action("SearchAD", "Home").Data("AdditionalData");
})
.ServerFiltering(true);
}))
<strong>BCC:</strong> Html.Kendo().AutoComplete().Name("bccAddress")
.DataTextField("Email")
.Separator(";").MinLength(4).Filter(FilterType.Contains)
.DataSource(source =>
{
source.Read(r =>
{
r.Action("SearchAD", "Home").Data("AdditionalData");
})
.ServerFiltering(true);
}))JavaScript
function AdditionalData() {
var text = $("[the autocomplete id]").val(); //get the ID or any other identifier
var i = text.indexOf(";");
var value = text.substring(i + 1);
return {
text: value
}
}