So there's been various versions of this question that's been asked but seems I may have found a new edge case for you guys.
In my Sfgrid, I have a custom dialog that pops up when a user selects an item inside the grid and it's tied to the RowSelection feature.
My issue is whenever a User adds to the grid the grid will refresh and then select the first object in the list, this is essentially causing an issue where -> Item gets added, open dialog for the first selected object.
Is there a way to disable the default setup for selecting first item in the list after an Add/Edit?
Hi Johnathon,
Greetings from Syncfusion support.
This is the default behavior after perform add in grid. So based on your scenario, we suggest you to call the ClearSelectionAsync method of grid inside the OnActionComplete event handler as like the below codes to overcome this behavior.
|
@using Action = Syncfusion.Blazor.Grids.Action
<SfGrid @ref="Grid" DataSource="@Orders" ...> <GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Dialog"></GridEditSettings> <GridEvents OnActionComplete="OnActionComplete" TValue="Order"></GridEvents> ... </SfGrid>
SfGrid<Order> Grid; public async Task OnActionComplete(ActionEventArgs<Order> args) { if (args.RequestType.Equals(Action.Save)) { await Grid.ClearSelectionAsync(); } }
|
Reference :
https://blazor.syncfusion.com/documentation/datagrid/editing#event-trace-while-editing
Please get back to us if you need further assistance.
Regards,
Renjith R
Thanks this was the exact help I was looking for.
Your solution partially worked but the RowSelected was still happening before the Function would cancel the ClearSelection.
The solution I found that worked for me was in the Reference Documentation.
I called the ActionBegin and set a bool to true, then in the OnActionComplete I then reversed that bool.
Then inside the RowSelected I just called the bool for when it was set to false basically.
Extra steps for sure but got the outcome I was looking for. Thanks.
Hi Johnathon,
Thanks for your update. We are glad to hear that you have achieved your requirement. Please get back to us if you need further assistance.
Regards,
Renjith R