I want to have a MultiSelect experience for a field in a ListView editor. I'd like the binding to work with the model's navigation collection instead of an ancillary Id collection.
Take the following example where we have a ListView of Appointments. An Appointment has a collection of Contacts called Attendees that we want to manage on Create and Edit with a MultiSelect.
TelerikMultiSelect doesn't like a bind-value with a collection of objects - it wants Ids. One way to solve this could be to do gymnastics with an extra AttendeeIds collection on the Appointment and synchronize that collection with the navigation entities on read/create/update. Is there a way to avoid the gymnastics and solve this case more directly?
Can you provide an example? Thanks.
<TelerikListView TItem="Appointment"...>
...
<EditTemplate>
<TelerikMultiSelect Data="@Contacts" Placeholder="Select attendees" AutoClose="false"
@bind-Value="@context.Attendees" <-this does not work
TextField="@nameof(Contact.Name)" ValueField="@nameof(Contact.Id)"
DebounceDelay="0" />
</EditTemplate>
...
</TelerikListView>
List<Contact> Contacts {get; set;} =[]; //loaded in oninitializeasync
public class Appointment {
public Guid Id {get; set;}
public List<Contact> Attendees {get; set;}
}
public class Contact {
public Guid Id {get; set;}
public string Name {get; set;}
}
...