自动完成的默认行为是输入字段为空并在用户开始输入时开始列出数据。我希望所有数据在开头列为下拉列表,以便用户可以看到所有可用选项。这可能吗:
HTML:
<input data-bind="kendoAutoComplete: { data: choices, value: selectedChoice }" />
<hr/>
Selected: <strong data-bind="text: selectedChoice"> </strong>
的javascript:
var ViewModel = function() {
this.choices = ko.observableArray(["apple", "orange", "banana"]);
this.selectedChoice = ko.observable();
};
ko.applyBindings(new ViewModel());
jsfiddle:http://jsfiddle.net/2Qnv7/94/
答案 0 :(得分:1)
您可以通过向HTML focus
添加input
事件然后调用autocomplete.popup.open()
示例:
HTML:
<input id="autocomplete" data-bind="kendoAutoComplete: { data: choices, value: selectedChoice }" />
<hr/>
Selected: <strong data-bind="text: selectedChoice"> </strong>
的JavaScript
var ViewModel = function() {
this.choices = ko.observableArray(["apple", "orange", "banana"]);
this.selectedChoice = ko.observable();
};
ko.applyBindings(new ViewModel());
$("#autocomplete").on("focus", function() {
var autocomplete = $("#autocomplete").data("kendoAutoComplete");
autocomplete.popup.open();
});
和JSFiddle:http://jsfiddle.net/OnaBai/2Qnv7/101/