- Home
- Forum
- ASP.NET Web Forms
- How to get the selected item ID (SelectValueByKey)from Autocomplete in Client Side Event
How to get the selected item ID (SelectValueByKey)from Autocomplete in Client Side Event
Thanks for contacting Syncfsuion Support.
We can get the selected item id in “ClientSideOnSelect” event argument in autocomplete.Please refer to the following code example for the same,
<code>
<ej:Autocomplete ID="categoryGrouping" Width="205px" ShowPopupButton="true" FilterType="Contains" HighlightSearch="true" runat="server" WatermarkText="Select a category" ClientSideOnSelect="OnSelect"/>
<script type="text/javascript">
function OnSelect(args)
{
alert(args.key);
}
</script>
</code>
We have prepared a sample based on this and you can refer to it from the following link:
Sample: Sample
Also, you can use “getSelectedItem()” method in “ClientSideOnSelect” event to get the selected item id. Refer to the following code example for the same,
<code>
<ej:Autocomplete ID="categoryGrouping" Width="205px" ShowPopupButton="true" FilterType="Contains" HighlightSearch="true" runat="server" WatermarkText="Select a category" ClientSideOnSelect="OnSelect"/>
<script type="text/javascript">
function OnSelect(args)
{
var autocompleteObj = $("#<%=categoryGrouping.ClientID%>").data("ejAutocomplete");
alert(autocompleteObj.getSelectedItems()[0].ID);
}
</script>
</code>
To know more about properties, methods and events of Autocomplete component, refer to the following API link,
http://help.syncfusion.com/js/api/ejautocomplete
Please let us know if you have any queries.
Regards,
Kasithangam
Thanks for your update.
Please let us know if you have any other quires.
Regards,
Ragunath M
- 3 Replies
- 3 Participants
-
PR Pratheep
- Oct 14, 2015 02:36 AM UTC
- Oct 15, 2015 10:06 AM UTC