|
div class="col-lg-12 control-section">
<div class="control-wrapper">
<div class="padding-top">
<SfDropDownList TItem="TransactionType" TValue="string" DataSource="@TransactionTypes">
<DropDownListEvents TItem="TransactionType" TValue="string" ValueChange="ChangeTransactionType"></DropDownListEvents>
<DropDownListFieldSettings Text="CountryName" Value="CountryId"></DropDownListFieldSettings>
</SfDropDownList>
</div>
<div class="padding-top">
<SfDropDownList Enabled="@EnableCategoriesDropDown" TValue="string" TItem="CategoryResult" @bind-Value="@CategoryValue" Query="@CategoryQuery" DataSource="@Categories">
<DropDownListFieldSettings Text="StateName" Value="StateId"></DropDownListFieldSettings>
</SfDropDownList>
</div>
</div>
</div>
@code {
public bool EnableCategoriesDropDown = false;
public string CategoryValue { get; set; } = null;
public Query CategoryQuery { get; set; } = null;
public void ChangeTransactionType(Syncfusion.Blazor.DropDowns.ChangeEventArgs<string, TransactionType> args)
{
this.EnableCategoriesDropDown = true;
this.CategoryQuery = new Query().Where(new WhereFilter() { Field = "CountryId", Operator = "equal", value = args.Value, IgnoreCase = false, IgnoreAccent = false });
this.CategoryValue = null;
}
...
} |
|
<SfGrid DataSource="@GridData" Toolbar="@(new string[] {"Add", "Edit", "Delete", "Update", "Cancel"})" AllowPaging="true">
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="@EditMode.Dialog" Dialog="DialogParams">
<Template>
@{
var transaction = (context as TransactionDetails);
<DialogEditComponent Transaction="transaction"></DialogEditComponent>
}
</Template>
</GridEditSettings>
<GridPageSettings PageSizes="true"></GridPageSettings>
<GridEvents OnActionComplete="ActionComplete" TValue="TransactionDetails"></GridEvents>
</SfGrid>
[DialogEditComponent.razor]
|
Hi Vignesh ,
I download above sample and try it, found when Add and Edit mode seems not work.
Test Case1 . original environment : vs2022 + .NET Core 3.1+ Syncfusion 18.3.0.44 --->run as follows caption screen.
Test Case 2 . my current new enviorment : .vs2022 + Net 7.0 + Syncfusion 24.2.7--->Add and Edit Dialog not display.
Question 1 : For my current new enviorment, how to adjust the code ?
Question 2 : if the Cascading in Dropdown List is packaged into a public Blazor component for communication other Blazor pages , Is there a sample for reference or key points to note.
Thanks!
Jacky
Add mode
Edit mode
Hi
Jackey,
Based on your requirement, we have
modified the sample Net7 and Syncfusion Blazor NuGet version 24.2.7. Kindly
refer to the modified sample for your reference. Regarding the requirement,
here is to create a public Blazor component that encapsulates the Syncfusion
Dropdown List component and allows for communication with other Blazor pages.
This likely involves utilizing Blazor's parameters feature to pass data
or state from the parent component (the page where the Dropdown List component
is used) to its child components (other Blazor pages).
|
@using Syncfusion.Blazor.DropDowns @using Syncfusion.Blazor.Data
@typeparam TVal; @typeparam TItemss;
<SfDropDownList TValue="TVal" TItem="TItemss" Query="DropDownQuery" Enabled="@IsEnable" ShowClearButton="true" DataSource="@Data"> <DropDownListFieldSettings Text="Name" Value="Code"></DropDownListFieldSettings> <DropDownListEvents TItem="TItemss" TValue="TVal" ValueChange="valuechangevent"></DropDownListEvents> </SfDropDownList>
@code {
[Parameter] public IEnumerable<TItemss> Data { get; set; }
private TVal _value { get; set; } [Parameter] public string ID { get; set; }
[Parameter] public Query DropDownQuery { get; set; }
[Parameter] public bool IsEnable { get; set; } = true;
[Parameter] public string FieldSettingText { get; set; }
[Parameter] public string FieldSettingName { get; set; }
[Parameter] public TVal Value { get => _value; set { if (!EqualityComparer<TVal>.Default.Equals(value, _value)) { _value = value; ValueChanged.InvokeAsync(value); } } } [Parameter] public EventCallback<TVal> ValueChanged { get; set; }
[Parameter] public EventCallback<ChangeEventArgs<TVal,TItemss>> valuechangevent { get; set; }
} |
Reference:
https://blazor.syncfusion.com/documentation/datagrid/how-to/cascading-dropdownlist-with-grid-editing
Regards,
Prathap S