I was tring to disable a couple of options in the dropdown list, but for some reason I keep getting this error:
The wiki also didn't give much information about how to use this attribute.
I was tring to disable a couple of options in the dropdown list, but for some reason I keep getting this error:
The wiki also didn't give much information about how to use this attribute.
If you are binding to IEnumerable<string>
this is expected.
what am I supposed to bind it to? If I want to disable multiple items?
Could I get some more help with this?
I don’t have anything else to add, you can check our demos for reference on how to use DisabledProperty, TextProperty and ValueProperty.
The demo displays the use of a string to disable values, but when I enter a string I get the same error from before.
The DisabledProperty needs the name of an existing model property specified as a string. In our demo the name of that property is Discontinued. The DropDownList is bound to IEnumerable<Product>
and the Product class has a boolean property called Discontinued
. The value of that property determines if in an item is disabled or not.
<RadzenDropDown @bind-Value=@value
Data=@products
TextProperty="ProductName"
ValueProperty="ProductID"
DisabledProperty="Discontinued"
/>
@code {
int value = 1;
IEnumerable<Product> products;
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
products = dbContext.Products;
}
}
We are not sure how your dropdown is configured but the exception suggests its Data attribute is set to IEnumerable<string>
and the string
type does not have a Discontinued property hence the exception. Long story short you should set the Data of your dropdown to a collection of classes that have properties if you want to use DisabledProperty, TextProperty or ValueProperty.