Initial value is not selected

I'm trying to upgrade my project to the latest version, after not having worked on it for some time. I noticed an issue which I could track down to a change of behavior from version 18.4.0.42 to 18.4.0.43

See the attached solution for a simplified demo of the issue. I have an class called Country with an Id and Name. It overrides the Equals method so that all instances of a Country with the same Id are considered equal. Furthermore, I have a component CountryDropDown which basically wraps SfDropDownList. In the Index page, I create an entity with a Country where only the Id = 2 is set. When you start the solution, the Country with Id = 2 (which is Canada) should be selected automatically. With version 18.4.0.42, this works fine. When upgrading to 18.4.0.43 or later, it doesn't work anymore, i.e. Canada is not selected. It seems that the Equals method is not called anymore and it works only if I select the exact same instance of the Country class which I have defined in the DataSource, but this is not an option in my case.

Could you check this, please?

Thanks

Sven



Attachment: BlazorApp2_31dd0f9b.zip

3 Replies

UD UdhayaKumar Duraisamy Syncfusion Team June 2, 2022 03:10 PM UTC

Hi Sven,


We were able to reproduce the reported issue and we will update the further details in two business days (6th June 2022).


Regards,

Udhaya Kumar D




UD UdhayaKumar Duraisamy Syncfusion Team June 6, 2022 04:34 PM UTC

Hi Sven,


Due to complexity, we are still validating the requirement. We will update the details in two business days (8th June 2022).


Regards,

Udhaya Kumar D.



UD UdhayaKumar Duraisamy Syncfusion Team June 9, 2022 03:34 PM UTC

Hi Sven,


Sorry for the inconvenience caused.


We can’t able to run the sample that you have shared. We have attached a working sample for reference below. For the custom component scenario,
we need to use Value property (at parent component) instead of @bind-Value and need to use ValueChanged and ValueExpression property in the parent component. Please refer to the below code snippet for reference.


@using Syncfusion.Blazor.DropDowns

@using System.Linq.Expressions;

 

<SfDropDownList TValue="string" TItem="Country" Value="@Value" ValueChanged="ValueChanged" ValueExpression="@ValueExpression" DataSource="@Countries">

    <DropDownListFieldSettings Text="Name" Value="Code"></DropDownListFieldSettings>

</SfDropDownList>

 

@code {

 

    private string _value { get; set; }

 

    [Parameter]

    public Expression<Func<string>> ValueExpression { get; set; }

 

    [Parameter]

    public string Value

    {

        get => _value;

        set

        {

            if (!EqualityComparer<string>.Default.Equals(value, _value))

            {

                _value = value;

                ValueChanged.InvokeAsync(value);

            }

        }

    }

    [Parameter]

    public EventCallback<string> ValueChanged { get; set; }

}



Regards,

Udhaya Kumar D.


Attachment: WASMCustomComponent_f3b4bfc.zip

Loader.
Up arrow icon