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. Image for the cookie policy date

How can I get the id of the first item by pressing Enter?

How can I get the id of the first item by pressing Enter?
ex.:
DataSource:
a1 (id 0)
a2 (id 1)
a3 (id 2)
b1 (id 3)
b2 (id 4)
b3 (id 5)

Pressing B is shown:
b1
b2
b3

Pressing Enter would get:
id=3

3 Replies

SP Sureshkumar P Syncfusion Team January 27, 2020 09:56 AM UTC

Hi Marcelo, 
 
Greetings from Syncfusion support. 
 
You can get the filtered value in the actioncomplete event and store it in the global variable. So, when you press the enter key you can get the first value as mentioned below code snippet, 
 
public void keydown(KeyboardEventArgs args) 
{ 
    if(args.Code == "Enter") 
    { 
        Console.WriteLine(value.Code); 
    } 
} 
 
public Countries value { get; set; } 
 
public void onActionComplete(ActionCompleteEventArgs args) 
{ 
    value =  Newtonsoft.Json.JsonConvert.DeserializeObject<List<Countries>>(args.Result.ToString()).ToList<Countries>().FirstOrDefault(); 
 
} 
 
 
We have created a sample based on your requirement. please find the sample here: https://www.syncfusion.com/downloads/support/directtrac/general/ze/KeyDownGetValue-1521680672  
 
Regards, 
Sureshkumar P 



MO Marcelo Oliveira Santos January 27, 2020 07:10 PM UTC

Thanks Sureshkumar P, it works perfectly.

Regards,
Marcelo


SP Sureshkumar P Syncfusion Team January 28, 2020 06:30 AM UTC

Hi Marcelo, 
 
 
Regards, 
Sureshkumar P 


Loader.
Live Chat Icon For mobile
Up arrow icon