|
<div class="col-lg-12 control-section">
<div class="control-wrapper">
<div class="padding-top">
<SfComboBox TValue="string" TItem="Countries" Placeholder="Select a country" AllowCustom="false" PopupHeight="auto" DataSource="@Country">
<ComboBoxEvents TValue="string" TItem="Countries" ValueChange="ChangeCountry"></ComboBoxEvents>
<ComboBoxFieldSettings Text="CountryName" Value="CountryId"></ComboBoxFieldSettings>
</SfComboBox>
</div>
<div class="padding-top">
<SfComboBox TValue="string" TItem="State" Enabled="@EnableStateDropDown" @bind-Value="@StateValue" Placeholder="Select a state" Query="@StateQuery" AllowCustom="false" PopupHeight="auto" DataSource="@States">
<ComboBoxEvents TValue="string" TItem="State" ValueChange="ChangeState"></ComboBoxEvents>
<ComboBoxFieldSettings Text="StateName" Value="StateId"></ComboBoxFieldSettings>
</SfComboBox>
</div>
</div>
</div>
@code {
. . .
public void ChangeCountry(Syncfusion.Blazor.DropDowns.ChangeEventArgs<string, Countries> args)
{
this.EnableStateDropDown = !string.IsNullOrEmpty(args.Value);
this.EnableCitytDropDown = false;
this.StateQuery = new Query().Where(new WhereFilter() { Field = "CountryId", Operator = "equal", value = args.Value, IgnoreCase = false, IgnoreAccent = false });
this.StateValue = null;
}
public void ChangeState(Syncfusion.Blazor.DropDowns.ChangeEventArgs<string, State> args)
{
this.EnableCitytDropDown = !string.IsNullOrEmpty(args.Value);
}
. . .
}
|
|
<SfGrid @ref="GridRef" AllowPaging="true" DataSource="@GridData" ShowColumnChooser="true" Toolbar="@(new List<string>() { "Add","Edit","Delete","Update","Cancel" })">
<GridEditSettings AllowEditing="true" AllowDeleting="true" AllowAdding="true" Mode="@EditMode.Batch"></GridEditSettings>
<GridColumns>
<GridColumn Field=@nameof(Orders.OrderID) HeaderText="Order ID" IsPrimaryKey="true" TextAlign="@TextAlign.Center" Width="140"></GridColumn>
<GridColumn Field=@nameof(Orders.Freight) HeaderText="Freight" EditType="EditType.NumericEdit" Format="C2" Width="140" TextAlign="@TextAlign.Right"></GridColumn>
<GridColumn Field=@nameof(Orders.OrderDate) HeaderText="Order Date" EditType="EditType.DatePickerEdit" Format="d" Type="ColumnType.Date" Width="160"></GridColumn>
<GridColumn Field=@nameof(Orders.ShipCountry) HeaderText="Ship Country" EditType="EditType.DropDownEdit" Width="150">
<EditTemplate>
<SfComboBox ID="ShipCountry" Placeholder="Select a Country" TItem="string" TValue="string" @bind-Value="@((context as Orders).ShipCountry)" DataSource="@Countries">
<ComboBoxEvents TValue="string" TItem="string" ValueChange="ValueChange"></ComboBoxEvents>
<ComboBoxFieldSettings Text="ShipCountry" Value="ShipCountry"></ComboBoxFieldSettings>
</SfComboBox>
</EditTemplate>
</GridColumn>
<GridColumn Field=@nameof(Orders.ShipState) HeaderText=" Ship State" EditType="EditType.DropDownEdit" Width="150">
<EditTemplate>
<SfComboBox ID="ShipState" Placeholder="Select a State" TItem="string" TValue="string" @bind-Value="@((context as Orders).ShipState)" DataSource="@States">
<ComboBoxFieldSettings Text="ShipState" Value="ShipState"></ComboBoxFieldSettings>
</SfComboBox>
</EditTemplate>
</GridColumn>
</GridColumns>
</SfGrid>
public void ValueChange(@Syncfusion.Blazor.DropDowns.ChangeEventArgs<string, 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" }; } } |
Hi,
i'm trying to do something like that in a generic Component.
Here are my 2 combobox in 2 columns od a datagrid : When I edit a row of the grid and select an item in the first combobox, the ValueChange(...) is correctly fired but no changes in lookupChildren (DataSource of the second one) is shown in the second combo in the grid
Someone can tell me if there's something wrong in the definition of the GridForeignColumns ?
<GridForeignColumn Field="ID1" HeaderText="Header1"
EditType="EditType.DropDownEdit" TextAlign="TextAlign.Left"
ForeignKeyField="Id"
ForeignKeyValue="Description"
ForeignDataSource="@lookups">
<EditTemplate>
<SfComboBox ID="IdCdC1" Placeholder="Select a CdC "
TItem="LookupItem<int>" TValue="int"
DataSource="@lookups">
<ComboBoxFieldSettings Text="Description" Value="Id"></ComboBoxFieldSettings>
<ComboBoxEvents TValue="int" TItem="LookupItem<int>" ValueChange="ValueChange"></ComboBoxEvents>
</SfComboBox>
</EditTemplate>
</GridForeignColumn>
<GridForeignColumn Field="ID2" HeaderText="Header2"
EditType="EditType.DropDownEdit" TextAlign="TextAlign.Left"
ForeignKeyField="Id"
ForeignKeyValue="Description"
ForeignDataSource="@lookupChildren">
<EditTemplate>
<SfComboBox ID="IdCdC2" Placeholder="Select a CdC2"
TItem="LookupItem<int>" TValue="int"
DataSource="@lookupChildren">
<ComboBoxFieldSettings Text="Description" Value="Id"></ComboBoxFieldSettings>
</SfComboBox>
</EditTemplate>
</GridForeignColumn>
public List<LookupItem<int>> lookups;
public List<LookupItem<int>> lookupChildren { get; set; }
public void ValueChange(@Syncfusion.Blazor.DropDowns.ChangeEventArgs<int, LookupItem<int>> args)
{
lookupChildren.Clear();
lookupChildren.Add(new LookupItem<int>(1, "1"));
lookupChildren.Add(new LookupItem<int>(2, "2"));
//*** or load something else in children ***
}
public class LookupItem<T>
{
public T Id { get; set; }
public string Description { get; set; }
}
thnks a lot, m.
Hi Michele,
Based on the reported problem We would like to inform you that we have
prevented unwanted rendering of the Grid component during the external action
for better performance. So we suggest you use PreventRender(false) on
the value change event to
reflect the changes in the DataGrid. Kindly refer to the attached code snippet
for your reference.
|
<SfGrid @ref="Grid"……>
</SfGrid> { lookupChildren.Clear(); lookupChildren.Add(new LookupItem<int>(1, "1")); lookupChildren.Add(new LookupItem<int>(2,
"2")); } } |
If you still face difficulties, then kindly share us an simple issue reproduceable sample. It will be very helpful for us to validate the reported issue.
Regards,
Prathap S