Dynamically loading Blazor ListBox and single selection not working

Hi,

I am trying to update a Blazor ListBox dynamically as per the code listed below. When I do this the Single item selection does not work. Also if I select just the first item on the list and then reload the list (Click button BBB for example) the list box selects the same item in the new list. 

Can you let me know how to get this working properly?

Kind regards,
Stuart

@page "/Test1Page"
@using Syncfusion.Blazor.Data;
@using Syncfusion.Blazor.DropDowns;
@using Syncfusion.Blazor.Buttons;
@using Microsoft.Extensions.Logging
@inject ILogger<Test1Page> Logger
@using System.Collections.ObjectModel
@using System.Data;
@using System.Linq;

@attribute [Authorize]

<h3>Test Page 1</h3>

<SfButton OnClick="Button1OnClick">AAA</SfButton>
<SfButton OnClick="Button2OnClick">BBB</SfButton>
<SfButton OnClick="Button3OnClick">CCC</SfButton>

<SfListBox DataSource="@Data" TValue="string[]" TItem="string">
    <ListBoxSelectionSettings Mode="Syncfusion.Blazor.DropDowns.SelectionMode.Single" ></ListBoxSelectionSettings>
</SfListBox>

@code {
    public List<string> Vehicles = new List<string> { "AAA Hennessey Venom", "AAA Bugatti Chiron", "AAA Bugatti Veyron Super Sport", "AAA SSC Ultimate Aero", "BBB Koenigsegg CCR", "BBB McLaren F1", "BBB Aston Martin One- 77", "CCC Jaguar XJ220", "CCC Holden SV6" };
    public static ObservableCollection<string> Data = new ObservableCollection<string>();

    public void Button1OnClick()
    {
        Data.Clear();
        foreach (var data in Vehicles.Where(s => s.StartsWith("AAA")))
            Data.Add(data);
        Logger.LogInformation($"Button 1 click data updated");
    }

    public void Button2OnClick()
    {
        Data.Clear();
        foreach (var data in Vehicles.Where(s => s.StartsWith("BBB")))
            Data.Add(data);
        Logger.LogInformation($"Button 2 click data updated");
    }

    public void Button3OnClick()
    {
        Data.Clear();
        foreach (var data in Vehicles.Where(s => s.StartsWith("CCC")))
            Data.Add(data);
        Logger.LogInformation($"Button 3 click data updated");
    }
}

1 Reply

SD Saranya Dhayalan Syncfusion Team April 14, 2020 01:50 PM UTC

Hi Stuart, 
 
Thank you for contacting Syncfusion support 
 
We have validated your reported issue and we are able to reproduce this issue in our end. We have logged a defect report for this, and the fix will be available in our upcoming Nuget patch release. You can track the status of this defect using below link from our feedback portal,  
 
 
Regards, 
Saranya D 


Loader.
Up arrow icon