Search code examples
mudblazor

MudDataGrid row select using SelectColumn doesnt display


(MudBlazor 6.6.0, dotnet core 6.0)

I have constructed my first MudDataGrid based on an observable collection of 'product's

public partial class Product
{
    public string? Name { get; set; }
    public decimal? Price { get; set; }
    public decimal? Quantity { get; set; }
    public long ProductId { get; set; }
}

and my grid

<MudDataGrid MultiSelection="true" Items="observableProducts" ReadOnly="false" EditMode="DataGridEditMode.Cell">
    <Columns>
        <SelectColumn T="Product" />
        <PropertyColumn Property="x => x.Name" Title="Name" />
        <PropertyColumn Property="x => x.Price" Title="Price" />
        <PropertyColumn Property="x => x.Quantity" Title="Quantity" />
    </Columns>
</MudDataGrid>

based on https://mudblazor.com/components/datagrid#advanced-data-grid

but I get no 'select' tickbox on the row, I get one in the column title and footer.

grid with no tick box

What am I missing? do the items in the grid need to implement some attribute to track selection?

(I can't find any significant docs except the the one stated, which demonstrates techniques but leaves out some of the details)


Solution

  • <MudDataGrid MultiSelection="true" Items="observableProducts" ReadOnly="false" EditMode="DataGridEditMode.Cell">

    Since you've added a ReadOnly="false" & EditMode="DataGridEditMode.Cell" This means that the DataGrid cells are always in an editing state therefore, the tickbox will not show.

    You will have to change either of these properties in order for the multiselect tickbox to show.

    MudBlazor snippet