Hi Tyrone,
Greetings from Syncfusion support.
Query: “Is there is a way to focus programatically in
"Add" button within the toolbar in grid? ”
We suspect that you need to focus the Add button at initial
rendering. If so we suggest you to achieve your requirement by using an JavaScript
interop solution. Here we have used DataBound event to focus the toolbar Add button. Kindly check the below code snippet for your reference.
@inject IJSRuntime JSRuntime
<SfGrid DataSource="@Orders" AllowGrouping="true" AllowPaging="true" Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update", "Search" })" Height="315">
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Normal"></GridEditSettings>
<GridEvents DataBound="DataBoundHandler" TValue="Order"></GridEvents>
<GridColumns>
</GridColumns>
</SfGrid>
@code {
public async Task DataBoundHandler()
{
await
JSRuntime.InvokeVoidAsync("focus"); // called interop function for focus
}
}
|
function focus() {
document.getElementsByClassName('e-toolbar-item')[0].getElementsByTagName('button')[0].focus();
}
|
Please let us know if you have any concerns.
Regards,
Monisha