How get the id/name of the autocomplete object or send a parameter on select

Hi!

I need to know what autocomplete object was inkoved when the user clicks an option of autocomplete. I need to get the id/name.

Or, also another option is to send a parameter when the user clicks an option of autocomplete to know what was invoked.

The index 3 (the idea is make it dinamically) is what i want to send as parameter or get the name/id of the autocomplete:

@Html.EJ().AutocompleteFor(x => x[i].AnswerText).Datasource(Model[i].lstAnswers).AutocompleteFields(f => f.Text("AnswerText").Key("AnswerID")).Width("200").EmptyResultText("No existe").ClientSideEvents(e => e.Select("OnSelect"))

function OnSelect(arg) {
   $("input[name*='[3].AnswerSelected']").val(arg.key);
}

Thanks!

3 Replies

KV Karthikeyan Viswanathan Syncfusion Team August 10, 2018 08:38 AM UTC

Hi Daniel, 

Thanks for contacting Syncfusion support. 

Based on your scenario, You can get the generic ID/Name of autocomplete by using this.element. this.element is a generic solution for all autocomplete. 

Please find the below code example: 

<code> 

<script type="text/javascript"> 
    function OnSelect(args) { 
        console.log(this.element[0].id); 
        console.log(this.element[0].name) 
    } 
</script> 
</code> 


Regards, 
Karthikeyan V. 



DA Daniel August 10, 2018 02:35 PM UTC

Perfect! This is that I need.

Thanks for the assistance.

Regards!



KV Karthikeyan Viswanathan Syncfusion Team August 11, 2018 09:35 AM UTC

Hi Daniel,  
We are glad to hear that your issue has been resolved.    
Regards,  
Karthikeyan V.  


Loader.
Up arrow icon