This is a migrated thread and some comments may be shown as answers.

Set object as DataItem programatically

1 Answer 458 Views
AutoComplete
This is a migrated thread and some comments may be shown as answers.
Software
Top achievements
Rank 1
Software asked on 06 Aug 2018, 10:15 AM

I use AutoComplete as people picker

When selecting element, the whole object is selected (but just first name and last name is shown).

You can get selected object by: $("#" + ).data("kendoAutoComplete").dataItem()

The problem is when I fill the form with data. I don't know how to set to autocomplete so there would be value in ""

$("#" + ).data("kendoAutoComplete").value("test") is setting only what's displayed

I need this to validate whether the proper element was selected and I need all of the other properties of .

 

How to set as element in AutoComplete

 

1 Answer, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 07 Aug 2018, 02:35 PM
Hi,

Unlike the DropDownList or the ComboBox the AutoComplete does not have a dataValueField. Only the field set as dataTextField is used to set the value and only the widget's text is sent to the server on form submission. A workaround you could consider using is to access the selected item's dataItem in the AutoComplete's select event handler. Get the field value you need from the dataItem and save it in a hidden field. On form submission get the field value from the hidden field.

Regards,
Ivan Danchev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
AutoComplete
Asked by
Software
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Share this question
or