How to set the value of a Kendo AutoComplete control to a javascript object?

8.6k Views Asked by At

I have a KendoUI AutoComplete control bound to a list of objects. What I can't figure out is how to set the selected value of the AutoComplete from javascript. For example:

<input id="autocomplete" />
<script>
  $("#autocomplete").kendoAutoComplete({
    dataTextField: "Name",
    dataSource: [ 
      { id: 1, Name: "Apples" }, 
      { id: 2, Name: "Oranges" }, 
      { id: 3, Name: "Carrots" } ]
  });

  $("#autocomplete").data("kendoAutoComplete").value({ id: 2, Name: "Oranges" });
</script>

This just results in the AutoComplete control showing [object Object]. A jsBin of the problem is available here: jsBin

Any suggestions? Jason

1

There are 1 best solutions below

1
On

Answer from OnaBai

$("#autocomplete").data("kendoAutoComplete").value("Oranges");