New to Kendo UI for jQuery? Download free 30-day trial

Disable noDataTemplate in AutoComplete, MultiSelect, ComboBox, and DropDownList for MVC

Environment

Product Progress® Kendo UI® AutoComplete for jQuery

Description

The .NoDataTemplate method of the ASP.NET MVC wrappers for the dropdown widgets—AutoComplete, MultiSelect, ComboBox, and DropDownList—accepts only strings as parameters. As a result, the template is not displayed.

Solution

Disable noDataTemplate by setting the noDataTemplate option of the wrapped widget to false after the wrapped widget is initialized.

<input id="autocomplete" style="width: 100%;" />
<script>
    // The below configuration mimicks the initialization with a wrapper (MVC/Core, JSP/PHP).

    $(document).ready(function(){
        $("#autocomplete").kendoAutoComplete({
            dataSource: {
            data: ["One", "Two"]
            }
        });
        var autocomplete = $("#autocomplete").data("kendoAutoComplete");
        autocomplete.setOptions({ noDataTemplate: false });
    });
</script>
In this article