Conditional Column is added at the end of a data grid

So I have this table which I filter using custom filter selects. I have one filter ("Stockfahrzeuge"), that is supposed to add an additional column to the data grid when it is used ("Standtage"). But the column isn't added where it is supposed to be, but rather as a last column at the end of the grid:

 <RadzenDataGridColumn TItem="IndexViewModel" Property="IsStock" Title="Stockfzg." Width="110px">
    <Template Context="data">
    @if (data.IsStock)
     {
           <span class="badge bg-primary">Stock</span>
     }
    </Template>
</RadzenDataGridColumn>

    @if (isStock) **// this is the attribute the "Stockfahrzeuge" filter is bound to.** 
     {
<RadzenDataGridColumn TItem="IndexViewModel" Property="StandingDays" Title="Standtage" Width="110px">
     <Template Context="data">
         <span class="badge bg-primary">@data.StandingDays</span>            
     </Template>
</RadzenDataGridColumn>
     }
<RadzenDataGridColumn TItem="IndexViewModel" Property="DeliveryDateCustomer.Value" Title="Lieferdatum Kunde" Width="110px">
                <Template Context="data">
                    @if (data.DeliveryDateCustomer.HasValue)
                    {
                        @data.DeliveryDateCustomer.Value.ToShortDateString()
                    }
                </Template>
 </RadzenDataGridColumn>
<RadzenDataGridColumn TItem="IndexViewModel" Property="InvoiceReceiver" Title="Rechnungsempfänger" />
<RadzenDataGridColumn TItem="IndexViewModel" Property="Customer" Title="Kunde" Width="180px" />
<RadzenDataGridColumn TItem="IndexViewModel" Property="CommNrReprise" Title="Komm.-Nr. Reprise" Width="150px" />
<RadzenDataGridColumn TItem="IndexViewModel" Property="RepriseProcessed" Title="Reprise bearb." Width="120px">

This thread might help you: Blazor Grid Column Order - #10 by mconrad

1 Like