<EjsDropDownList ref="ddlSupplier" ID="supplierDropDown" DataSource="@_supplierList.supList" Change="@onSupplierChange">
<DropDownListFieldSettings Text="Name" Value="SID"></DropDownListFieldSettings>
</EjsDropDownList>
<EjsDropDownList ref="ddlProduct" ID="supplierProductsDropDown">
<DropDownListFieldSettings Text="Name" Value="PID"></DropDownListFieldSettings> </EjsDropDownList>
@functions{
EjsDropDownList ddlSupplier;
EjsDropDownList ddlProduct;
supplierList _supplierList = new supplierList();
supplierProductList _supplierProductList = new supplierProductList();
public void onSupplierChange(object args)
{
//Deserialized the change event args using Newton soft.
DropDownChangeArgs eventArgs = JsonConvert.DeserializeObject<DropDownChangeArgs>(args as string);
ddlProduct.Value = null;
//Filter the producted value based on suppliers
ddlProduct.DataSource = this._supplierProductList.supProdcutList.Where(item => item.SID == eventArgs.Value);
ddlProduct.DataBind();
}
} |
<EjsDropDownList ID="supplierDropDown" DataSource="@supplierList.supSupplierList" Change="@OnSupplierChange">
<DropDownListFieldSettings Text="Name" Value="SID"></DropDownListFieldSettings>
</EjsDropDownList>
<EjsDropDownList ID="supplierProductsDropDown" DataSource="@supplierProductList.supProductList" Value=@value Enabled="@enabled" Query="@query">
<DropDownListFieldSettings Text="Name" Value="PID"></DropDownListFieldSettings>
</EjsDropDownList>
@code{
SupplierList supplierList =new SupplierList();
SupplierProductList supplierProductList=new SupplierProductList();
public string query = null;
public bool enabled = false;
public string value= null;
public void OnSupplierChange(ChangeEventArgs eventArgs)
{
this.value=null;
this.enabled = true;
this.query = "new ej.data.Query().select(['Name', 'SID', 'PID']).where('SID', 'equal', "+eventArgs.Value+")";
this.StateHasChanged();
}
} |
<EjsDropDownList ID = "supplierDropDown" DataSource="@supplierList.supSupplierList" ValueChange="@OnSupplierChange">
<DropDownListFieldSettings Text = "Name" Value="SID"></DropDownListFieldSettings >
</EjsDropDownList >
<EjsDropDownList ID = "supplierProductsDropDown" DataSource="@supplierProductList.supProductList" Value=@Value Enabled = "@Enabled" Query="@Query">
<DropDownListFieldSettings Text = "Name" Value="PID"></DropDownListFieldSettings >
</EjsDropDownList>
@code{
SupplierList supplierList = new SupplierList();
SupplierProductList supplierProductList = new SupplierProductList();
public string Query { get; set; } = null;
public bool Enabled { get; set; } = false;
public string Value { get; set; } = null;
public void OnSupplierChange(@Syncfusion.EJ2.Blazor.DropDowns.ChangeEventArgs eventArgs)
{
this.Value = null;
this.Enabled = true;
this.Query = "new ej.data.Query().select(['Name', 'SID', 'PID']).where('SID', 'equal', " + eventArgs.Value + ")";
this.StateHasChanged();
}
…..
} |
Hi Ryan,This problem happened because we changed the name of the nuget package name RazorComponents to Blazor. So, we suggest you to upgrade the latest nuget in your application to run the sample without any issues and change the package name to @using Syncfusion.EJ2.Blazor on your import.razor page, alter the event name to ValueChange . Please find the code snippet and sample below
<EjsDropDownList ID = "supplierDropDown" DataSource="@supplierList.supSupplierList" ValueChange="@OnSupplierChange"><DropDownListFieldSettings Text = "Name" Value="SID"></DropDownListFieldSettings ></EjsDropDownList ><EjsDropDownList ID = "supplierProductsDropDown" DataSource="@supplierProductList.supProductList" Value=@Value Enabled = "@Enabled" Query="@Query"><DropDownListFieldSettings Text = "Name" Value="PID"></DropDownListFieldSettings ></EjsDropDownList>@code{SupplierList supplierList = new SupplierList();SupplierProductList supplierProductList = new SupplierProductList();public string Query { get; set; } = null;public bool Enabled { get; set; } = false;public string Value { get; set; } = null;public void OnSupplierChange(@Syncfusion.EJ2.Blazor.DropDowns.ChangeEventArgs eventArgs){this.Value = null;this.Enabled = true;this.Query = "new ej.data.Query().select(['Name', 'SID', 'PID']).where('SID', 'equal', " + eventArgs.Value + ")";this.StateHasChanged();}…..}Sample Link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/WebApplication31895365051Release Notes: https://ej2.syncfusion.com/aspnet-core-blazor/documentation/release-notes/17.2.28/#commonNote: We have prepared the sample using latest version 17.2.0.30-beta with .NET Core SDK version 3.0.0-Preview6.Regards,Gopi G.
@using Syncfusion.EJ2.Blazor.DropDowns
<EjsDropDownList ID="supplierDropDown" TValue="string" DataSource="@supplierList.supSupplierList">
<DropDownListEvents TValue="string" ValueChange="@OnSupplierChange"></DropDownListEvents>
<DropDownListFieldSettings Text="Name" Value="SID"></DropDownListFieldSettings>
</EjsDropDownList>
<EjsDropDownList ID="supplierProductsDropDown" DataSource="@supplierProductList.supProductList" Value=@Value Enabled="@Enabled" Query="@Query">
<DropDownListFieldSettings Text="Name" Value="PID"></DropDownListFieldSettings>
</EjsDropDownList>
@code{
public void OnSupplierChange(Syncfusion.EJ2.Blazor.DropDowns.ChangeEventArgs<string> eventArgs)
{
this.Value = null;
this.Enabled = true;
this.Query = "new ej.data.Query().select(['Name', 'SID', 'PID']).where('SID', 'equal', " + eventArgs.Value + ")";
this.StateHasChanged();
}
} |
<link rel='nofollow' href="https://cdn.syncfusion.com/ej2/17.3.29/material.css" rel="stylesheet" />
<script src="https://cdn.syncfusion.com/ej2/17.3.29/dist/ej2.min.js"></script>
<script src="https://cdn.syncfusion.com/ej2/17.3.29/dist/ejs.interop.min.js"></script> |