title | page_title | description |
---|---|---|
AutoComplete |
Configuration, methods and events of Kendo UI AutoComplete |
How to configure and control methods in Autocomplete UI widget, which events to use to open, close, change, select. |
Represents the Kendo UI AutoComplete widget. Inherits from Widget.
Important: The Kendo UI AutoComplete should be created from an input HTML element.
Configures the opening and closing animations of the suggestion popup. Setting the animation
option to false
will disable the opening and closing animations. As a result the suggestion popup will open and close instantly.
animation:true
is not a valid configuration.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
animation: false
});
</script>
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
animation: {
close: {
effects: "fadeOut zoom:out",
duration: 300
},
open: {
effects: "fadeIn zoom:in",
duration: 300
}
}
});
</script>
The animation played when the suggestion popup is closed.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
animation: {
close: {
effects: "zoom:out",
duration: 300
}
}
});
</script>
The duration of the close animation in milliseconds.
The effect(s) to use when playing the close animation. Multiple effects should be separated with a space.
Complete list of available animations
The animation played when the suggestion popup is opened.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
animation: {
open: {
effects: "zoom:in",
duration: 300
}
}
});
</script>
The duration of the open animation in milliseconds.
The effect(s) to use when playing the open animation. Multiple effects should be separated with a space.
Complete list of available animations
If set to true
, the widget automatically adjusts the width of the popup element and does not wrap up the item label.
Note: Virtualized list doesn't support the auto-width functionality.
<input id="autocomplete" style="width: 100px;" />
<script>
$("#autocomplete").kendoAutoComplete({
autoWidth: true,
dataSource: {
data: ["Short item", "An item with really, really long text"]
}
});
</script>
The data source of the widget which is used to display suggestions for the current value. Can be a JavaScript object which represents a valid data source configuration, a JavaScript array or an existing kendo.data.DataSource instance.
If the dataSource
option is set to a JavaScript object or array the widget will initialize a new kendo.data.DataSource instance using that value as data source configuration.
If the dataSource
option is an existing kendo.data.DataSource instance the widget will use that instance and will not initialize a new one.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
dataSource: {
data: ["One", "Two"]
}
});
</script>
<input id="autocomplete" />
<script>
var data = ["One", "Two"];
$("#autocomplete").kendoAutoComplete({
dataSource: data
});
</script>
<input id="autocomplete" />
<script>
var dataSource = new kendo.data.DataSource({
transport: {
read: {
url: "http://demos.telerik.com/kendo-ui/service/products",
dataType: "jsonp"
}
}
});
$("#autocomplete").kendoAutoComplete({
dataSource: dataSource,
dataTextField: "ProductName"
});
</script>
Unless this options is set to false
, a button will appear when hovering the widget. Clicking that button will reset the widget's value and will trigger the change event.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
clearButton: false
});
</script>
The field of the data item used when searching for suggestions. This is the text that will be displayed in the list of matched results.
<input id="autocomplete" />
<script>
var data = [
{ id: 1, name: "Apples" },
{ id: 2, name: "Oranges" }
];
$("#autocomplete").kendoAutoComplete({
dataTextField: "name", // The widget is bound to the "name" field
dataSource: data
});
</script>
The delay in milliseconds between a keystroke and when the widget displays the suggestion popup.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
delay: 500
});
</script>
If set to false
the widget will be disabled and will not allow user input. The widget is enabled by default and allows user input.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
enable: false
});
</script>
If set to true
the widget will not show all items when the text of the search input cleared. By default the widget shows all items when the text of the search input is cleared. Works in conjunction with minLength.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
dataTextField: "ProductName",
filter: "contains",
minLength: 3,
enforceMinLength: true,
autoBind: false,
dataSource: {
type: "odata",
serverFiltering: true,
transport: {
read: "//demos.telerik.com/kendo-ui/service/Northwind.svc/Products"
}
}
});
</script>
The filtering method used to determine the suggestions for the current value. The default filter is "startswith" -
all data items which begin with the current widget value are displayed in the suggestion popup. The supported filter
values are startswith
, endswith
and contains
.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
filter: "contains",
dataSource: {
data: ["One", "Two"]
}
});
</script>
The template used to render the fixed header group. By default the widget displays only the value of the current group.
<input id="customers" style="width: 400px" />
<script>
$(document).ready(function() {
$("#customers").kendoAutoComplete({
dataTextField: "ContactName",
fixedGroupTemplate: "Fixed group: #:data#",
height: 400,
dataSource: {
type: "odata",
transport: {
read: "http://demos.telerik.com/kendo-ui/service/Northwind.svc/Customers"
},
group: { field: "Country" }
}
});
});
</script>
The template used to render the footer template. The footer template receives the widget itself as a part of the data argument. Use the widget fields directly in the template.
The widget instance.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
dataSource: [
{ id: 1, name: "Apples" },
{ id: 2, name: "Oranges" }
],
dataTextField: "name",
footerTemplate: 'Total <strong>#: instance.dataSource.total() #</strong> items found'
});
</script>
The template used to render the groups. By default the widget displays only the value of the group.
<input id="customers" style="width: 400px" />
<script>
$(document).ready(function() {
$("#customers").kendoAutoComplete({
dataTextField: "ContactName",
groupTemplate: "Group: #:data#",
height: 400,
dataSource: {
type: "odata",
transport: {
read: "http://demos.telerik.com/kendo-ui/service/Northwind.svc/Customers"
},
group: { field: "Country" }
}
});
});
</script>
The height of the suggestion popup in pixels. The default value is 200 pixels.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
height: 100,
dataSource: {
data: ["One", "Two", "Three", "Four", "Five", "Six", "Seven"]
}
});
</script>
If set to true
the first suggestion will be automatically highlighted.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
highlightFirst: true,
dataSource: {
data: ["One", "Two"]
}
});
</script>
If set to false
case-sensitive search will be performed to find suggestions. The widget performs case-insensitive searching by default.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
ignoreCase: false,
dataSource: {
data: ["One", "Two"]
}
});
</script>
The minimum number of characters the user must type before a search is performed. Set to higher value than 1
if the search could match a lot of items.
Widget will initiate a request when input value is cleared. If you would like to prevent this behavior please check the filtering event for more details.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
minLength: 3,
placeholder: "Type 'one'",
dataSource: {
data: ["One", "Two"]
}
});
</script>
The template used to render the "no data" template, which will be displayed if no results are found or the underlying data source is empty. The noData template receives the widget itself as a part of the data argument. The template will be evaluated on every widget data bound.
Important The popup will open when 'noDataTemplate' is defined
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
dataSource: [
{ id: 1, name: "Apples" },
{ id: 2, name: "Oranges" }
],
dataTextField: "name",
noDataTemplate: 'No Data!'
});
</script>
The hint displayed by the widget when it is empty. Not set by default.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
placeholder: "Enter value ..."
});
</script>
The Kendo UI AutoComplete widget could also use the value of the placeholder
HTML attribute as hint.
<input id="autocomplete" placeholder="Enter value..." />
<script>
$("#autocomplete").kendoAutoComplete();
</script>
The options that will be used for the popup initialization. For more details about the available options refer to Popup documentation.
<div id="container">
<input id="autocomplete" />
</div>
<script>
$("#autocomplete").kendoAutoComplete({
dataSource: [
{ id: 1, name: "Apples" },
{ id: 2, name: "Oranges" }
],
dataTextField: "name",
popup: {
appendTo: $("#container")
}
});
</script>
The character used to separate multiple values. Empty by default.
As of Q3 2016 the Autocomplete widget supports multiple separators listed in an array. All separators will be replaced with the first array item, which acts as a default separator.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
separator: ", ",
dataSource: {
data: ["One", "Two"]
}
});
</script>
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
separator: [", ", "; "],
dataSource: {
data: ["One", "Two"]
}
});
</script>
If set to true
the widget will automatically use the first suggestion as its value.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
suggest: true,
dataSource: {
data: ["One", "Two"]
}
});
</script>
Specifies a static HTML content, which will be rendered as a header of the popup element.
Important The header content should be wrapped with a HTML tag if it contains more than one element. This is applicable also when header content is just a string/text.
Important Widget does not pass a model data to the header template. Use this option only with static HTML.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
dataSource: [
{ id: 1, name: "Apples" },
{ id: 2, name: "Oranges" }
],
dataTextField: "name",
headerTemplate: '<div><h2>Fruits</h2></div>'
});
</script>
The template used to render the suggestions. By default the widget displays only the text of the suggestion (configured via dataTextField
).
<input id="autocomplete" />
<script id="template" type="text/x-kendo-template">
<span>
<img src="/https/github.com/img/#: id #.png" alt="#: name #" />
#: name #
</span>
</script>
<script>
$("#autocomplete").kendoAutoComplete({
dataSource: [
{ id: 1, name: "Apples" },
{ id: 2, name: "Oranges" }
],
dataTextField: "name",
template: kendo.template($("#template").html())
});
</script>
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
dataSource: [
{ id: 1, name: "Apples" },
{ id: 2, name: "Oranges" }
],
dataTextField: "name",
template: '<span><img src="/https/github.com/img/#: id #.png" alt="#: name #" />#: name #</span>'
});
</script>
The value of the widget.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
dataSource: [
{ id: 1, name: "Apples" },
{ id: 2, name: "Oranges" }
],
dataTextField: "name",
value: "Oranges"
});
</script>
Specifies the value binding behavior for the widget when the initial model value is null. If set to true, the View-Model field will be updated with the selected item text field. If set to false, the View-Model field will be updated with the selected item.
<input id="autocomplete" data-bind="value: productName, source: products" />
<script>
$("#autocomplete").kendoAutoComplete({
valuePrimitive: true,
dataTextField: "name"
});
var viewModel = kendo.observable({
productName: null,
products: [
{ id: 1, name: "Coffee" },
{ id: 2, name: "Tea" },
{ id: 3, name: "Juice" }
]
});
kendo.bind($("#autocomplete"), viewModel);
</script>
Enables the virtualization feature of the widget. The configuration can be set on an object, which contains two properties - itemHeight
and valueMapper
.
For detailed information, refer to the [article on virtualization]({% slug virtualization_kendoui_combobox_widget %}).
<input id="orders" style="width: 400px" />
<script>
$(document).ready(function() {
$("#orders").kendoAutoComplete({
template: "#= OrderID # | For: #= ShipName #, #= ShipCountry #",
dataTextField: "ShipName",
virtual: true,
height: 520,
dataSource: {
type: "odata",
transport: {
read: "http://demos.telerik.com/kendo-ui/service/Northwind.svc/Orders"
},
schema: {
model: {
fields: {
OrderID: { type: "number" },
Freight: { type: "number" },
ShipName: { type: "string" },
OrderDate: { type: "date" },
ShipCity: { type: "string" }
}
}
},
pageSize: 80,
serverPaging: true,
serverFiltering: true
}
});
});
</script>
<div class="demo-section k-header">
<h4>Search for shipping name</h4>
<input id="orders" style="width: 400px"
data-role="autocomplete"
data-bind="value: order, source: source"
data-text-field="ShipName"
data-virtual="{itemHeight:26,valueMapper:orderValueMapper}"
/>
</div>
<script>
$(document).ready(function() {
var model = kendo.observable({
order: "Hanari Carnes",
source: new kendo.data.DataSource({
type: "odata",
transport: {
read: "http://demos.telerik.com/kendo-ui/service/Northwind.svc/Orders"
},
schema: {
model: {
fields: {
OrderID: { type: "number" },
Freight: { type: "number" },
ShipName: { type: "string" },
OrderDate: { type: "date" },
ShipCity: { type: "string" }
}
}
},
pageSize: 80,
serverPaging: true,
serverFiltering: true
})
});
kendo.bind($(document.body), model);
});
function orderValueMapper(options) {
$.ajax({
url: "http://demos.telerik.com/kendo-ui/service/Orders/ValueMapper",
type: "GET",
dataType: "jsonp",
data: convertValues(options.value),
success: function (data) {
options.success(data);
}
})
}
function convertValues(value) {
var data = {};
value = $.isArray(value) ? value : [value];
for (var idx = 0; idx < value.length; idx++) {
data["values[" + idx + "]"] = value[idx];
}
return data;
}
</script>
Specifies the height of the virtual item. All items in the virtualized list must have the same height.
If the developer does not specify one, the framework will automatically set itemHeight
based on the current theme and font size.
<input id="orders" style="width: 400px" />
<script>
$(document).ready(function() {
$("#orders").kendoAutoComplete({
template: "#= OrderID # | For: #= ShipName #, #= ShipCountry #",
dataTextField: "ShipName",
virtual: {
itemHeight: 26
},
height: 520,
dataSource: {
type: "odata",
transport: {
read: "http://demos.telerik.com/kendo-ui/service/Northwind.svc/Orders"
},
schema: {
model: {
fields: {
OrderID: { type: "number" },
Freight: { type: "number" },
ShipName: { type: "string" },
OrderDate: { type: "date" },
ShipCity: { type: "string" }
}
}
},
pageSize: 80,
serverPaging: true,
serverFiltering: true
}
});
});
</script>
The changes introduced with the Kendo UI R3 2016 release enable you to determine if the valueMapper
must resolve a value to an index
or a value to a dataItem
. This is configured through the mapValueTo
option that accepts two possible values - "index"
or "dataItem"
. By default, the mapValueTo
is set to "index"
, which does not affect the current behavior of the virtualization process.
For more information, refer to the [article on virtualization]({% slug virtualization_kendoui_combobox_widget %}#value-mapping).
Important
As of the Kendo UI R3 2016 release, the implementation of the
valueMapper
function is not necessary.
// the example is relevant to Kendo UI versions prior to 2016.3.914
<input id="orders" style="width: 400px" />
<script>
$(document).ready(function() {
$("#orders").kendoAutoComplete({
template: '<span class="order-id">#= OrderID #</span> #= ShipName #, #= ShipCountry #',
dataTextField: "ShipName",
virtual: {
itemHeight: 26,
valueMapper: function(options) {
$.ajax({
url: "http://demos.telerik.com/kendo-ui/service/Orders/ValueMapper",
type: "GET",
dataType: "jsonp",
data: convertValues(options.value),
success: function (data) {
//the **data** is either index or array of indices.
//Example:
// "Ernst Handel" -> 10 (index in the Orders collection)
// ["Ernst Handel", "Que Delícia"] -> [10, 14] (indices in the Orders collection)
options.success(data);
}
})
}
},
height: 520,
dataSource: {
type: "odata",
transport: {
read: "http://demos.telerik.com/kendo-ui/service/Northwind.svc/Orders"
},
pageSize: 80,
serverPaging: true,
serverFiltering: true
}
});
});
function convertValues(value) {
var data = {};
value = $.isArray(value) ? value : [value];
for (var idx = 0; idx < value.length; idx++) {
data["values[" + idx + "]"] = value[idx];
}
return data;
}
</script>
The data source of the widget. Configured via the dataSource option.
Changes of the data source will be reflected in the widget.
Important: Assigning a new data source would have no effect. Use the setDataSource method instead.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
dataSource: [
{ name: "Apples" },
{ name: "Oranges" }
],
dataTextField: "name"
});
var autocomplete = $("#autocomplete").data("kendoAutoComplete");
autocomplete.dataSource.read();
autocomplete.dataSource.add({ name: "Appricot" });
autocomplete.search("A");
</script>
An object, which holds the options of the widget.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete();
var autocomplete = $("#autocomplete").data("kendoAutoComplete");
var element = autocomplete.element;
var options = autocomplete.options;
console.log(options);
</script>
A jQuery object of the drop-down list element.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete();
var autocomplete = $("#autocomplete").data("kendoAutoComplete");
var list = autocomplete.list;
console.log(list);
</script>
A jQuery object of the ul
element, which holds the available options.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete();
var autocomplete = $("#autocomplete").data("kendoAutoComplete");
var ul = autocomplete.ul;
console.log(ul);
</script>
Closes the widget suggestion popup.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
dataSource: [ "Apples", "Oranges" ]
});
var autocomplete = $("#autocomplete").data("kendoAutoComplete");
// Search for items starting with "A" - will open the suggestion popup and show "Apples"
autocomplete.search("A");
// Close the suggestion popup
autocomplete.close();
</script>
Returns the data item at the specified index.
The zero-based index of of the data item.
Object
the data item at the specified index. Returns undefined
if the index is not within bounds.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
dataSource: [ "Apples", "Oranges" ]
});
var autocomplete = $("#autocomplete").data("kendoAutoComplete");
// Search for items starting with "A" - will open the suggestion popup and show "Apples"
autocomplete.search("A");
console.log(autocomplete.dataItem(0)); // Displays "Apples" in the browser console
</script>
Prepares the widget for safe removal from DOM. Detaches all event handlers and removes jQuery.data attributes to avoid memory leaks. Calls destroy method of any child Kendo widgets.
Important: This method does not remove the widget element from DOM.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete();
var autocomplete = $("#autocomplete").data("kendoAutoComplete");
autocomplete.destroy();
</script>
Enables or disables the widget.
If set to true
the widget will be enabled. If set to false
the widget will be disabled.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
enable: false
});
var autocomplete = $("#autocomplete").data("kendoAutoComplete");
autocomplete.enable(true);
</script>
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete();
var autocomplete = $("#autocomplete").data("kendoAutoComplete");
autocomplete.enable(false);
</script>
Focuses the widget.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete();
var autocomplete = $("#autocomplete").data("kendoAutoComplete");
autocomplete.focus();
</script>
Obtains an Array of the DOM elements, which correspond to the data items from the Kendo UI DataSource view (e.g. the ones that match the user's last filtering input).
Array
The currently rendered dropdown list items (<li>
elements).
Toggles the readonly state of the widget. When the widget is readonly it doesn't allow user input.
There is a difference between disabled and readonly mode. The value of a disabled widget is not posted as part of a
form
whereas the value of a readonly widget is posted.
If set to true
the widget will not allow user input. If set to false
the widget will allow user input.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete();
var autocomplete = $("#autocomplete").data("kendoAutoComplete");
autocomplete.readonly(true);
</script>
Refresh the suggestion popup by rendering all items again.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete();
var autocomplete = $("#autocomplete").data("kendoAutoComplete");
autocomplete.refresh();
</script>
Searches the data source for the provided value and displays any matches as suggestions.
The value to search for. All matches are displayed in the suggestion popup.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
dataSource: [ "Apples", "Oranges" ]
});
var autocomplete = $("#autocomplete").data("kendoAutoComplete");
autocomplete.search("A"); // Displays "Apples" in the suggestion popup
</script>
Selects the item provided as an argument and updates the value of the widget.
Important: When virtualization is enabled, the method does not support selection with a function predicate. The predicate function looks only in the current datasource view, which represents only the active range/page. Hence it will not work properly.
Important: This method does not trigger change event. This could affect MVVM value binding. The model bound to the widget will not be updated. You can overcome this behavior trigerring the
change
event manually using trigger("change") method.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
dataSource: [ "John", "Jane" ]
});
var autocomplete = $("#autocomplete").data("kendoAutoComplete");
autocomplete.search("J");
autocomplete.select(autocomplete.ul.children().eq(1)); // Selects the second suggestion which is "Jane"
autocomplete.trigger("change");
</script>
A string, DOM element or jQuery object which represents the item to be selected. A string is treated as a jQuery selector.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
dataSource: [ "John", "Jane" ]
});
var autocomplete = $("#autocomplete").data("kendoAutoComplete");
autocomplete.search("J");
autocomplete.select(autocomplete.ul.children().eq(1)); // Selects the second suggestion which is "Jane"
</script>
Sets the data source of the widget.
The data source to which the widget should be bound.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
dataSource: [ "Apples", "Oranges" ]
});
var dataSource = new kendo.data.DataSource({
data: [ "Bananas", "Cherries" ]
});
var autocomplete = $("#autocomplete").data("kendoAutoComplete");
autocomplete.setDataSource(dataSource);
</script>
Sets the value of the widget to the specified argument and visually selects the text.
The value to set.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
dataSource: [ "Apples", "Oranges" ]
});
var autocomplete = $("#autocomplete").data("kendoAutoComplete");
autocomplete.suggest("Apples");
</script>
Gets or sets the value of the widget.
Important: This method does not trigger change event. This could affect MVVM value binding. The model bound to the widget will not be updated. You can overcome this behavior trigerring the
change
event manually using trigger("change") method.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete();
var autocomplete = $("#autocomplete").data("kendoAutoComplete");
autocomplete.value("new value");
autocomplete.trigger("change");
</script>
The value to set.
String
the value of the widget.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
dataSource: [ "Apples", "Oranges" ]
});
var autocomplete = $("#autocomplete").data("kendoAutoComplete");
autocomplete.value("Apples");
var value = autocomplete.value();
console.log(value); // Displays "Apples"
</script>
Fired when the value of the widget is changed by the user.
The event handler function context (available via the this
keyword) will be set to the widget instance.
Important: The event is not fired when the value of the widget is changed from code.
The widget instance which fired the event.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
change: function(e) {
var value = this.value();
console.log(value);
// Use the value of the widget
}
});
</script>
<input id="autocomplete" />
<script>
function autocomplete_change(e) {
var value = this.value();
// Use the value of the widget
}
$("#autocomplete").kendoAutoComplete();
var autocomplete = $("#autocomplete").data("kendoAutoComplete");
autocomplete.bind("change", autocomplete_change);
</script>
Fired when the suggestion popup of the widget is closed by the user.
The event handler function context (available via the this
keyword) will be set to the widget instance.
The widget instance which fired the event.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
dataSource: [ "Apples", "Oranges" ],
close: function(e) {
// handle the event
}
});
</script>
<input id="autocomplete" />
<script>
function autocomplete_close(e) {
// handle the event
}
$("#autocomplete").kendoAutoComplete({
dataSource: [ "Apples", "Oranges" ]
});
var autocomplete = $("#autocomplete").data("kendoAutoComplete");
autocomplete.bind("close", autocomplete_close);
</script>
Fired when the widget is bound to data from its data source.
The event handler function context (available via the this
keyword) will be set to the widget instance.
The widget instance which fired the event.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
dataSource: [ "Apples", "Oranges" ],
dataBound: function(e) {
// handle the event
}
});
</script>
<input id="autocomplete" />
<script>
function autocomplete_dataBound(e) {
// handle the event
}
$("#autocomplete").kendoAutoComplete({
dataSource: [ "Apples", "Oranges" ]
});
var autocomplete = $("#autocomplete").data("kendoAutoComplete");
autocomplete.bind("dataBound", autocomplete_dataBound);
</script>
Fired when the widget is about to filter the data source.
The event handler function context (available via the this
keyword) will be set to the widget instance.
The widget instance which fired the event.
The filter descriptor that will be used to filter the data source.
The data source filters the data items client-side unless the data source serverFiltering option is set to
true
.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
dataSource: [ "Apples", "Oranges" ],
filtering: function(e) {
//get filter descriptor
var filter = e.filter;
console.log(filter);
// handle the event
}
});
</script>
<input id="autocomplete" />
<script>
function autocomplete_filtering(e) {
//get filter descriptor
var filter = e.filter;
console.log(filter);
// handle the event
}
$("#autocomplete").kendoAutoComplete({
dataSource: [ "Apples", "Oranges" ]
});
var autocomplete = $("#autocomplete").data("kendoAutoComplete");
autocomplete.bind("filtering", autocomplete_filtering);
</script>
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
dataSource: [ "Apples", "Oranges" ],
filtering: function(e) {
var filter = e.filter;
if (!filter.value) {
//prevent filtering if the filter does not value
e.preventDefault();
}
}
});
</script>
Fired when the suggestion popup of the widget is opened by the user.
The event handler function context (available via the this
keyword) will be set to the widget instance.
The widget instance which fired the event.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
dataSource: [ "Apples", "Oranges" ],
open: function(e) {
// handle the event
}
});
</script>
<input id="autocomplete" />
<script>
function autocomplete_open(e) {
// handle the event
}
$("#autocomplete").kendoAutoComplete({
dataSource: [ "Apples", "Oranges" ]
});
var autocomplete = $("#autocomplete").data("kendoAutoComplete");
autocomplete.bind("open", autocomplete_open);
</script>
Fired when an item from the suggestion popup is selected by the user.
Important: The event is not fired when an item is selected programmatically.
The data item instance of the selected item.
The jQuery object which represents the selected item.
The widget instance which fired the event.
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
dataSource: [ "Apples", "Oranges" ],
select: function(e) {
var item = e.item;
var text = item.text();
console.log(text);
// Use the selected item or its text
}
});
</script>
<input id="autocomplete" />
<script>
function autocomplete_select(e) {
var item = e.item;
var text = item.text();
// Use the selected item or its text
}
$("#autocomplete").kendoAutoComplete({
dataSource: [ "Apples", "Oranges" ]
});
var autocomplete = $("#autocomplete").data("kendoAutoComplete");
autocomplete.bind("select", autocomplete_select);
</script>
<input id="autocomplete" />
<script>
$("#autocomplete").kendoAutoComplete({
dataSource: [ "Apples", "Oranges" ],
select: function(e) {
//call preventDefault() to prevent the selection
e.preventDefault();
}
});
</script>