DataGrid Control in Blazor Radzen (Part 3)


DataGrid is one of the most used controls in web application. Radzen is giving us very powerful grid controls. Which has default support of Sorting, Filtering, paging and Virtualization

Before using this code, Please configure your project for Radzen Controls like this

https://chandradev819.wordpress.com/2022/09/28/getting-started-with-radzen-blazor-controls/

@page "/grid"
@using RadzenTest.Shared
@inject HttpClient Http
<h3>RadzenGrid</h3>

<RadzenDataGrid Data="@forecasts"
                TItem="WeatherForecast"
                AllowVirtualization="true"
                AllowPaging="true"
                 PageSize="10"
                AllowFiltering="true"
                FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive"
                LogicalFilterOperator="LogicalFilterOperator.Or"
                AllowSorting="true">
    <Columns>
        <RadzenDataGridColumn TItem="WeatherForecast" Property="Date" Title="Date">
            <Template Context="forecasts">
                @forecasts.Date.ToShortDateString()
            </Template>
        </RadzenDataGridColumn>

         <RadzenDataGridColumn TItem="WeatherForecast" Property="TemperatureC" Title="TemperatureC" />
        <RadzenDataGridColumn TItem="WeatherForecast" Property="Summary" Title="Summary" />
        <RadzenDataGridColumn TItem="WeatherForecast" Property="TemperatureF" Title="TemperatureF" />

    </Columns>
</RadzenDataGrid>


@code {
    private WeatherForecast[]? forecasts;
   
    protected override async Task OnInitializedAsync()
    {
        forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("WeatherForecast");
    }
}

Hey, Thanks for reading the blog post, I am in the market, looking for new freelance employment opportunities. If you need assistance on any of your ASP.NET Core Blazor projects, I am available for hire for freelance work.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.