Is it possible to highlight the previous selected values of a Blazorise Select List?

177 views Asked by At

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.

1

There are 1 answers

0
derLarsonaut On BEST ANSWER

The hint was good. I had made a mistake in my thinking. The selectedVisitShipment list was still empty. I have now triggered the update via a SelectedRowChanged. Now, the entries are marked in edit mode. I also changed to @bind-SelectedValues="@selectedVisitShipment". Now it works.