Overview
ISimpleGridDataSource<T>
The ISimpleGridDataSource<T>
interface is what powers the Simple Blazor Grid, it is responsible for performing all filtering, sorting, searching and pagination of the data. A ISimpleGridDataSource<T>
must be provided to the SimpleGridDataSource
parameter on all Simple Blazor Grids.
This interface allows for different implementations of searching / filtering etc. depending on the source of the data (IEnumerable<T> / Entity Framework etc.) Simple Blazor Grid Core comes with an implementation of ISimpleGridDataSource<T>
in the form of SimpleGridEnumerableDataSource<T>
.
To use SimpleGridEnumerableDataSource<T>
, simply create a new instance passing in your data to the constructor and use it as the SimpleGridDataSource
parameter on your grid, see the example below for more details
<SimpleGrid
TType="Data"
SimpleGridDataSource="new SimpleGridEnumerableDataSource<Data>(_data)">
<Columns>
<SimpleColumn TType="Data" For="@(x => x.Id)" />
<SimpleColumn TType="Data" For="@(x => x.Name)" />
</Columns>
</SimpleGrid>
@code {
public class Data
{
public Data(int id, string name)
{
Id = id;
Name = name;
}
public int Id { get; }
public string Name { get; }
}
private readonly List<Data> _data = new()
{
new(1, "Fred Jones"),
new(2, "Daphne Blake"),
new(3, "Velma Dinkley"),
new(4, "Shaggy Rodgers"),
new(5, "Scoobert 'Scooby' Doo"),
};
}
Entity Framework
A separate package is provided for Entity Framework, it provides SimpleGridEntityFrameworkDataSource<T>
as the implementation of ISimpleGridDataSource<T>
by replacing some features with more database friendly implementations. For further details, see the dedicated Entity Framework page.
Available Sources
The table below lists all data sources and their packages
Package | Implementation | Details |
---|---|---|
SimpleBlazorGrid.Core | SimpleGridEnumerableDataSource<T> |
The default implementation for filtering data contained in a list / array inheriting from IEnumerable |
SimpleBlazorGrid.EntityFramework | SimpleGridEntityFrameworkDataSource<T> |
Entity Framework specific implementation designed to take in an IQueryable<T> |