Skip to content
daisyBlazor

DataGrid

A typed, column-based grid on a daisyUI table with client-side sorting and paging, or server-side loading through ServerData. Mirrors MudDataGrid's shape: declare PropertyColumn and TemplateColumn children, add a DataGridPager for paging.
Data components.table
Cover · <DataGrid>
#Top accounts
1
Globex
Ana Silva
2
Northwind Traders
Tom Becker
3
Contoso
Priya Nair
4
Fabrikam
Lucas Martin
5
Umbrella Corp
Mei Chen

Examples

Property columns

PropertyColumn binds a member by expression, is sortable by default and takes an optional Format string. Click a header to sort.

Northwind TradersEnterprise2404,890.00 €
ContosoPro581,131.00 €
FabrikamPro32624.00 €
GlobexEnterprise4107,995.00 €
InitechFree50.00 €
website/Examples/Data/DataGridBasicExample.razor Source

Template columns

TemplateColumn renders any markup per row through context.Item; pass SortBy to make it sortable.

Task
AS
Add SSO to the login page
Ana Silva
19.0Done
TB
Fix invoice PDF totals
Tom Becker
7.0Done
PN
Migrate staging to .NET 10
Priya Nair
13.0Review
LM
Export reports to CSV
Lucas Martin
0.0Todo
website/Examples/Data/DataGridTemplateColumnExample.razor Source

Put a DataGridPager in PagerContent and set RowsPerPage; RowClick hands you the clicked item.

#ORD-1021Contoso10
#ORD-1022Fabrikam15
#ORD-1023Globex20
#ORD-1024Initech25
1-4 of 11

Selected: click a row

website/Examples/Data/DataGridPagingExample.razor Source

Styling and loading

Dense, Striped, Bordered and Hover map to daisyUI table modifiers; Loading swaps the body for skeleton rows.

Free48,20041 %
Pro39,90034 %
Team21,10018 %
Enterprise8,3007 %
website/Examples/Data/DataGridStylesExample.razor Source

Server data

ServerDataFunc receives the page and sort state and returns only that page plus the total count.

No records found
0-0 of 0
website/Examples/Data/DataGridServerDataExample.razor Source

API

<DataGrid<T>>

DaisyBlazor.Data

daisyUI replacement for MudDataGrid<T>. Renders a .table with a sortable header and a paged body. Supports client-side paging/sort over Items or server-side data via ServerData / ServerDataFunc.

Parameters

  • Bordered bool
    = false

    Render outer/inner borders.

  • Dense bool
    = false

    Compact row styling.

  • Elevation int
    = 0

    Elevation (accepted for MudBlazor parity; mapped to a shadow class).

  • EmptyText string
    = "No records found"

    Text shown in the built-in empty state when there are no rows and no NoRecordsContent.

  • Hover bool
    = false

    Highlight rows on hover.

  • Items IEnumerable<T>
    = null

    Local item source. Mutually exclusive with the server-data callbacks.

  • Loading bool
    = false

    Loading state (shows LoadingContent when set, else skeleton rows).

  • PageSize int?
    = null

    Alias for RowsPerPage.

  • PageSizeOptions int[]
    = [10, 25, 50]

    Page-size options offered by the pager.

  • ReadOnly bool
    = false

    Read-only flag (accepted for MudBlazor parity; no effect on rendering).

  • RowStyle string
    = null

    Inline style applied to each body row (e.g. "cursor: pointer;").

  • RowsPerPage int
    = 10

    Rows per page. PageSize is an alias.

  • ServerData Func<GridState<T>, CancellationToken, Task<GridData<T>>>
    = null

    Server-data loader (with cancellation). Mirrors the wrapper's signature.

  • ServerDataFunc Func<GridState<T>, Task<GridData<T>>>
    = null

    Server-data loader (no cancellation token).

  • SkeletonRows int
    = 5

    Number of skeleton rows rendered while loading without a LoadingContent.

  • Striped bool
    = false

    Zebra striping.

  • Class string
    = null

    CSS class applied to the table wrapper.

  • Style string
    = null

    Inline style applied to the table wrapper.

Events

  • RowClick EventCallback<DataGridRowClickEventArgs<T>>

    Raised when a row is clicked.

  • RowsPerPageChanged EventCallback<int>

    Raised when the pager changes the page size (enables @bind-RowsPerPage).

Content

  • ChildContent RenderFragment

    Alternative slot for column declarations.

  • Columns RenderFragment

    Column declarations.

  • LoadingContent RenderFragment

    Content shown while Loading is true.

  • NoRecordsContent RenderFragment

    Content shown when there are no rows.

  • PagerContent RenderFragment

    Pager content (typically a DataGridPager<T>).

<PropertyColumn<T, TProperty>>

DaisyBlazor.Data

A column bound to a member of the row type via an expression. Mirrors MudBlazor's PropertyColumn<T, TProperty>. Renders the (optionally formatted) member value.

Parameters

  • CellClass string
    = null

    Optional CSS class applied to every body cell in this column.

  • Format string
    = null

    Standard/custom format string applied to the value (e.g. "dd/MM/yyyy").

  • HeaderClass string
    = null

    Optional CSS class applied to the header cell.

  • Property Expression<Func<T, TProperty>>
    = required

    Expression selecting the member to display/sort.

  • SortBy Func<T, object>
    = null

    Optional explicit sort selector (overrides Property for sorting).

  • Sortable bool
    = true

    Whether the column is sortable.

  • Title string
    = null

    Column header text.

<TemplateColumn<T>>

DaisyBlazor.Data

A column whose cell content is supplied by an arbitrary template. Mirrors MudBlazor's TemplateColumn<T>. Not sortable by default; supply SortBy to enable sorting.

Parameters

  • CellClass string
    = null

    Optional CSS class applied to every body cell in this column.

  • HeaderClass string
    = null

    Optional CSS class applied to the header cell.

  • SortBy Func<T, object>
    = null

    Optional sort selector. When set (and Sortable), the column becomes sortable.

  • Sortable bool
    = false

    Whether the column is sortable.

  • Title string
    = null

    Column header text.

Content

  • CellTemplate RenderFragment<CellContext<T>>

    Cell template receiving a CellContext<T> (access the row via context.Item).

  • ChildContent RenderFragment<CellContext<T>>

    Alias for CellTemplate when content is provided as the column's body.

<DataGridPager<T>>

DaisyBlazor.Data

Parameters

  • InfoSeparatorText string
    = null

    Separator word in the range text (e.g. "of"). Null uses the app-wide Strings.

  • NextPageText string
    = null

    Accessible label for the next-page navigation button. Null uses the app-wide Strings.

  • PageSizeOptions int[]
    = null

    Page-size options. When set, mirrored onto the grid.

  • PreviousPageText string
    = null

    Accessible label for the previous-page navigation button. Null uses the app-wide Strings.

  • RowsPerPageText string
    = null

    Label shown before the page-size select. Null uses the app-wide Strings.

  • Class string
    = null

    Extra CSS classes added to the pager bar.

  • Style string
    = null

    Inline CSS style applied to the pager bar.

Something went wrong while running the docs. Reload