Skip to content

Instantly share code, notes, and snippets.

@EdCharbeneau
Created August 15, 2019 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EdCharbeneau/e261cbde936f38cee3befd4eb6d344e4 to your computer and use it in GitHub Desktop.
Save EdCharbeneau/e261cbde936f38cee3befd4eb6d344e4 to your computer and use it in GitHub Desktop.
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