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

DropDownList events not firing

Thread ID:

Created:

Updated:

Platform:

Replies:

150811 Jan 21,2020 04:06 AM UTC Jan 21,2020 04:37 PM UTC Blazor 1
loading
Tags: Dropdown List
Dan
Asked On January 21, 2020 04:15 AM UTC

There appear to be lots of events on EjsDropDownList, but none, of those I tried, seem to work. In the following code, I am trying to subscribe to 3 events, `OnSelect`, `onchange` and `ValueChange`. I'm updating an on-screen message to see what events are hit. In the below case, only `ValueChange` is hit. Why are the other ones not being hit?

```
@page "/"

@using Syncfusion.EJ2.Blazor.DropDowns

                 TValue="string" 
                 TItem="Supplier" 
                 DataSource="@supplierList.supSupplierList"
                 OnSelect="@OnSelect"
                 @onchange="@OnChange">
   
   
Supplier ID: @Value

@Message
@code{
    public string Message { get; set; } = "";
    SupplierList supplierList = new SupplierList();
    public string Value { get; set; } = null;
    public void OnSupplierChange(Syncfusion.EJ2.Blazor.DropDowns.ChangeEventArgs eventArgs)
    {
        Message += "OnSupplierChange";
        this.Value = eventArgs.Value;
        this.StateHasChanged();
    }

    public void OnSelect()
    {
        Message += "OnSelect";
        StateHasChanged();
    }

    public void OnChange()
    {
        Message += "OnChange";
        StateHasChanged();
    }

    public class SupplierList
    {
        public List supSupplierList = new List
        {
            new Supplier { Name ="Paul Henriot", SID= 101 },
            new Supplier  { Name= "Karin Josephs", SID= 102 },
            new Supplier { Name ="Mario Pontes", SID= 103 },
            new Supplier  { Name= "Mary Saveley", SID= 104 }
        };
    }

    public class Supplier
    {
        public string Name { get; set; }
        public int SID { get; set; }
    }
}
```

Ultimately, I'd like to wrap the above into a (more specific DropDownList) component and allow parent components to be notified when the selection has changed.

I'm open to alternate ways of doing this and any best practices. Thanks.


Sevvandhi Nagulan [Syncfusion]
Replied On January 21, 2020 04:37 PM UTC

Hi Dan, 

Greetings from Syncfusion support. 

We have checked the reported requirement. We would like to inform that we have provided wrapper component support to DropDownList. So we have provided these native events support in our Blazor source. So, you can use the ValueChange and OnValueSelect event instead select and change event. Kindly refer the below code, 

[index.razor] 

<EjsDropDownList TValue="string" Placeholder="e.g. Australia" TItem="Countries" DataSource="@Country"> 
        <DropDownListFieldSettings Value="Name"></DropDownListFieldSettings> 
        <DropDownListEvents TValue="string" OnValueSelect="OnSelect" ValueChange="OnChange"></DropDownListEvents> 
    </EjsDropDownList> 


Please find the sample below, 

 
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