<MudDataGrid Items="@Data">
<Columns>
<PropertyColumn Property="x => x.Id"/>
<PropertyColumn Property="x => x.Title" Title="Title"/>
</Columns>
</MudDataGrid>
How to add a link to Id
property using MudBlazor?
You could use TemplateColum
to make a custom column for Id
<MudDataGrid Items="@Data">
<Columns>
<TemplateColumn >
<HeaderTemplate>Id</HeaderTemplate>
<CellTemplate>
<MudLink Href="@($"/otherpage/{@context.Item.Id}")">@context.Item.Id</MudLink>
</CellTemplate>
</TemplateColumn>
<PropertyColumn Property="x => x.Title" Title="Title" />
</Columns>
</MudDataGrid>
@code{
List<Message> Data { get; set; } = new List<Message>
{
new Message{Id=1,Title="title1"},
new Message{Id=2,Title="title2"}
};
public class Message
{
public int Id{ get; set;}
public string Title { get; set; }
}
}