Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
130
Autocomplete and objects as search response
posted

Im creating an autocomplete input that searchs company employees. 

After getting a list of employees and chosing one, I need to store in a variable the selected employee, and show in the input his full name, which is a property from the selected employee object. 

So far I've had no success. After selecting an employee from the list, the input shows "[object Object]" because im setting the object for the drop down item.

Is this possible? 

  • 0
    Offline posted

    thanks for the awesome information.

  • 2680
    Offline posted
    Hello Hernan,

     

    Thank you for posting to Infragistics Community.

     

    I have been looking into your question and what I can say is that what is shown in the input is indeed determined by the IgxDropDownItem’s value property, so in case you would like to show the full name property, that is what has to be specified.

     

    A possible workaround approach I can suggest is shown in this sample. It consists of handling the selectionChanging event of the IgxDropDownComponent and assigning the selected object variable to the event arguments’ newSelection value property (it is set as the entire object). And the “stateSelected” variable, which is the one bound to the input via ngModel, is assigned a property of the newSelection.value object. Finally, this is what is shown in the input.

     

    Please, test the sample on your side and if you require any further assistance on the matter, please let me know.

    Sincerely,
    Bozhidara Pachilova
    Associate Software Developer