Kendo UI autocomplete databound event does not trigger

I am developing a mobile application using Kendo UI. In my script file,

$("#name").kendoAutoComplete({
        dataBound: onChange
    });

Suppose my autocomplete box has the string "abc". When I delete a letter it triggers the databound event. But I delete the last letter of autocomplete (emptying autocomplete) it does not trigger databound event. Can anyone explain the problem?

Answers


When you type, the auto-complete widget will filter the data source if there is any text in it; this triggers the data source change event which in turn leads to the dataBound event being triggered in the AutoComplete.refresh method (where the widget updates its view if necessary).

If there is no text in the input, then the data source is not filtered and as a result, the dataBound event isn't triggered (in that case, the auto-complete simply closes its popup).

If this bothers you and you want dataBound to be triggered when you clear the input, you can customize the widget's search method:

kendo.ui.AutoComplete.fn.search = (function (search) {
    return function (word) {
        word = word || this._accessor();
        var length = word.length;
        if (!length) {
            this.dataSource.filter({}); // clear the data source filter
        }

        search.apply(this, arguments);
    };
})(kendo.ui.AutoComplete.fn.search);

(demo)


Need Your Help

How does tcl exec work exactly?

exec tcl

I am automating some work that requires calling tcpdump -nn -tt -r on some .pcap files.

Dynamically build SQL " OR " query in c#

c# asp.net sql

I am having problem with my asp.net app, in which I am dynamically building SQL query where I am using WHERE clause and adding OR depending on the fields which is entered. here is the scenario.