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

DropDownList events not firing

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.


1 Reply

SN Sevvandhi Nagulan Syncfusion Team 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 


Loader.
Up arrow icon