We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Feature Request: Add OnKeyPress event or an attribute to handle ENTER key presses

Thread ID:

Created:

Updated:

Platform:

Replies:

151234 Feb 4,2020 04:40 PM UTC Feb 5,2020 04:09 PM UTC Blazor 1
loading
Tags: ComboBox
Scott Peal
Asked On February 4, 2020 04:40 PM UTC

I am not able to detect the user hitting the enter key after typing text into the combobox. Ideally, we would either have an OnKeyPress event or an attribute added to the control. I prefer the attribute approach with an attribute named "HandleEnterAsValueChange". Note, this may or may not be part of the ValueChange bug being rolled out tomorrow.

Behavior:
- If user enters text and the value exists in the list of values in the control, then call the ValueChanged event.
- If user enters text and the value does not exist, do nothing

Thanks...VR Architect

Sevvandhi Nagulan [Syncfusion]
Replied On February 5, 2020 04:09 PM UTC

Hi Scott, 

Greetings from Syncfusion support. 

Solution 1: We have checked the reported requirement. We would like to inform you that when you enable the filtering event, the change event will be triggered based on the filtered value while pressing the enter key. If you don't have any records matched, then the change event will not be trigger. 
Solution2: We can achieve the same functionalities using action complete and key-down events. You can enable the filtering, and get the filtered data in the action complete event. 
 
Query: If the user enters text and the value exists in the list of values in the control, then call the ValueChanged event. 

You can get the value in the key down event as mentioned below code snippet, 

public void keydown(KeyboardEventArgs args) 
    { 
        if(args.Code == "Enter" && value.Count != 0) 
        { 
            Console.WriteLine(value[0].Code); 
        } 
        else if (args.Code == "Enter" && value.Count == 0) 
        { 
            Console.WriteLine("No records found"); 
        } 
    } 
 
    public List<Countries> value { get; set; } 
 
    public void onActionComplete(ActionCompleteEventArgs args) 
    { 
        value =  Newtonsoft.Json.JsonConvert.DeserializeObject<List<Countries>>(args.Result.ToString()).ToList<Countries>(); 
 
    } 
    private void onChange(Syncfusion.EJ2.Blazor.DropDowns.ChangeEventArgs<string> args) 
    { 
         
     

Query : If user enters text and the value does not exist, do nothing 

If you do not have any matching record , then value will be returned. 
 
Regards, 
Sevvandhi N 



CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon