Skip to content
IzzyBlazor

Enter all results ↑ ↓ move Esc close

Toolbar

Since 0.1.0-alpha.20
The toolbar above the grid holds your buttons, a search box and the grid's own tools, in the order you choose.

The toolbar sits above the grid. To add buttons, put ToolbarButtons in ToolbarContent; to add a box that searches the text columns, set Searchable.

Static

Preview

Orders with tools
OrderCustomer Date Total
1001Margaret HamiltonSep 8$66.25
1002Katherine JohnsonSep 15$108.00
1003Grace HopperSep 22$149.75
1004Barbara LiskovSep 29$191.50
1005Linus TorvaldsOct 6$233.25

Code

Toolbar.razor
@* Your own buttons above the grid, and a search box whose words are in the address. A search that
   matches nothing shows NoMatchesContent, with the grid's own Clear search under it. *@
@using Rows = IzzyBlazor.Site.Examples.Table.Orders
<DataGrid Items="Rows.All" ItemKey="o => o.Number.ToString()" PageSize="5" Caption="Orders with tools" Searchable QueryPrefix="tools-" Grow>
    <ToolbarContent>
        <ToolbarButton StartIcon="Lucide.Plus" Position="ToolbarPosition.End" Variant="ButtonVariant.Outline">New order</ToolbarButton>
        <ToolbarButton StartIcon="Lucide.Download" Position="ToolbarPosition.End">Export</ToolbarButton>
    </ToolbarContent>
    <NoMatchesContent Context="words">
        <EmptyState Icon="Lucide.SearchX" Title="@($"No orders match “{words}”")" Description="Try an order number or a customer's name." Size="ControlSize.Sm" />
    </NoMatchesContent>
    <Columns>
        <PropertyColumn Property="o => o.Number" Title="Order" Align="CellAlign.Start" Width="6.Rem" />
        <PropertyColumn Property="o => o.Customer" Sortable />
        <PropertyColumn Property="o => o.Date" Format="MMM d" Sortable Width="8.Rem" />
        <PropertyColumn Property="o => o.Total" Format="C" Sortable Width="8.Rem" />
    </Columns>
</DataGrid>

The search is kept in the URL, so a link or a reload keeps it. It looks for the words in every text column.

When the search matches nothing, the grid says so and offers Clear search. To say it in your words, set NoMatchesText. To show more, such as an EmptyState with an icon and what to try, set NoMatchesContent; Clear search stays under it.

Placing the toolbar's tools

To place the grid's own tools among your buttons, add DataGridSearch, DataGridExport or DataGridColumnPicker to ToolbarContent. They appear in the order written.

Static

Preview

Choose columns

Orders with placed tools
NumberCustomer Total
1001Margaret Hamilton$66.25
1002Katherine Johnson$108.00
1003Grace Hopper$149.75
1004Barbara Liskov$191.50
1005Linus Torvalds$233.25

Code

ToolbarOrder.razor
@* The grid's own tools among yours, in the order written: what shapes the view at the start, what acts on the
   data at the end, with the main action last. Export has its text; the others are as usual. *@
@using Rows = IzzyBlazor.Site.Examples.Table.Orders
<DataGrid Items="Rows.All" PageSize="5" Caption="Orders with placed tools" Searchable ColumnPicker LayoutKey="order-tools" QueryPrefix="placed-" ExportCsvHref="/examples/orders.csv" ExportExcelHref="/examples/orders.xlsx" Grow>
    <ToolbarContent>
        <DataGridSearch />
        <DataGridColumnPicker />
        <ToolbarIconButton Icon="Lucide.CircleQuestionMark" Label="Help" Position="ToolbarPosition.End" />
        <DataGridExport Position="ToolbarPosition.End" ShowLabel />
        <ToolbarButton StartIcon="Lucide.Plus" Position="ToolbarPosition.End" Priority="1">Add order</ToolbarButton>
    </ToolbarContent>
    <Columns>
        <PropertyColumn Property="o => o.Number" Align="CellAlign.Start" Width="8.Rem" />
        <PropertyColumn Property="o => o.Customer" Sortable />
        <PropertyColumn Property="o => o.Total" Format="C" Sortable Width="8.Rem" />
    </Columns>
</DataGrid>

Add them directly, not inside a component of your own. A tool you don't add stays in its usual place, and the grid's parameter still turns it on.

Export and Columns show only an icon with a tooltip. To add text to both, set ToolbarLabels; to add it to one, set its ShowLabel.

To float the Add button in the screen's corner on a phone, add DataGridAdd with FloatBelow="Breakpoint.Sm". Columns and Export are in the … menu on a phone.

A column's filter in the toolbar

To put the filter people use most beside the search, such as Status, add a DataGridFilter with the column's key in Column. The column must be Filterable.

Static

Preview

Orders with a status filter
Number
Customer
Status
Total
1001Margaret HamiltonFailed$66.25
1002Katherine JohnsonRefunded$108.00
1003Grace HopperPending$149.75
1004Barbara LiskovPaid$191.50
1005Linus TorvaldsFailed$233.25

Code

ToolbarFilter.razor
@* Status, the filter people reach for first on an order list, beside the search; the column's header leaves its
   funnel to it. The other columns keep theirs. *@
@using Rows = IzzyBlazor.Site.Examples.Table.Orders
<DataGrid Items="Rows.All" PageSize="5" Caption="Orders with a status filter" Searchable QueryPrefix="tf-" Grow>
    <ToolbarContent>
        <DataGridSearch />
        <DataGridFilter Column="Status" />
    </ToolbarContent>
    <Columns>
        <PropertyColumn Property="o => o.Number" Align="CellAlign.Start" Width="8.Rem" />
        <PropertyColumn Property="o => o.Customer" Sortable Filterable />
        <PropertyColumn Property="o => o.Status" Filterable Width="9.Rem" />
        <PropertyColumn Property="o => o.Total" Format="C" Sortable Width="8.Rem" />
    </Columns>
</DataGrid>

It opens the column's own filter and says what it's set to, such as "Status: Paid". It keeps the same keys in the URL, and the column's header leaves out its funnel. Write it in the grid's ToolbarContent, not outside the grid.

A grid in a tile

To put the grid's tools in a Tile's header, write them in its HeaderEnd. They act on the grid in the tile, and the grid leaves its toolbar out, so the tile has one header row.

Static

Preview

Recent orders

Recent orders
OrderCustomer Date Total
1001Margaret HamiltonSep 8$66.25
1002Katherine JohnsonSep 15$108.00
1003Grace HopperSep 22$149.75
1004Barbara LiskovSep 29$191.50
1005Linus TorvaldsOct 6$233.25

Code

InTile.razor
@* A dashboard's orders tile: the grid's search, columns and export sit in the tile's header, so the
   tile has one header row. *@
@using Rows = IzzyBlazor.Site.Examples.Table.Orders
<TileLayout Columns="1" aria-label="Sales">
    <Tile Id="orders" Title="Recent orders" RowSpan="3" Flush>
        <HeaderEnd>
            <DataGridSearch />
            <DataGridExport />
            <DataGridColumnPicker />
        </HeaderEnd>
        <ChildContent>
            <DataGrid Items="Rows.All" PageSize="5" Caption="Recent orders" Searchable ColumnPicker LayoutKey="tile-orders" QueryPrefix="tile-" ExportCsvHref="/examples/orders.csv" Grow>
                <Columns>
                    <PropertyColumn Property="o => o.Number" Title="Order" Align="CellAlign.Start" Width="8.Rem" />
                    <PropertyColumn Property="o => o.Customer" Sortable />
                    <PropertyColumn Property="o => o.Date" Format="MMM d" Sortable />
                    <PropertyColumn Property="o => o.Total" Format="C" Sortable Width="8.Rem" />
                </Columns>
            </DataGrid>
        </ChildContent>
    </Tile>
</TileLayout>

Outside a tile or card, set a tool's For to the grid's id. A search box outside the grid still posts the grid's form, so it works with JavaScript off.

To make Add the page's main button, put DataGridAdd with For in a PageHeader's PageHeaderActions. There it's the page's button size, and with FloatBelow it floats in the corner on a phone.

A DataGridFilter stays in the grid's ToolbarContent: it takes over the column's own filter, which lives with the grid.

Connection lost

Rejoining the server…