|
<SfGrid AllowPaging="true" DataSource="@Orders" Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update" })">
<GridEvents OnActionBegin="OnBegin" TValue="Customer"></GridEvents>
<GridEditSettings AllowEditing="true" AllowDeleting="true" AllowAdding="true" Mode="@EditMode.Normal"></GridEditSettings>
<GridColumns>
<GridColumn Field=@nameof(Customer.Id) HeaderText="Order ID" IsPrimaryKey="true" TextAlign="@TextAlign.Center" Width="140"></GridColumn>
<EditTemplate>
<SfDropDownList ID="FullName" TItem="Customer" TValue="string" @bind-Value="@((context as Customer).FullName)" DataSource="@Orders">
<DropDownListFieldSettings Value="FullName"></DropDownListFieldSettings>
<DropDownListEvents ValueChange="OnChange" TItem="Customer" TValue="string"></DropDownListEvents>
</SfDropDownList>
</EditTemplate>
</GridColumn>
<GridColumn Field=@nameof(Customer.Address) HeaderText="Freight" Width="140" TextAlign="@TextAlign.Right">
<EditTemplate>
@{
Address = (context as Customer).Address;
<SfTextBox @ref="TxtBox" ID="Address" @bind-Value="@Address"></SfTextBox>
}
</EditTemplate>
</GridColumn>
</GridColumns>
</SfGrid>
@code{
SfTextBox TxtBox { get; set; }
public List<Customer> Orders { get; set; }
public string Address { get; set; }
public void OnBegin(ActionEventArgs<Customer> Args)
{
if(Args.RequestType == Syncfusion.Blazor.Grids.Action.Save)
{
Args.Data.Address = TxtBox.Value;
}
}
public void OnChange(ChangeEventArgs<string, Customer> Args)
{
TxtBox.Value = Args.Value + 1.ToString();
TxtBox.FocusIn();
}
|