I'm currently using the ListBox component with an ICollection<> that comes from EF Core. I also saw that you suggest to use Observerable Collections but due my entities this is not possible and a DTO is in this project against the guidelines. So how can I achieve a refresh of the list through code? In many other SJ2 Component it's just enaugh to call `this.state.hasChanged()` which doesn't work here if also tried the two methods `.Refresh()` and `.DataBind()`
@page "/"
@using Syncfusion.EJ2.Blazor.DropDowns
@using Syncfusion.EJ2.Blazor.Buttons
<EjsListBox TValue="string[]" DataSource="@Vehicles" ModelType="@typeof(VehicleData)" @ref="ListBoxObj">
<ListBoxFieldSettings Text="Text" Value="Id" />
<ListBoxTemplates>
<ItemTemplate>
<p>@((context as VehicleData).Text)</p>
</ItemTemplate>
</ListBoxTemplates>
</EjsListBox>
<EjsButton CssClass="e-btn" Content="Modify data" @onclick="modifyData"></EjsButton>
@code {
EjsListBox<string[]> ListBoxObj;
public ICollection<VehicleData> Vehicles = new List<VehicleData> {
new VehicleData { Text = "Hennessey Venom", Id = "Vehicle-01" },
new VehicleData { Text = "Bugatti Chiron", Id = "Vehicle-02" },
new VehicleData { Text = "Bugatti Veyron Super Sport", Id = "Vehicle-03" },
new VehicleData { Text = "SSC Ultimate Aero", Id = "Vehicle-04" },
new VehicleData { Text = "Koenigsegg CCR", Id = "Vehicle-05" },
new VehicleData { Text = "McLaren F1", Id = "Vehicle-06" },
new VehicleData { Text = "Aston Martin One- 77", Id = "Vehicle-07" },
new VehicleData { Text = "Jaguar XJ220", Id = "Vehicle-08" }
};
public class VehicleData
{
public string Text { get; set; }
public string Id { get; set; }
}
private void modifyData()
{
Vehicles.Remove(Vehicles.First());
Vehicles.Add(new VehicleData {Text = "Ferrari LaFerrari", Id = "Vehicle-09"});
ListBoxObj.Refresh();
ListBoxObj.DataBind();
}
}