如何解决使 MudBlazor 表的一行可点击?
我用 MudBlazor 制作了这张桌子:
<MudTable ServerData="@(new Func<TableState,Task<TableData<DossierInfo>>>(GetServerData))"
RowsPerPage="@_PageSize"
Dense="true"
Hover="true"
Bordered="false"
Striped="true"
Outlined="true"
Filter="new Func<DossierInfo,bool>(FilterFunc)" Elevation="0">
<ToolBarContent>
<MudTextField @bind-Value="searchString" Label="Ricerca" Placeholder="Digitare il testo da ricercare" Variant="Variant.Filled" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.Search" />
<!--<MudTextField @bind-Value="searchString" Placeholder="Search" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.Search" IconSize="Size.Medium"></MudTextField>-->
</ToolBarContent>
<HeaderContent>
<MudTh>Tipo</MudTh>
<MudTh>Nr</MudTh>
<MudTh>Targa</MudTh>
<MudTh>Tipo veicolo</MudTh>
<MudTh>marca</MudTh>
<MudTh>Modello</MudTh>
<MudTh>Km</MudTh>
<MudTh>Totale validato</MudTh>
<MudTh>Data apertura OL</MudTh>
<MudTh></MudTh>
</HeaderContent>
<RowTemplate>
<MudTd DataLabel="Tipo pratica"><MudIcon Icon="@DossierTypeIconService.GetDossierTypeIcon(context.Type)"></MudIcon></MudTd>
<MudTd DataLabel="Numero">@context.Number</MudTd>
<MudTd DataLabel="Targa">@context.VehiclePlate</MudTd>
<MudTd DataLabel="Tipo veicolo">@context.VehicleType</MudTd>
<MudTd DataLabel="marca">@context.VehicleMake</MudTd>
<MudTd DataLabel="Modello">@context.VehicleModel</MudTd>
<MudTd DataLabel="Km">@context.VehicleKm</MudTd>
<MudTd DataLabel="Totale validato">@context.ValidatedTotalAmount</MudTd>
<MudTd DataLabel="Data apertura OL">@context.OpenedDate</MudTd>
<MudTd DataLabel="Azioni" Style="text-align:right">
<MudButton Variant="Variant.Filled" disableElevation="true" Color="Color.Primary" Size="Size.Small" OnClick="@((e) => TodossierDetail(@context.Id))"><strong>Apri</strong></MudButton>
</MudTd>
</RowTemplate>
<PagerContent>
<MudTablePager PageSizeOptions="@_pageSizeOption" RowsPerPageString="Pratiche per pagina" />
</PagerContent>
我不知道这是否可行,但我想让表格的每一行完全可点击以访问每个达析报告的信息,而不是像现在这样使用 MudButton。我在主要的 MudBlazor 网站上进行了搜索,但没有找到任何相关信息。
解决方法
您可以使用事件回调 OnRowClick
。
示例:
<MudTable
ServerData="@(new Func<TableState,Task<TableData<DossierInfo>>>(GetServerData))"
T="YourT"
OnRowClick="@RowClicked">
// ...
</MudTable>
代码:
public void RowClicked(TableRowClickEventArgs<YourT> p)
{
// Example:
NavigationManager.NavigateTo($"/DossierInfo/{p.Item.IdDossier}");
}
MudTable<T>
的完整 API 文档:https://mudblazor.com/api/table
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。