DropDown filtering not working

Hi!
After updating the library to the latest stable version, the filter for RadzenDropDown stopped working.

For example:

                <RadzenDropDown TValue="string"
                            Data="@currencies"
                            Style="width: 100%;"
                            AllowClear="true" 
                            AllowFiltering="true"
                            Placeholder="Выберите валюту.."
                            TextProperty="AlphabeticCode"/>

..

                  private IEnumerable<CurrencyModel> currencies = new List<CurrencyModel>();
                  // or
                  private List<CurrencyModel> currencies = new List<CurrencyModel>();

An exception:
Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer: Warning: Unhandled exception rendering component: No applicable method 'Contains' exists in type 'Object'

No applicable method 'Contains' exists in type 'Object' (at index 47)
Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost: Error: Unhandled exception in circuit 'qv98XdF5P7Uu6JVZMZctpvVlb-8v6U8hdp4sR8DvUMY'.

No applicable method 'Contains' exists in type 'Object' (at index 47)
Microsoft.AspNetCore.Routing.EndpointMiddleware: Information: Executed endpoint '/_blazor'
Microsoft.AspNetCore.Hosting.Diagnostics: Information: Request finished in 5437.9525ms 101

If we indicate the type:

        <RadzenDropDown TValue="CurrencyModel"
                        Data="@currencies"
                        Style="width: 100%;"
                        AllowClear="true" 
                        AllowFiltering="true"
                        Placeholder="Выберите валюту.."
                        TextProperty="AlphabeticCode"/>

An exception:

Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer: Warning: Unhandled exception rendering component: No applicable method 'Contains' exists in type 'Object'

No applicable method 'Contains' exists in type 'Object' (at index 47)
Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost: Error: Unhandled exception in circuit 'KEc2vKAVgIgz2WdQW8AVVRDdsoZF6NWxxbCprwJT7pY'.

No applicable method 'Contains' exists in type 'Object' (at index 47)
Microsoft.AspNetCore.Routing.EndpointMiddleware: Information: Executed endpoint '/_blazor'
Microsoft.AspNetCore.Hosting.Diagnostics: Information: Request finished in 11530.350400000001ms 101

How to fix this problem?

Try to specify ValueProperty. TValue also should be the type of the ValueProperty.

Code:

            <RadzenDropDown TValue="string"
                            Data="@currencies"
                            Style="width: 100%;"
                            AllowClear="true" 
                            AllowFiltering="true"
                            Placeholder="Выберите валюту.."
                            TextProperty="AlphabeticCode"
                            ValueProperty="AlphabeticCode"/>

An exception:
Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer: Warning: Unhandled exception rendering component: No applicable method 'Contains' exists in type 'Object'

No applicable method 'Contains' exists in type 'Object' (at index 47)
Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost: Error: Unhandled exception in circuit 'C_i6rIFDjxa680vQbTAlDr97vFtfCp57BKDtyEq_Uqs'.

No applicable method 'Contains' exists in type 'Object' (at index 47)
Microsoft.AspNetCore.Routing.EndpointMiddleware: Information: Executed endpoint '/_blazor'

Can you post the class definition?

public class CurrencyModel
{
    public int Id { get; set; }
    public string RussianTitle { get; set; }
    public string EnglishTitle { get; set; }
    public string AlphabeticCode { get; set; }
    public int NumericCode { get; set; }
}

Try to assign Data like this and let me know if it works:

<RadzenDropDown Data="@currencies.AsQueryable()"  .../>

UPDATE: I've just published Radzen.Blazor 1.1.12 - it will work without AsQueryable() as well.

1 Like

The problem was solved when AsQueryable () was added.

Update radzen lib to latest.:+1:

I use a custom template, but for the filter I have to specify TextValue, why not specify it in AllowFiltering? ..

            <RadzenDropDown TValue="CurrencyModel"
                            Data="@currencies"
                            Style="width: 100%;"
                            AllowClear="true"
                            AllowFiltering="true"
                            Placeholder="Выберите валюту.."
                            TextProperty="@nameof(CurrencyModel.AlphabeticCode)"
                            Change="@(x=> createModel.QuoteCurrencyId = (x as CurrencyModel)?.Id ?? default)">

                <Template Context="data">
                    @{
                        var currency = data as CurrencyModel;

                        <CustomTemplateForDropDown MainText="@currency.AlphabeticCode" AdditionalInfo="@currency.EnglishTitle" />
                    }
                </Template>

            </RadzenDropDown>

image

Everything worked, thanks! :sunglasses: