|
<div class="padding-top">
<SfDropDownList TValue="string" TItem="city" DataSource="@cites">
<DropDownListFieldSettings Text="StartsValue" Value="StartsValue"></DropDownListFieldSettings>
<DropDownListEvents TValue="string" ValueChange="OnCityChange"></DropDownListEvents>
</SfDropDownList>
</div>
<div class="padding-top">
<SfDropDownList TValue="string" TItem="Countries" DataSource="@CountryData">
<DropDownListFieldSettings Text="Name" Value="Name"></DropDownListFieldSettings>
</SfDropDownList>
</div>
public async Task OnCityChange(ChangeEventArgs<string> args)
{
CountryData = await ownservice.GetDataAsync(args.Value);
}
|
|
public class CountryService
{
public async Task<List<Countries>> GetDataAsync(string value)
{
List<Countries> Country = new List<Countries>
{
new Countries() { Name = "Australia", ID = "AU" },
new Countries() { Name = "Bermuda", ID = "BM" },
new Countries() { Name = "Canada", ID = "CA" },
new Countries() { Name = "Cameroon", ID = "CM" },
new Countries() { Name = "Denmark", ID = "DK" },
new Countries() { Name = "France", ID = "FR" },
new Countries() { Name = "Finland", ID = "FI" }
};
if (value.Length > 0)
{
return Country.Where(a => a.Name.StartsWith(value)).ToList();
}
else
{
return await Task.FromResult(Country);
}
}
|
|
<SfGrid DataSource="@GridData" Toolbar="@(new string[] {"Add", "Edit" ,"Delete","Update","Cancel" })">
<GridEvents OnActionBegin="OnActionBegin" TValue="OrdersDetails"></GridEvents>
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="@EditMode.Dialog">
<Template>
@{
var Order = (context as OrdersDetails);
<div>
. . .
<div class="form-row">
<div class="form-group col-md-6">
<label class="e-float-text e-label-top">Ship Country</label>
<SfDropDownList ID="ShipCountry" Placeholder="Select a Country" TItem="string" TValue="string" @bind-Value="@((context as OrdersDetails).ShipCountry)" DataSource="@Countries">
<DropDownListEvents TValue="string" ValueChange="ValueChange"></DropDownListEvents>
<DropDownListFieldSettings Text="ShipCountry" Value="ShipCountry"></DropDownListFieldSettings>
</SfDropDownList>
</div>
<div class="form-group col-md-6">
<label class="e-float-text e-label-top">Ship State</label>
<SfDropDownList ID="ShipState" Placeholder="Select a State" TItem="string" Enabled="@Enabled" TValue="string" @bind-Value="@((context as OrdersDetails).ShipState)" DataSource="@States">
<DropDownListFieldSettings Text="ShipState" Value="ShipState"></DropDownListFieldSettings>
</SfDropDownList>
</div>
</div>
</div>
}
</Template>
</GridEditSettings>
<GridColumns>
. . .
</GridColumns>
</SfGrid>
@code{
public bool Enabled = false;
public List<string> Countries = new List<string>() { "United States", "Australia" };
public List<string> States = new List<string>() { "New York", "Virginia", "Washington", "Queensland", "Tasmania", "Victoria" };
. . .
public void ValueChange(@Syncfusion.Blazor.DropDowns.ChangeEventArgs<string> args)
{
if (args.Value == "United States")
{
States = new List<string>() { "New York", "Virginia", "Washington" };
}
else if (args.Value == "Australia")
{
States = new List<string>() { "Queensland", "Tasmania", "Victoria" };
}
Enabled = true;
}
public void OnActionBegin(ActionEventArgs<OrdersDetails> args)
{
if (args.RequestType == Syncfusion.Blazor.Grids.Action.BeginEdit || args.RequestType == Syncfusion.Blazor.Grids.Action.Add)
{
Enabled = false;
}
}
}
|
Hi Rahul,
i tried your last sample in a current environment (net6.0,v20.x) and it worked almost with one exception.
The cascading behaviour did'nt working if you doble-click the records in the grid.
if you try "Add" or "Edit" from ToolBar everything works fine, but not when you direct double-click it.
I figured the same problem in my project, because im adding template buttons per record to edit it and it comes to exact issue like at yours double-clicking.
What is the difference between these procedures? or is it a bug?
Regards
Stefan
Hi Stefan,
Greetings from Syncfusion support.
We had checked this scenario by creating a sample in our latest version(20.1.0.59).But we are not able to reproduce the reported issue at our end. We are attaching the sample in this ticket.
Kindly download and refer the sample in this ticket. If you are still facing the reported issue, then the following details would be helpful for us to proceed further.
Above request details will be very helpful for us to further validate the reported query at our end and provide solution as easy as possible.
Regards,
Sarveswaran PK
Hello Sarveswaran,
after checking and altering your example (to EditMode.Dialog :-) i found the missing piece. It's the command
GridRef.PreventRender(false);
If it is not set, the cascading did'nt work, but only if you double-click a record.
if you choose the record and click the Toolbar Edit-Button, it works also without PreventRender.
Maybe you could reproduce it, if you set the GridEditSetting Mode to EditMode.Dialog und comments out the PreventRender command in ChangeValue method.
Then test both possibilities to edit a record by changing the cities, maybe you will see the same results.
Nevertheless thanks for your great support
For me the issue is solved.
Regards
Stefan
Hi Stefan,
Welcome
We are glad to hear that your query has been resolved by you.
Please get back to us if you need any further assistance.
Regards,
Sarveswaran PK