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

Regarding AutoComplete

1 Answer 64 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
neethu
Top achievements
Rank 1
neethu asked on 28 Nov 2019, 11:51 AM

Hi,

I am using AutoComplete with the below code:

<AutoComplete
                        data={this.state.DataSet2.map(item => item.name)}
                      />

It is working and I need to pass id of the selected text to backend, where Dataset2 contains both id and name. But here just getting the text.

 

Regards

 

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 02 Dec 2019, 07:13 AM

Hello, Neethu,

Currently, the AutoComplete will only return the text as its value.

There are two options in this case:

1) Based on the text value to extract the ID by looping thought the collection.

2) Use the ComboBox component with the suggest property and it will behave as an AutoComplete and it will return the object as value with the ID:

https://www.telerik.com/kendo-react-ui/components/dropdowns/combobox/suggestions/

Make sure to pass the data as objects as well, as otherwise, the component will not have access to it:

https://www.telerik.com/kendo-react-ui/components/dropdowns/combobox/binding/#toc-datasets-of-objects

I hope one of the options to prove helpful.

Regards,
Stefan
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
neethu
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or