Skip to content
IzzyBlazor

Enter all results ↑ ↓ move Esc close

Row actions

Since 0.1.0-alpha.20
Each row's actions sit at its end or in a ⋯ menu, and cells can hold your own buttons, links and fields.

Row menus

A row menu is a ⋯ button on each row that opens the row's actions. Add an ActionColumn of RowActions and set its Overflow to RowActionOverflow.Always.

Static

Preview

Orders with menus
OrderCustomerTotalActions
1001Margaret Hamilton$66.25
1002Katherine Johnson$108.00
1003Grace Hopper$149.75
1004Barbara Liskov$191.50
1005Linus Torvalds$233.25

Code

RowMenu.razor
@* Right-click a row, press and hold it on a phone, or press Shift+F10 on a cell: the same menu as its
   ⋯ button, which works with no script. A paid order has no Cancel. *@
@using Rows = IzzyBlazor.Site.Examples.Table.Orders
@inject NavigationManager Navigation
<DataGrid Items="Rows.All" PageSize="5" Caption="Orders with menus" ItemKey="o => o.Number.ToString()" QueryPrefix="menus-" Grow>
    <Columns>
        <PropertyColumn Property="o => o.Number" Title="Order" Align="CellAlign.Start" Width="6.Rem" />
        <PropertyColumn Property="o => o.Customer" />
        <PropertyColumn Property="o => o.Total" Format="C" Width="8.Rem" />
        <ActionColumn Context="order" Overflow="RowActionOverflow.Always">
            <RowAction Label="@($"View {order.Number}")" Href="@Navigation.GetUriWithQueryParameter("order", order.Number)" />
            <RowAction Label="@($"Cancel {order.Number}")" Href="@Navigation.GetUriWithQueryParameter("cancel", order.Number)" Visible="order.Status != Table.OrderStatus.Paid" />
        </ActionColumn>
    </Columns>
</DataGrid>

With IzzyBlazor's script, a right-click or a long press opens the same menu. The menu acts on the row it was opened from, whatever is selected.

Right-clicking a link still opens the browser's own menu.

Controls in cells

To put buttons, links or fields in cells, use a TemplateColumn. The keys that reach them are in the Keyboard table.

Static

Preview

Orders to review
OrderCustomer NotePriorityActionsMore
1001Margaret Hamilton
1002Katherine Johnson
1003Grace Hopper
1004Barbara Liskov
1005Linus Torvalds
1006Alan Turing
1007Ada Lovelace
1008Margaret Hamilton
1009Katherine Johnson
1010Grace Hopper
1011Barbara Liskov
1012Linus Torvalds
1013Alan Turing
1014Ada Lovelace
1015Margaret Hamilton
1016Katherine Johnson
1017Grace Hopper
1018Barbara Liskov
1019Linus Torvalds
1020Alan Turing
1021Ada Lovelace
1022Margaret Hamilton
1023Katherine Johnson

Code

Cells.razor
@* Cells that hold controls, small to keep the rows' height. One button or menu takes focus directly;
   with several, or a field that uses the arrows itself, Enter goes in and Escape comes back. The
   header stays in view when the rows scroll. *@
@using Rows = IzzyBlazor.Site.Examples.Table.Orders
<DataGrid Items="Rows.All" ItemKey="o => o.Number.ToString()" MaxHeight="16.Rem" Caption="Orders to review" Grow>
    <Columns>
        <PropertyColumn Property="o => o.Number" Title="Order" Align="CellAlign.Start" Width="6.Rem" />
        <PropertyColumn Property="o => o.Customer" Sortable Width="12.Rem" />
        <TemplateColumn Title="Note" Context="order">
            @{ var review = _reviews[order.Number]; }
            <TextField @bind-Value="review.Note" Label="@($"Note for order {order.Number}")" HideLabel Size="ControlSize.Sm" />
        </TemplateColumn>
        <TemplateColumn Title="Priority" Width="8.Rem" Context="order">
            @{ var review = _reviews[order.Number]; }
            <Select @bind-Value="review.Priority" Items="Priorities" Label="@($"Priority of order {order.Number}")" HideLabel Size="ControlSize.Sm" />
        </TemplateColumn>
        <TemplateColumn Title="Actions" Width="10.Rem" Context="order">
            <Row Gap="1">
                <Button Size="ControlSize.Sm" Variant="ButtonVariant.Outline" Accent="Accent.Neutral">Open</Button>
                <Button Size="ControlSize.Sm" Variant="ButtonVariant.Ghost" Accent="Accent.Neutral">Copy</Button>
            </Row>
        </TemplateColumn>
        <TemplateColumn Title="More" Width="4.Rem" Context="order">
            <Menu>
                <Trigger Context="wire">
                    <IconButton Icon="Lucide.Ellipsis" Label="@($"Actions for order {order.Number}")" Variant="ButtonVariant.Ghost" Accent="Accent.Neutral" Size="ControlSize.Sm" @attributes="wire" />
                </Trigger>
                <ChildContent>
                    <MenuItem>Archive</MenuItem>
                </ChildContent>
            </Menu>
        </TemplateColumn>
    </Columns>
</DataGrid>

@code {
    private static readonly string?[] Priorities = ["Normal", "High", "Low"];

    // Each order's own note and priority, not one shared by every row.
    private readonly Dictionary<int, Review> _reviews = Rows.All.ToDictionary(o => o.Number, o => new Review { Priority = o.Number % 4 == 1 ? "High" : "Normal" });

    private sealed class Review
    {
        public string? Note { get; set; }

        public string? Priority { get; set; }
    }
}

Connection lost

Rejoining the server…