RadzenTextBox and Change event

Hello,

I’m trying to use a RadzenTextBox to make a searchbox (for an API call). I’d like 4 caracters before calling API and a min of 2msec but I never hit the OnTyping method. I tried several solutionb but still the same problem.

Do you have an idea ?

Thanks

I tried several solution like but for the moment I’m trying this one.

<RadzenTextBox @bind-Value="@ViewModel.Model.SearchString"
Change="OnTyping"
Name="Name"
Placeholder="Partial ref"
Style="width: 100%;"
MaxLength="100"
aria-label="Partial ref" />

private async Task OnTyping()
{
    // Cancel any pending search
    _searchCancellationTokenSource?.Cancel();
    _searchCancellationTokenSource = new CancellationTokenSource();

    if (ViewModel.Model.SearchString?.Length >= 4)
    {
        try
        {
            await Task.Delay(200, _searchCancellationTokenSource.Token);

            await ViewModel.Search(0, 10);
        }
        catch (OperationCanceledException)
        {
            // ignore
        }
    }

    StateHasChanged();
}

Hi @Kris-I,

The Change event is fired when the textbox is blurred (loses focus) by default. Try setting the Immediate property to true.

Hello,

I may be have more global issue :

  • The RadzenSidebarToggleto toggle light/dark
  • The “Toc” does not work
  • The NotificationMessage appear but stay and the click on the X not working.

Calling backend, display in grid no problem

Update1 : I get a branch from the beginning of the project I have the 3 issues above.

Update2 : Created new project grab the code of App.razor and copy it in the not working one work now, the 3 points above are ok. Now I’m going to find the solution for the original problem.

Looks strange,