I am using Kendo UI autocomplete in my asp.net mvc application, Kendo autocomplete callbacks the server method on each key strock which over heads the server requests. Is there any way to manually callback the server using autocomplete to get the data source.
My code is as below
@(Html.Kendo().AutoComplete()
.Name("patientSearch")
.DataTextField("patientSearch")
.MinLength(2)
.Placeholder("Search by Lastname, Firstname or DOB")
.HtmlAttributes(new { id = "textPatientSearch" })
.Template("<B>${data.LastName}, ${data.FirstName} </B> - ${ kendo.toString(kendo.parseDate(data.DateOfBirth),'MM/dd/yyyy') } ")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetFilteredPatient", "Order").Data("onAdditionalData");
})
.ServerFiltering(true);
}))
I have found the jquery solution for check that user stops typing, the code is as below:
$(function(){
//setup before functions
var typingTimer; //timer identifier
var doneTypingInterval = 2000; //time in 3 ms
//on keyup, start the countdown
$('#textPatientSearch').keyup(function(e){
clearTimeout(typingTimer);
typingTimer = setTimeout(doneTyping, doneTypingInterval);
});
//on keydown, clear the countdown
$('#textPatientSearch').keydown(function(){
clearTimeout(typingTimer);
});
//user is "finished typing," do something
function doneTyping () {
**//WHAT TO DO HERE**
}
});
I don't know how to manually server filter the autocomplete on doneTyping function, Please help.