Hello,
With the grid EditTemplate and also when including input fields in a DetailTemplate, a multiline text field doesn't allow the enter button to be pressed. Pressing enter causes the text field to lose focus. This can be replicated using the example in the docs Editing in Blazor DataGrid Component | Syncfusion with the CustomEditorParams, setting the text field to multiline still doesnt allow newlines to be entered.
Thanks.
|
[Index.razor]
@inject IJSRuntime Runtime
<SfGrid DataSource="@OrderData" Toolbar=@ToolbarItems>
<GridEditSettings AllowEditing="true" AllowAdding="true" AllowDeleting="true" Mode="EditMode.Normal"></GridEditSettings>
<GridColumns>
<GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" IsPrimaryKey="true" TextAlign="TextAlign.Center" Width="120"></GridColumn>
<GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer ID" TextAlign="TextAlign.Center" Width="130">
<EditTemplate>
<SfTextBox ID="CustomerID" OnFocus="Focus" ShowClearButton="false" Multiline="true" @bind-Value="((context as Order).CustomerID)">
</SfTextBox>
</EditTemplate>
</GridColumn>
. ..
</GridColumns>
</SfGrid>
@code{
public void Focus()
{
//pass ID(column name) of multiline textbox
Runtime.InvokeVoidAsync("EditKeyDown", "CustomerID");
}
. ..
} |
|
[JavaScript.js]
function EditKeyDown(id) {
document.getElementById(id).addEventListener("keydown", function (e) {
if (e.key == "Enter") {
e.stopPropagation();
}
});
} |
|
[_Host.cshtml]
<head>
. ..
<link rel='nofollow' href="_content/Syncfusion.Blazor/styles/material.css" rel="stylesheet" />
<script src="JavaScript.js"></script>
</head> |
Hello,
Many thanks for this, it has fixed our issue.
Thanks again.
Ben.