@page "/fetchdata"
@using WebApplication1.Data
@inject WeatherForecastService ForecastService
@using Syncfusion.EJ2.RazorComponents.Grids
@using Newtonsoft.Json;
<h1>Weather forecast</h1>
<p>This component demonstrates fetching data from a service.</p>
@if (forecasts == null)
{
<p><em>Loading...</em></p>
}
else
{
<EjsGrid id="Grid" DataSource="@forecasts">
<GridColumns>
<GridColumn Field="Date" HeaderText="Date"></GridColumn>
. . . .
</GridColumns>
</EjsGrid>
}
@functions {
WeatherForecast[] forecasts;
protected override async Task OnInitAsync()
{
forecasts = await ForecastService.GetForecastAsync(DateTime.Now);
}
} |