I have RadzenDropDown whose data comes from other components or DB and need to load pre-selected items, I could not find a way to do that. For example below, "allExpressions" comes from other control where few items are already pre-selected.
List allExp = "a","b","c","d" but "b" and "c" should be checked when loaded in.
<RadzenDropDown
AllowFiltering="true"
FilterOperator="StringFilterOperator.Contains"
FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive"
Multiple="true"
Data="@allExpressions "
TValue="IEnumerable"
@bind-Value="expressionNameList"
TextProperty="Name"
ValueProperty="Name"
Change="@(args => OnChangeExpression(args))" />
korchev
September 20, 2020, 7:29am
2
Hi @ShishirDahal ,
You can refer to the DropDown demo . The one which has multiple selection enabled shows how to select multiple values.
<RadzenDropDown @bind-Value="multipleValues"
Multiple="true"
Data="@customers"
TextProperty="CompanyName"
ValueProperty="CustomerID"
/>
@code {
IEnumerable<string> multipleValues = new string[] { "ALFKI", "ANATR" };
}
1 Like
What if you were to have a List of variables that you want to load into the drop down? For example a List of integers.
The last DropDown from the example has the same configuration:
<RadzenDropDown AllowClear="true" AllowFiltering="true" Multiple="true" FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive" Data=@products
@bind-Value=@multipleValuesdisabled TextProperty="ProductName"
ValueProperty="ProductID" DisabledProperty="Discontinued" Change=@(args => OnChangeDisabled(args, "DropDown with multiple selection")) Class="w-100" />
@code {
IEnumerable<int> multipleValuesdisabled = new int[] { 1,2 };
}