LoadDataArgs is not set

Hello.

I am facing an issue with LoadDataArgs.

I used LoadData approach to fill RadzenDataGrid. It works well. But in one case I get error message Nullable object must have a value. I found out its caused by LoadDataArgs object, which is not set.

image

To set WHERE parameters to my query, I use RadzenDropdown component with AllowClear set to true.

LoadData method looks like this:

    async Task LoadData(LoadDataArgs args)
    {
        isLoading = true;

        await Task.Yield();

        var query = dlContext.Dls
        .Select(s => new Statistics()
        {
            GUID = s.Guid,
            Import = s.Import,
            CreatedBy = s.CreatedBy,
            CreatedOn = s.CreatedOn,
            StartedOn = s.StartedOn,
            CompletedOn = s.CompletedOn,
            FileName = s.FileName,
            InstantRun = s.InstantRun,
            StatusCode = s.StatusCode,
            Success = GetCount(s.Guid, (int)ImportStatus.Successful, s.Import, dlContext),
            Failed = GetCount(s.Guid, (int)ImportStatus.Failed, s.Import, dlContext),
            Totals = GetCount(s.Guid, (int)ImportStatus.Totals, s.Import, dlContext)
        }).AsQueryable();

        if (importValue != null)
        {
            query = query.Where(c => c.Import == importValue);
        }

        if (filenameValue != "")
        {
            query = query.Where(c => c.FileName.Contains(filenameValue));
        }

        if (importState != null)
        {
            var state = Enum.Parse(typeof(ImportStatus), importState);
            query = query.Where(c => c.StatusCode == (int)state);
        }

        if (createdOnFrom != DateTime.MinValue)
        {
            query = query.Where(c => c.CreatedOn >= createdOnFrom);
        }

        if (createdOnTo != DateTime.MinValue)
        {
            query = query.Where(c => c.CreatedOn <= createdOnTo);
        }

        if (!string.IsNullOrEmpty(args.OrderBy))
        {
            // Řazení pomocí OrderBy z argumentů, které se berou z gridu
            query = query.OrderBy(args.OrderBy);
        }

        // Nastavení celkového počtu záznamů do proměnné použité v RadzenDataGridu
        count = query.Count();

        // Provádění stránkování pomocí Skip a Take
        records = query.Skip(args.Skip.Value).Take(args.Top.Value).ToList();

        isLoading = false;
    }

And the code for the DataGrid is here:

Did you already experienced such problem?

I've not seen such issue before, let us know how/where we can replicate it.

Hello Enchev.

Its easy to reproduce. I use latest version of RadzenDataGrid with .Net 8. I also use EntityFramework for loading data with dbContext.

  1. I use typical RadzenDataGrid with LoadData approach.
  2. In LoadData method I call the data feom dbContext and save them to IEnumerable object. Statistics is class with some string or datetime objects.
  3. For creating Where clausule of the query, I use some fields above the grid. Dropdowns, text fields or DateTime fields.
  4. Problem is caused by the :"AllowClear=true" and using the X in the field. If you have the action in the dropdown component " LoadData="@LoadData" ", It will automatically call the LoadData method to re-render the grid, but does not contain the LoadDataArgs object.

<RadzenDropDown @bind-Value=@importValue Data=@importTypes Style="width: 100%; max-width: 400px;" AllowClear=true Name="DropDownBindValue" LoadData="@LoadData" />

I'm afraid we need runnable code - other possible solution is to attach Radzen.Blazor.csproj to your project to debug our code.