Hi JaeHyeong,
Greetings from Syncfusion support.
We would like to inform you that, this is the default behavior of editing in Grid. When enter key is pressed in edit form, this will trigger the save action in Grid.
Based on your scenario, we suggest you to use the EditTemplate feature of Grid to overcome this default behavior. With this, we suggest you to render a SfTextBox for the corresponding columns and bind @onkeypress event for the component. Now if enter key pressed for SfTextBox, this will enable the PreventUpdate flag variable.
Based on this PreventUpdate flag variable, we suggest you to cancel the save action by using “args.Cancel”. Please refer the codes below,
|
<SfGrid DataSource="@Orders" ...>
...
<GridEvents OnActionBegin="OnActionBegin" TValue="Order"></GridEvents>>
<GridColumns>
<EditTemplate>
<SfTextBox ID="CustomerID" Placeholder='CustomerID' FloatLabelType='@FloatLabelType.Always' @bind-Value="@((context as Order).CustomerID)" @onkeypress="@KeyPressHandler">
</SfTextBox>
</EditTemplate>
</GridColumn>
</GridColumns>
</SfGrid>
private bool PreventUpdate { get; set; } = false;
private void KeyPressHandler(KeyboardEventArgs args)
{
if (args.Key == "Enter")
{
PreventUpdate = true;
}
else
{
PreventUpdate = false;
}
}
public void OnActionBegin(ActionEventArgs<Order> args)
{
if (args.RequestType == Syncfusion.Blazor.Grids.Action.Save && PreventUpdate)
{
args.Cancel = true;
PreventUpdate = false;
}
}
|
We are also attaching the sample for your reference. Please download the sample from the link below,
Please get back to us if you need further assistance.
Regards,
Renjith Singh Rajendran