DataGrid LoadData No records problem

I am using LoadData even though data retrieved from the database is not displayed on the grid.

Here is the grid:

<RadzenDataGrid @ref="_grid" AllowFiltering="true" AllowPaging="true" AllowSorting="true" Data="@_orders" TItem="ReportViewModel"
                            PagerHorizontalAlign="HorizontalAlign.Left" ShowPagingSummary="true" AllowColumnResize="true" 
                            AllowVirtualization="true" Style="width: calc(100vw - 120px);" ColumnWidth="170px" PageSize="5" LoadData="@LoadData" >

Here is the related code:

IEnumerable<ReportViewModel?> _orders;
    IEnumerable<Vendor?> _vendors = new List<Vendor?>();
    IEnumerable<Customer?> _customers;
    ClaimsPrincipal user;
    IEnumerable<ReportViewModel?> query;
    List<string> vendorNames;

    protected override async Task OnInitializedAsync()
        user = (await _authenticationStateProvider.GetAuthenticationStateAsync()).User;

        if (!user.Identity.IsAuthenticated)
            NavigationManager.NavigateTo("/Identity/Account/Login", false);

        _vendors = await ViewAllVendorsUseCase.ExecuteAsync();
        _customers = await ViewAllCustomersUseCase.ExecuteAsync();
        vendorNames = _vendors.Select(c => c.Name).ToList();

async Task LoadData(LoadDataArgs args)
         _orders = await GetOrdersExportUseCase.ExecuteAsync(_vendorId, _status, _startDate, _endDate, _detailStatus, _customerId, user);

        IQueryable<ReportViewModel?> query = _orders.AsQueryable(); 
        if (!string.IsNullOrEmpty(args.Filter)){
            query = query.Where(args.Filter);
        if (!string.IsNullOrEmpty(args.OrderBy)){
            query = query.OrderBy(args.OrderBy);
        _orders = query.ToList();

Here is the debug:

Here is the screenshot:

When using the LoadData event you need to set the Count attribute of RadzenDataGrid.

1 Like

Thank you @korchev.
There is something strange about the selection of dropdown that I can't understand. When I select vendors from the dropdown, the grid is not filtered. But when I unselect the list from the dropdown, the grid gets filtered.

<RadzenDataGridColumn TItem="ReportViewModel" Property="VendorName" Title="Vendor" 
                                          Type="typeof(IEnumerable<string>)" FilterValue="@selectedVendors" FilterOperator="FilterOperator.Contains" LogicalFilterOperator="LogicalFilterOperator.Or">
                            <RadzenDropDown Style="width:100%;" @bind-Value=@selectedVendors Placeholder="Select..."
                                            Change=@OnSelectedVendorsChange Data="@(vendorNames)" AllowClear="true" Multiple="true"/>

Everything seems OK, _orders get the filtered records but the grid is not filtered until the selected value is unselected from the dropdown.

By the way, is it normal for the LoadData method to be called 3 times when the page is loading?

I am afraid I can't answer those questions without reproducing the problem first. If you have a subscription you can send us your project to

BTW I noticed there is a StateHasChanged call in the LoadData event which is not needed.

Thank you @korchev, filtering is not firing when selecting from the dropdown in my case, after selecting the value in the dropdown, I click on the grid somewhere, and it fires and the filter applies. I know it's hard to detect without the source code, but I'm asking in case you've come across it.