Hi Juan,
We have modified the sample based on this scenario, please download and refer the sample from the link below,
Please find the suggestions for the queries below,
Query 1 : - Visually indicating that the current row is selected (the rows opens for editing, but the checbox is not checked, so the user thinks it's not selected)
We suggest you to use the EditTemplate feature of Grid. With this we have rendered a SfCheckBox component with Checked property as true.
|
<GridColumn Type="ColumnType.CheckBox" Width="140">
<EditTemplate>
<SfCheckBox Checked="true"></SfCheckBox>
</EditTemplate>
</GridColumn>
|
Query 2 : - Closing the row after pressing the Enter key (currently, the only way for closing the edition is to click in another row)
We have used Microsoft JSInterop to find the Enter key press in Grid’s edit form. And with this we have made customizations in RowSelected and OnActionComplete event handlers to achieve this requirement. Please refer the codes below,
<GridEvents RowSelected="RowSelected" DataBound="Data" OnActionComplete="OnActionComplete" TValue="Order"></GridEvents>public async Task RowSelected(RowSelectEventArgs<Order> args){ await Runtime.InvokeAsync<object>("StartEditAction"); if (EnterKeyPress && SelectIndexes.LastOrDefault().Equals(args.RowIndex)) { if (!flagSave) { EnterKeyPress = false; return; } flagSave = false; await Grid.SelectRows(SelectIndexes); } else if (!EnterKeyPress) { if (flag) { await Grid.StartEdit(); if (!SelectIndexes.Contains(args.RowIndex)) SelectIndexes.Add(args.RowIndex); } flag = true; }}public bool firstrender = true;public async Task Data(){ if (firstrender) { var dotNetReference = DotNetObjectReference.Create(this); await Runtime.InvokeAsync<string>("keyevent", dotNetReference); firstrender = false; }}public bool flagSave = false;public async Task OnActionComplete(ActionEventArgs<Order> args){ if (args.RequestType.Equals(Action.BeginEdit) && SelectIndexes.Count != 0) { flag = false; await Runtime.InvokeAsync<object>("StartEditAction"); await Grid.SelectRows(SelectIndexes); } if (EnterKeyPress && args.RequestType.Equals(Action.Save)) { flagSave = true; }}public bool EnterKeyPress = false; [JSInvokable("EnterKeyPressMethod")]public async Task EnterKeyPressMethod(bool EnterKeyState) //c# method called from JS{ EnterKeyPress = EnterKeyState;}[enterkey.js]var dotnetInstance;function keyevent(dotnet) { dotnetInstance = dotnet; // dotnet instance to invoke C# method from here }function StartEditAction() { var gridform = document.getElementsByClassName("e-gridform")[0]; if (gridform) { gridform.onkeydown = function (e) { if (e.code == "Enter") { dotnetInstance.invokeMethodAsync('EnterKeyPressMethod', true); // call C# method from javascript function } } }}
|
Please get back to us if you need further assistance.
Regards,
Renjith Singh Rajendran