Using the Kendo Autocomplete to search in a collection of 5000+ items stored in a database. Due to that is chosen to perform the filtering on the server. The problem is that the search value (parameter filter) received by the function is always NULL.
The project is MVC4/razor based, on the page the autocomplete is defined like this:
The javascript handling the additional data events is placed at the end of the cshtml of the page:
The MVC Source controller has the following function to provide the data and search functionality:
Can anyone explain why the filter value received is NULL instead of the value typed in the Autocomplete?
The project is MVC4/razor based, on the page the autocomplete is defined like this:
@(Html.Kendo().AutoComplete()
.Name(
"ExternalId"
)
.Placeholder(
"Search..."
)
.MinLength(3)
.DataSource(source => source.Read(read => read.Action(
"SourcesForAutoComplete"
,
"Source"
)
.Data(
"onAdditionalData"
))
.ServerFiltering(
true
))
.HtmlAttributes(
new
{ style =
"width:468px"
}))
<script>
function
onAdditionalData() {
return
{ filter: $(
"#ExternalId"
).val() };
}
</script>
The MVC Source controller has the following function to provide the data and search functionality:
public
JsonResult SourcesForAutoComplete(
string
filter)
{
using
(var db =
new
EasyTaskIntegrationEntities())
{
...
return
Json(result, JsonRequestBehavior.AllowGet);
}
}