AutoComplete with Fake Ajax

by krustev

HTML

<link rel="stylesheet" href="http://cdn.kendostatic.com/2011.3.1129/styles/kendo.common.min.css">
<link rel="stylesheet" href="http://cdn.kendostatic.com/2011.3.1129/styles/kendo.default.min.css">
<script src="http://cdn.kendostatic.com/2011.3.1129/js/kendo.all.min.js"></script>
<input id="searchBox" />

JavaScript

$("#searchBox").kendoAutoComplete({
    minLength: 3,
    dataTextField: "Title",
    //JSON property name to use
    dataSource: {
        pageSize: 10,
        //Limits result set
        transport: {
            read: {
                url: "/echo/json/",
                //using jsfiddle echo service to simulate JSON endpoint
                dataType: "json",
                type: "POST",
                data: {
                    // /echo/json/ echoes the JSON which you pass as an argument
                    json: JSON.stringify([
                    {
                        "Title": "Doctor Who: The Trial of a Time Lord"},
                    {
                        "Title": "Doctor Who: The Key to Time"},
                    {
                        "Title": "Doctor Who: The Time Meddler"},
                    {
                        "Title": "Doctor Who: The End of Time"}
                    ])
                }
            },
            parameterMap: function(options) {
                return $.extend(options, { 
                    title: $("#searchBox").data("kendoAutoComplete").value()
                });
            }
        }
    }
});