EDIT: Title should say *Can't* enable/disable DropDownList rather than *Can*
I have a Dialog component with a DropDownList and a MultiSelect. When no items are selected in the MultiSelect, I want the DropDownList to be disabled. I've set it up like so:
<TelerikDropDownList Data="@Data" @bind-Value="@SelectedValue" Enabled="@IsEnabled"/>
<TelerikMultiSelect Data="@SelectData"
TextField="Text"
ValueField="TheValue"
OnChange="@SelectChange"
@bind-Value="@SelectValue"/>
@code {
public class MyData
{
public string Text { get; set; }
public string TheValue { get; set; }
}
private string @SelectedValue { get; set; } = "One";
private List<string> Data { get; set; } =
[
"One",
"Two",
"Three"
];
private List<MyData> SelectData { get; set; } =
[
new MyData { Text = "One", TheValue = "1" },
new MyData { Text = "Two", TheValue = "2" },
new MyData { Text = "Three", TheValue = "3" }
];
private List<string> SelectValue { get; set; } = [];
private bool IsEnabled = false;
private void SelectChange()
{
IsEnabled = SelectValue.Count > 0;
}
}
When I put the DropDownList and MultiSelect directly into a Dialog, this doesn't work. Specifically, when I add items to the MultiSelect, the DropDownList doesn't get enabled. However, when I move this exact same code into a separate component and then embed THAT component into the Dialog, then it does. Any ideas why that would be?
I have a reproduction of the issue here: https://github.com/kbaley/TelerikBlazor/blob/main/TelerikBlazor/TelerikBlazor.Client/Pages/Home.razor
EDIT: I've tried calling StateHasChanged in the SelectChange handler but it doesn't change the behaviour.