DataGrid In Line Edit - Focus On EditTemplate Items

Thank you, perfect! I was able to capture in OnAfterRenderAsync (I see I need to go do a more careful study of the Blazor component lifecycle).

In that method, I was able to revert back to the @ref approach, but have a couple small follow-up questions on focus and selection:

<EditTemplate Context="order">
    <RadzenTextBox @ref="shipNameTextBox" id="idForJSTest" 
    @bind-Value="order.ShipName" 
    Style="width:100%; display: block" Name="ShipName" />

then check the ref variable for null before focusing.

protected override Task OnAfterRenderAsync(bool firstRender)
      if (shipNameTextBox is not null)
      {
        shipNameTextBox.Element.FocusAsync();
      ...
  1. I assume grabbing the Element to do the FocusAsync() is still required since I didn't see a focus method on the RadzenTextBox itself?

  2. Also, is there a way to select the full text of the RadzenTextBox in C# when it is given focus programmatically?

Instead of the @ref.Element.FocusAsync() approach above, I've only been able to get it to both focus and highlight by using JSInterop that does both setSelectionRange(0,0) and Focus() using the ID attribute instead.

JS.InvokeVoidAsync("focusElement", "idForJSTest");
...


function focusElement(id) {
    if (document.getElementById(id) && document.getElementById(id).value) {
      element = document.getElementById(id);
      if (element.nodeName.toUpperCase() == "INPUT") {
        element.setSelectionRange(0, 0);
      }
      element.focus();
    }

Thanks