Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Working Grid with Template
@page "/fetchdata"
@inject HttpClient Http
@using Telerik.Blazor.Components.Grid
<h1>Weather forecast</h1>
<p>This component demonstrates fetching data from the server.</p>
<TelerikGrid Data="@forecasts" Pageable="true" Sortable="true" Filterable="true">
<TelerikGridColumns>
<TelerikGridColumn Field="Date">
<Template>
@((context as WeatherForecast).Date.ToShortDateString())
</Template>
</TelerikGridColumn>
<TelerikGridColumn Field="TemperatureC" Title="Temp C'" />
<TelerikGridColumn Field="TemperatureF" Title="Temp F'" />
<TelerikGridColumn Field="Summary" />
</TelerikGridColumns>
</TelerikGrid>
@code {
WeatherForecast[] forecasts;
protected override async Task OnInitializedAsync()
{
forecasts = await Http.GetJsonAsync<WeatherForecast[]>("sample-data/weather.json");
}
class WeatherForecast
{
public DateTime Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF { get; set; }
public string Summary { get; set; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.