blazor-devexpress-dot-blazor-dot-base-dot-dxeditorbase-0db85f9f.md
Suspends component updates caused by parameter changes and method calls until the EndUpdate() method is called.
Namespace : DevExpress.Blazor.Base
Assembly : DevExpress.Blazor.v25.2.dll
NuGet Package : DevExpress.Blazor
public void BeginUpdate()
You can use BeginUpdate() and EndUpdate() methods to change values of the editor parameters outside the component markup.
The following code snippet changes the ReadOnly parameter value.
<DxListBox Data="forecasts"
TextFieldName="@nameof(WeatherForecast.Summary)"
@ref="component"
@bind-Values="values"/>
<DxButton Text="MakeReadOnly" Click="@MakeReadOnly"></DxButton>
@code {
private IListBox<WeatherForecast, WeatherForecast> component;
private IEnumerable<WeatherForecast> forecasts;
private IEnumerable<WeatherForecast> values;
protected override async Task OnInitializedAsync() {
forecasts = await ForecastService.GetForecastAsync(DateOnly.FromDateTime(DateTime.Now));
}
void MakeReadOnly() {
component.BeginUpdate();
component.ReadOnly = true;
component.EndUpdate();
}
}
using System;
public class WeatherForecast {
public DateTime Date { get; set; }
public int TemperatureC { get; set; }
public double TemperatureF => Math.Round((TemperatureC * 1.8 + 32), 2);
public double Precipitation { get; set; }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
public class WeatherForecastService {
// ...
private List<WeatherForecast> Forecast { get; set; }
public WeatherForecastService() {
// ...
Forecast = CreateForecast();
}
// ...
private List<WeatherForecast> CreateForecast() {
var rng = new Random();
DateTime startDate = DateTime.Now;
return Enumerable.Range(1, 15).Select(index => new WeatherForecast {
Date = startDate.AddDays(index),
TemperatureC = rng.Next(-20, 55),
}).ToList();
}
public Task<WeatherForecast[]> GetForecastAsync(CancellationToken ct = default) {
return Task.FromResult(Forecast.ToArray());
}
}
// ...
builder.Services.AddSingleton<WeatherForecastService>();
See Also