You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.8 KiB
50 lines
1.8 KiB
@page "/weather"
|
|
@attribute [StreamRendering]
|
|
|
|
<PageTitle>Weather</PageTitle>
|
|
|
|
<h1>Weather</h1>
|
|
|
|
<p>This component demonstrates showing data.</p>
|
|
|
|
@if (forecasts == null)
|
|
{
|
|
<p><em>Loading...</em></p>
|
|
}
|
|
else
|
|
{
|
|
<!-- This page is rendered in SSR mode, so the FluentDataGrid component does not offer any interactivity (like sorting). -->
|
|
<FluentDataGrid Id="weathergrid" Items="@forecasts" GridTemplateColumns="1fr 1fr 1fr 2fr" TGridItem="WeatherForecast">
|
|
<PropertyColumn Title="Date" Property="@(c => c!.Date)" Align="Align.Start"/>
|
|
<PropertyColumn Title="Temp. (C)" Property="@(c => c!.TemperatureC)" Align="Align.Center"/>
|
|
<PropertyColumn Title="Temp. (F)" Property="@(c => c!.TemperatureF)" Align="Align.Center"/>
|
|
<PropertyColumn Title="Summary" Property="@(c => c!.Summary)" Align="Align.End"/>
|
|
</FluentDataGrid>
|
|
}
|
|
|
|
@code {
|
|
private IQueryable<WeatherForecast>? forecasts;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
// Simulate asynchronous loading to demonstrate streaming rendering
|
|
await Task.Delay(500);
|
|
|
|
var startDate = DateOnly.FromDateTime(DateTime.Now);
|
|
var summaries = new[] { "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" };
|
|
forecasts = Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
|
{
|
|
Date = startDate.AddDays(index),
|
|
TemperatureC = Random.Shared.Next(-20, 55),
|
|
Summary = summaries[Random.Shared.Next(summaries.Length)]
|
|
}).AsQueryable();
|
|
}
|
|
|
|
private class WeatherForecast
|
|
{
|
|
public DateOnly Date { get; set; }
|
|
public int TemperatureC { get; set; }
|
|
public string? Summary { get; set; }
|
|
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
|
}
|
|
}
|
|
|