使MudBlazor表的行可点击?
我用MudBlazor做了这张桌子:使MudBlazor表的行可点击?,blazor,Blazor,我用MudBlazor做了这张桌子: <MudTable ServerData="@(new Func<TableState, Task<TableData<DossierInfo>>>(GetServerData))" RowsPerPage="@_PageSize" Dense="true" Hover="true" Bor
<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>
蒂波
天然橡胶
塔尔加
蒂波维科洛
马卡
莫代洛
公里
全部验证
数据孔径
@上下文。数字
@上下文。车辆板
@context.VehicleType
@汽车制造
@context.VehicleModel
@车辆公里
@context.ValidatedTotalAmount
@context.OpenedDate
Apri
我不知道这是否可行,但我想让表格的每一行都可以完全点击以访问每个档案的信息,而不是像现在这样使用MudButton。我在MudBlazor主站点上搜索过,但没有找到任何相关信息。您可以使用eventcallback:“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}");
}
public void行单击(TableRowClickEventArgs p)
{
//例如:
NavigationManager.NavigateTo($“/DossierInfo/{p.Item.IdDossier}”);
}
这似乎有效,但当我将函数放在onrwoclick上时,我应该在@rowclicked()parentese之间放置什么?什么都没有。阅读有关委托和事件+(回调)的内容以了解它们是如何工作的事实是,如果我这样说,它会给我一个错误,它说它无法从“一组方法”转换为“事件回调”您是否用适当的类型替换了“YourT”?我想是的,我在其中添加了DossierInfo,这就是TableData中存在的类型。我在网上看过其他的例子,它们都在表格数据字段中输入了一种类型。对不起,我对这门语言很陌生,所以我不太擅长。