DxListEditorBase<TData, TValue>.Reload() Method
Reloads a list editor’s data.
Namespace: DevExpress.Blazor.Base
Assembly: DevExpress.Blazor.v24.2.dll
NuGet Package: DevExpress.Blazor
Declaration
public void Reload()
Remarks
Call the Reload
method after a list editor’s data source is changed. The method gets updated data from the source and applies changes to the editor.
Note that list editors reloads their data automatically in the following cases:
- Observable Data Collections
- You can bind list editors to a data collection that implements the INotifyCollectionChanged or IBindingList interface. These collections notify an editor about changes and cause automatic updates.
- Data Instance Change
- If you change an instance of a field/property bound to the Data parameter, list editors reload their data in response to this change. You can use this technique if you post updates to the underlying service (such as DbContext EF Core).
The following sample binds the List Box editor to a List<T> and adds a new item to this list on a button click. The Reload
method is called in the Click
event handler. The List Box items are grouped against the ‘Summary’ field.
@using System.Collections.ObjectModel
<div style="margin-bottom: 10px">
<DxButton Text="Add New Day" Click="OnAddNewDay" />
</div>
<DxListBox @ref="MyListBox"
style="height: 300px"
TData="WeatherForecast"
TValue="WeatherForecast"
GroupFieldName="@nameof(WeatherForecast.Summary)"
Data="@WeatherForecastData"
@bind-Values="@values">
<Columns>
<DxListEditorColumn FieldName="Date" />
<DxListEditorColumn FieldName="TemperatureC" Caption="@("Temp. (\x2103)")" />
<DxListEditorColumn FieldName="TemperatureF" Caption="@("Temp. (\x2109)")" />
<DxListEditorColumn FieldName="Summary" />
</Columns>
</DxListBox>
@code {
int DayCount { get; set; } = 0;
List<WeatherForecast> WeatherForecastData { get; set; }
static readonly Random Rnd = new Random();
private IListBox<WeatherForecast, WeatherForecast> MyListBox;
private IEnumerable<WeatherForecast> forecasts;
private IEnumerable<WeatherForecast> values;
protected override void OnInitialized() {
WeatherForecastData = new List<WeatherForecast>();
foreach (var date in Enumerable.Range(1, 4).Select(i => DateTime.Now.Date.AddDays(i))) {
AddNewForecast();
}
}
private static readonly string[] Summaries = new[] {
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
void AddNewForecast() {
WeatherForecastData.Add(new WeatherForecast() {
Date = DateTime.Now.Date.AddDays(++DayCount),
TemperatureC = Rnd.Next(10, 20),
Summary = Summaries[Rnd.Next(Summaries.Length)]
});
}
void OnAddNewDay() {
AddNewForecast();
MyListBox.Reload();
}
}
Implements
Reload()
See Also