RadzenDropDownDataGrid exception when filtering data #176

Closed
opened 2026-01-29 17:32:51 +00:00 by claunia · 0 comments
Owner

Originally created by @DvD12 on GitHub (Aug 14, 2021).

Describe the bug
Filtering a RadzenDropDownDataGrid and then clicking on a filtered element raises the following exception:
(blazor.server.js:21) Error: No applicable method 'Contains' exists in type 'Int32' (at index 0)

To Reproduce
Steps to reproduce the behavior:

  1. Create an index page with the following code:
@page "/"

<RadzenDropDownDataGrid LoadData="LoadData" AllowFiltering="true"
                        @ref="Element"
                        @bind-Value="@Value"
                        Data="FilteredData" Count="@Count" />

@code
{
    public RadzenDropDownDataGrid<int> Element { get; set; }
    public Dictionary<int, string> Data { get; set; }
    private List<int> FilteredData;
    private int Count;
    private int Value;

    protected override void OnInitialized()
    {
        Data = new Dictionary<int, string>()
        {
            { 1, "123" },
            { 2, "223" },
            { 3, "323" },
        };
    }

    private void LoadData(LoadDataArgs args)
    {
        var query = Data.AsQueryable();
        try
        {
            if (!string.IsNullOrEmpty(args.Filter))
            {
                query = Data.Where(x => x.Key.ToString().Contains(args.Filter) || x.Value.ToString().ToLower().Contains(args.Filter.ToLower())).ToDictionary(x => x.Key, x => x.Value).AsQueryable();
            }
        }
        catch (Exception e) { }
        Count = query.Count();
        if (args.Skip != null)
        {
            query = query.Skip(args.Skip.Value);
        }
        if (args.Top != null)
        {
            query = query.Take(args.Top.Value);
        }
        FilteredData = query.Select(x => x.Key).ToList();
        InvokeAsync(StateHasChanged);
    }
}
  1. Run the project
  2. Click on the dropdown
  3. Input '1' as filter
  4. Click on the one entry that says '1'
  5. An exception is raised.

Desktop

  • OS: Windows 10
  • Browser: Microsoft Edge
  • Version 3.8.2

Additional context
Versions <=3.4.0 seem unaffected. This behaviour is present in versions >=3.4.1.

Originally created by @DvD12 on GitHub (Aug 14, 2021). **Describe the bug** Filtering a RadzenDropDownDataGrid and then clicking on a filtered element raises the following exception: `(blazor.server.js:21) Error: No applicable method 'Contains' exists in type 'Int32' (at index 0)` **To Reproduce** Steps to reproduce the behavior: 1. Create an index page with the following code: ``` @page "/" <RadzenDropDownDataGrid LoadData="LoadData" AllowFiltering="true" @ref="Element" @bind-Value="@Value" Data="FilteredData" Count="@Count" /> @code { public RadzenDropDownDataGrid<int> Element { get; set; } public Dictionary<int, string> Data { get; set; } private List<int> FilteredData; private int Count; private int Value; protected override void OnInitialized() { Data = new Dictionary<int, string>() { { 1, "123" }, { 2, "223" }, { 3, "323" }, }; } private void LoadData(LoadDataArgs args) { var query = Data.AsQueryable(); try { if (!string.IsNullOrEmpty(args.Filter)) { query = Data.Where(x => x.Key.ToString().Contains(args.Filter) || x.Value.ToString().ToLower().Contains(args.Filter.ToLower())).ToDictionary(x => x.Key, x => x.Value).AsQueryable(); } } catch (Exception e) { } Count = query.Count(); if (args.Skip != null) { query = query.Skip(args.Skip.Value); } if (args.Top != null) { query = query.Take(args.Top.Value); } FilteredData = query.Select(x => x.Key).ToList(); InvokeAsync(StateHasChanged); } } ``` 2. Run the project 3. Click on the dropdown 4. Input '1' as filter 5. Click on the one entry that says '1' 6. An exception is raised. **Desktop** - OS: Windows 10 - Browser: Microsoft Edge - Version 3.8.2 **Additional context** Versions <=3.4.0 seem unaffected. This behaviour is present in versions >=3.4.1.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#176