|
@using Syncfusion.Blazor.Buttons
@using Syncfusion.Blazor.Spinner
<div>
<SfButton @onclick="@ClickHandler">Load Data</SfButton>
<div id="container">
@if (this.showData) {
<table class="table">
<thead>
<tr>
<th>Date</th>
<th>Temp. (C)</th>
<th>Temp. (F)</th>
<th>Summary</th>
</tr>
</thead>
<tbody>
@foreach (var forecast in forecasts)
{
<tr>
<td>@forecast.Date.ToShortDateString()</td>
<td>@forecast.TemperatureC</td>
<td>@forecast.TemperatureF</td>
<td>@forecast.Summary</td>
</tr>
}
</tbody>
</table>
}
<SfSpinner @bind-Visible="@VisibleProperty" CssClass="e-customClass">
</SfSpinner>
</div>
</div>
@code{
private WeatherForecast[] forecasts;
public bool showData { get; set; } = false;
//The visile property is used to show and hide the spinner.
private bool VisibleProperty { get; set; } = false;
private async Task ClickHandler()
{
// To show the spinner.
this.VisibleProperty = true;
await Task.Delay(2000);
forecasts = await ForecastService.GetForecastAsync(DateTime.Now);
this.showData = true;
// To hide the spinner.
this.VisibleProperty = false;
}
}
<style>
.e-spinner-pane.e-customClass .e-spinner-inner .e-spin-bootstrap4 {
stroke: #808080;
}
</style> |