3

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.

1 Answer 1

7

Finally, I have found the solution, The Kendo UI provides the Delay (default: 200) method which accepts the integral value in milliseconds, which waits for the next user strock from last keystrokes in specified milliseconds, if the user fails to send the keystroke in specified delay time, the kendo autocomplete fires the server filtering automatically.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.