in my Blazor Project i try a Datagrid with Blazorise. For one value i have a (Multi)SelectList in the EditTemplate to select one or more entries from the shipment table. I would like to highlight the previous selected shipments in case the user reopen the selected visit in "Edit Mode". Is this possible? Regards Lars
<DataGridSelectColumn Field="@nameof(Visit.VisitShipment)" Caption="Lieferung" Width="600px" Sortable Editable>
<DisplayTemplate>
@if (context != null)
{
<div>
@foreach (var visitShipment in allVisitShipments.Where(v => v.VisitId == context.Id).ToList())
{
var shipment = allShipments.FirstOrDefault(a => a.Id == visitShipment.ShipmentId);
if (shipment != null)
{
<div>@($"{shipment.OrderNo} - {shipment.ShipToName}") </div>
}
}
</div>
}
</DisplayTemplate>
<EditTemplate>
<SelectList Multiple
TItem="Shipment"
TValue="int"
Data="@openShipments"
TextField="@((item) => item.OrderNo + ", " + item.ShipToName)"
ValueField="@((item) => item.Id )"
@bind-SelectedValues="@selectedVisitShipment"
DefaultItemText="Bitte Auftrag auswählen" />
</EditTemplate>
</DataGridSelectColumn>
I thought the reason for this is a problem with my selectedVisitShipment . So i tried several ways to update selectedVisitShipment and openShipments but with but without success. I have to say that i am a newbie to all this stuff.
The hint was good. I had made a mistake in my thinking. The
selectedVisitShipmentlist was still empty. I have now triggered the update via aSelectedRowChanged. Now, the entries are marked in edit mode. I also changed to@bind-SelectedValues="@selectedVisitShipment". Now it works.