Row actions
Since 0.1.0-alpha.20Each 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.
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
| Order | Customer | Note | Priority | Actions | More |
|---|---|---|---|---|---|
| 1001 | Margaret Hamilton | ||||
| 1002 | Katherine Johnson | ||||
| 1003 | Grace Hopper | ||||
| 1004 | Barbara Liskov | ||||
| 1005 | Linus Torvalds | ||||
| 1006 | Alan Turing | ||||
| 1007 | Ada Lovelace | ||||
| 1008 | Margaret Hamilton | ||||
| 1009 | Katherine Johnson | ||||
| 1010 | Grace Hopper | ||||
| 1011 | Barbara Liskov | ||||
| 1012 | Linus Torvalds | ||||
| 1013 | Alan Turing | ||||
| 1014 | Ada Lovelace | ||||
| 1015 | Margaret Hamilton | ||||
| 1016 | Katherine Johnson | ||||
| 1017 | Grace Hopper | ||||
| 1018 | Barbara Liskov | ||||
| 1019 | Linus Torvalds | ||||
| 1020 | Alan Turing | ||||
| 1021 | Ada Lovelace | ||||
| 1022 | Margaret Hamilton | ||||
| 1023 | Katherine Johnson |
Code
@* 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. *@
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>
{
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; }
}
}