Skip to content

RaySheikh/Blazor-Bootstrap4-Table

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Blazor BootStrap4 Responsive Tables

example

Works with Blazor Serverside or WebAssembly.

Install using nuget package manager:

Install-Package BlazorBootstra4Table -Version 1.2.1

Usage:

@page "/fetchdata"
@inject HttpClient Http
@using BlazorBootstrap4Table

<h1>Weather forecast</h1>

<p>Blazor Bootstrap 4 Rresponsive Table</p>

    <Table Items="@forecasts" Striped="table-striped">
        <TableHeader>

            <th>Date</th>
            <th>Temp. (C)</th>
            <th>Temp. (F)</th>
            <th>Summary</th>

        </TableHeader>
        <TableRow>
            <td mobile-header="Date">@context.Date.ToShortDateString()</td>
            <td mobile-header="Temp. (C)">@context.TemperatureC</td>
            <td mobile-header="Temp. (F)">@context.TemperatureF</td>
            <td mobile-header="Summary">@context.Summary</td>
        </TableRow>
    </Table>
}

@code {
    private List<WeatherForecast> forecasts;

    protected override async Task OnInitializedAsync()
    {
        forecasts = await Http.GetFromJsonAsync<List<WeatherForecast>>("sample-data/weather.json");
    }

    public class WeatherForecast
    {
        public DateTime Date { get; set; }

        public int TemperatureC { get; set; }

        public string Summary { get; set; }

        public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
    }
}

Enable Search Filter: GetFilterableText = Fun<TItem, String> Pass items you want searchbar to filter

<Table Items="@forecasts" Striped="table-striped" GetFilterableText=@(item => $"{item.Date} {item.Summary} {item.TemperatureC} {item.TemperatureF}" )>

Link CSS file:

//Add to index.html file in wwwroot folder
<link href="_content/BlazorBootstrap4Table/styles.css" rel="stylesheet"/>

Please reference latest boostrap 4 stylesheet in _Host.cshtml head tag.

Future Enhancements:

  • Responsive: Done!
  • Search: Done!
  • Pagination
  • Sorting

About

BlazorBootstrap4Tables

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published