How does one handle a null PropertyColumn in joined table in quickGrid?

96 Views Asked by At

This is my quickgrid:

<QuickGrid Items="@Items" Theme="MyGrid" @ref="quickGrid" Pagination="@pagination">
     <PropertyColumn Property="@(p => p.Id)" Sortable="true" Class="p-2" />
     <PropertyColumn Property="@(p => p.LabelCode)" Sortable="true" Class="p-2" />     
     <PropertyColumn Property="@(p => p.Employee.Name)" Sortable="true" Class="p-2" />
 </QuickGrid>

This is my dbContext:

_dbContext.Asset   
    .Include(c => c.Employee)
    .ToListAsync();

EmployeeId is nullable.

If EmployeeId is null, the grid doesn't work.

How can I handle this to show empty cell?

1

There are 1 best solutions below

0
On BEST ANSWER

i use this solution for now:

<TemplateColumn Title="Employee" Class="p-2" Sortable="true">
    @if (context.EmployeeId != null)
    {
        <span> @context.Employee.Name </span>
    }
</TemplateColumn>