<SfMultiSelect ID="SelectAttendees" Placeholder="e.g. Australia" @bind-Value="@MultiVal" Mode="@VisualMode.CheckBox" DataSource="@Country">
<MultiSelectFieldSettings Value="Code" Text="Name"></MultiSelectFieldSettings>
</SfMultiSelect>
<button @onclick="@UpdateValue">Dynamically update value</button>
@code {
public string[] MultiVal { get; set; }
public void UpdateValue()
{
MultiVal = new string[] { "BM", "CA" };
}
public class Countries
{
public string Name { get; set; }
public string Code { get; set; }
}
List<Countries> Country = new List<Countries>
{
new Countries() { Name = "Australia", Code = "AU" },
new Countries() { Name = "Bermuda", Code = "BM" },
new Countries() { Name = "Canada", Code = "CA" },
new Countries() { Name = "Cameroon", Code = "CM" },
};
} |
Ok, I got this to work... EXCEPT. It only works with an array of string. If you try to use an array of <T> where T is a simple class, then it always returns null when you click a button etc. So although now I can select and retrieve a list of initials, I have to do an additional lookup in the database to retrieve the Id's for those initials.And with this construct, assigning a list of values at runtime in either OnParameterSet or OnInitialize events doesn't seem to assign it. Do I need to do this in the PreRender event perhaps?TIA,Miles