RadzenDropDownDataGrid: LoadData deadlock for async database-calls

I have this simple RadzenDropDown where the user can type a city-name and it will autocomplete what matches in the database.

  <RadzenDropDown AllowFiltering="true"                            
                        @* Count="_totalMatches" *@
                        Data="@_cities"
                        FilterDelay="300"
                        LoadData="HandleLoadDataAsync"
                        Placeholder="@(Localizer["Type the name of the city ..."])"
                        TValue="City"
                        ValueChanged="HandleValueChangedAsync">
    <Template>
        @((context as City)?.FormattedCityName)
    </Template>
</RadzenDropDown>

@code {
    [Parameter]
    public EventCallback<City> OnSelectedItemChange { get; set; }

    IEnumerable<City> _cities;

    private async Task HandleLoadDataAsync(LoadDataArgs loadData)
    {
       _cities = await DbContext.City.Where(...).OrderBy(...).Select(...).ToListAsync();

        await InvokeAsync(StateHasChanged);
    }

    private async Task HandleValueChangedAsync(TblCity city)
    {
        await OnSelectedItemChange.InvokeAsync(city);
    }
}

which all is working as expected. However, if I change to RadzenDropDownDataGrid and un-commenting (and setting) the Count-property I got a deadlock when HandleLoadDataAsync is invoked. I can see, that the SQL-is generated but it never goes further than the await ... ToListAsync() call.

First I thought this is an issue with the DbContext but I tried calling await DbContext...ToListAsync() in the OnInitializedAsync lifecycle-call which worked as expected. So I guess it has something to to with how the LoadData event-callback is invoked? Just guessing here as I wonder why it is working for RadzenDropDown but not for RadzenDropDownDataGrid.

Side note: Using the non-async calls will work but I still guess this is an issue/bug?

I'm unable to reproduce such exception. If you have Radzen subscription you can send us an repro application at info@radzen.com to debug it.

I ran into the same issue, was able to reproduce it by modifying the demo at:

radzen-blazor-master/RadzenBlazorDemos/Pages/DropDownDataGridPage.razor

Simply change the declaration of the LoadData() function to be async and add any async await to the first line:

    async Task LoadData(LoadDataArgs args)
    {
        await Task.Delay(100);

        var query = dbContext.Customers.AsQueryable();

When running the page, open the Custom filtering example dropdown and input any filter text, the filtering will not apply and elements on the page will stop responding.

Any progress on this? I'm able to replicate it too.
I stumbled upon this when making an async call to db from LoadData.
Converting it to sync call works fine.

private void LoadData(LoadDataArgs args){
    var list = db.Table.ToList();
}

Converting it to async call makes the initial call, but fails when filtering, it deadlocks on ToListAsync.

private async Task LoadData(LoadDataArgs args){
    var list = await db.Table.ToListAsync();
}

Thank you

1 Like

Unfortunately I'm not able neither with the sync version...

The collection is filtered properly (I have a Count that changes when I type in the filter), but the grid remains always empty

Customers Count =  <span>@NavCustomers.ToList().Count()</span>
                                <RadzenDropDownDataGrid TValue="string" Data="@NavCustomers" TextProperty="FullName" ValueProperty="Id" @bind-Value="@(Complaint.ErpCustomerCode)"
                                                        FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive" AllowFiltering="true" class="w-100" LoadData="@LoadCustomers"
                                                        AllowFilteringByAllStringColumns="true" FilterOperator="StringFilterOperator.Contains" AllowVirtualization="false">
                                   <Columns>
                                       <RadzenDropDownDataGridColumn Property="Id" Title="Id" Width="60px" />
                                        <RadzenDropDownDataGridColumn Property="CustomerName" Title="Nome" Width="240px" />
                                   </Columns>
                               </RadzenDropDownDataGrid>
public IEnumerable<NavCustomer> NavCustomers;

protected void LoadCustomers(LoadDataArgs args)
    {
        if (!string.IsNullOrEmpty(args.Filter))
        {
            NavCustomers =  NavCustomerService.Filter(args.Filter);
        }
        StateHasChanged();
    }


I forgot the COUNT parameter that it seems it is mandatory even without virtualization.

BTW with 4.3.6 it works also with async methods

Count is mandatory for LoadData binding no matter if virtualization is on or off.

1 Like