Grid Inline Edit Keyboard Navigation not updating UI until field loses focus 2nd time.
I am navigating through arrow keys for editing grid.
Attachment: ServerApp_e134fb8f.zip
But the UI is not being updated until field loses focus 2nd time. (See the video).
Github repo - https://github.com/chjayakrishnajk/Syncfusion_Grid
Attachment: ServerApp_e134fb8f.zip
SIGN IN To post a reply.
4 Replies
1 reply marked as answer
RS
Renjith Singh Rajendran
Syncfusion Team
June 10, 2021 09:06 AM UTC
Hi JayaKrishna,
Greetings from Syncfusion support.
We suggest you to ensure to update the cell value using UpdateCell method before calling the EditCell to overcome the reported behavior. We have modified the sample for your convenience, please download the working sample from link below,
References :
Please refer and modify as like the below highlighted codes in your application.
|
<SfGrid @ref="Grid" DataSource="@Orders" AllowPaging="true" Toolbar="@(new List<string>() { "Cancel", "Update" })">
...
<GridEvents OnCellEdit="OnCellEdit" ... TValue="Order"></GridEvents>
<GridColumns>
<GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" IsPrimaryKey="true" TextAlign="TextAlign.Right" Width="120">
<EditTemplate>
...
<SfNumericTextBox ID="OrderID" @bind-Value="con.OrderID"
@onkeyup="@(e=>KeyUpHandler(e, con.OrderID, null , "OrderID" , "CustomerID",inputvalue))"> </SfNumericTextBox>
</EditTemplate>
</GridColumn>
<EditTemplate>
...
<SfTextBox ID="CustomerID" @bind-Value="con.CustomerID" OnInput="OnInput"
@onkeydown="@(e=>KeyDownHandler(e,con.OrderID, (e.Key == "Enter" && !e.ShiftKey ? "ShipCountry": "OrderID")))"
@onkeyup="@(e=>KeyUpHandler(e, con.OrderID,null, "CustomerID" , "ShipCountry",inputvalue))">
</SfTextBox>
</EditTemplate>
</GridColumn>
<EditTemplate>
...
<SfTextBox ID="ShipCountry" @bind-Value="con.ShipCountry" OnInput="OnInput"
@onkeyup="@(e=>KeyUpHandler(e, con.OrderID, "CustomerID","ShipCountry" , "Boolean",inputvalue))">
</SfTextBox>
</EditTemplate>
</GridColumn>
<EditTemplate>
...
<SfCheckBox ID="Boolean" @bind-Checked="con.Boolean" ValueChange="ValueChange" TChecked="bool"
@onkeyup="@(e=>KeyUpHandler(e, con.OrderID, "ShipCountry","Boolean" , null,inputvalue))">
</SfCheckBox>
</EditTemplate>
</GridColumn>
</GridColumns>
</SfGrid>
@code{
public object inputvalue;
public void OnInput(ChangeEventArgs args)
{
inputvalue = args.Value;
}
public void ValueChange(Syncfusion.Blazor.Buttons.ChangeEventArgs<bool> args)
{
inputvalue = args.Checked;
}
public void ValueChange(Syncfusion.Blazor.Inputs.ChangeEventArgs<int?> args)
{
inputvalue = args.Value;
}
public void OnCellEdit(CellEditArgs<Order> args)
{
inputvalue = args.Data.GetType().GetProperty(args.ColumnName).GetValue(args.Data, null);
}
...
public async void KeyUpHandler(KeyboardEventArgs args, int? OrderID,string leftField, string Field , string rightField, object FieldValue)
{
if (Grid.IsEdit && (args.Key == "ArrowDown" || args.Key == "ArrowUp"))
{
var rowIndex = await Grid.GetRowIndexByPrimaryKey(OrderID);
await Grid.UpdateCell(rowIndex, Field, FieldValue);
await Grid.EndEdit();
...
}
if (Grid.IsEdit && args.Key == "ArrowLeft" && leftField != null)
{
var rowIndex = await Grid.GetRowIndexByPrimaryKey(OrderID);
await Grid.UpdateCell(rowIndex, Field, FieldValue);
await Grid.EditCell(rowIndex, leftField);
}
if (Grid.IsEdit && args.Key == "ArrowRight" && rightField != null)
{
var rowIndex = await Grid.GetRowIndexByPrimaryKey(OrderID);
await Grid.UpdateCell(rowIndex, Field, FieldValue);
await Grid.EditCell(rowIndex, rightField);
}
}
}
|
Please get back to us if you need further assistance.
Regards,
Renjith R
Marked as answer
JC
JayaKrishna Ch
June 10, 2021 01:49 PM UTC
Thank you very much for help
RS
Renjith Singh Rajendran
Syncfusion Team
June 11, 2021 03:28 AM UTC
Hi JayaKrishna,
Thanks for your update. Please get back to us if you need further assistance.
Regards,
Renjith R
SIGN IN To post a reply.
- 4 Replies
- 2 Participants
- Marked answer
-
JC JayaKrishna Ch
- Jun 7, 2021 06:53 PM UTC
- Jun 11, 2021 03:28 AM UTC