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="autoplete" />
<script>
$("#autoplete").kendoAutoComplete({
dataTextField: "Name",
dataSource: [
{ id: 1, Name: "Apples" },
{ id: 2, Name: "Oranges" },
{ id: 3, Name: "Carrots" } ]
});
$("#autoplete").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
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="autoplete" />
<script>
$("#autoplete").kendoAutoComplete({
dataTextField: "Name",
dataSource: [
{ id: 1, Name: "Apples" },
{ id: 2, Name: "Oranges" },
{ id: 3, Name: "Carrots" } ]
});
$("#autoplete").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
Share Improve this question asked May 27, 2014 at 17:10 JasonJason 2,6174 gold badges43 silver badges48 bronze badges 2-
Use
$("#autoplete").data("kendoAutoComplete").value("Oranges");
– OnaBai Commented May 27, 2014 at 18:25 - Arg, I thought I'd tried that. Must have had something else wrong at the time. Thanks OnaBai! Add your ment as an answer and I'll set it as the Answer. – Jason Commented May 27, 2014 at 18:38
1 Answer
Reset to default 3Answer from OnaBai
$("#autoplete").data("kendoAutoComplete").value("Oranges");
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745327768a4622737.html
评论列表(0条)