Disabled Items in Blazor MultiSelect Dropdown Component
16 Sep 20243 minutes to read
The MultiSelect provides options for individual items to be either in an enabled or disabled state for specific scenarios. The category of each list item can be mapped through the Disabled field in the data table. Once an item is disabled, it cannot be selected as a value for the component. To configure the disabled item columns, use the MultiSelectFieldSettings.Disabled
property.
In the following sample, State are grouped according on its category using Disabled
field.
@using Syncfusion.Blazor.DropDowns
<SfMultiSelect TValue="string" TItem="TagData" Placeholder="Select Status" DataSource="@LocalData">
<MultiSelectFieldSettings Value="Text" Disabled="State" ></MultiSelectFieldSettings>
</SfMultiSelect>
@code {
public IEnumerable<TagData> LocalData { get; set; } = new TagData().TagDataList();
public class TagData
{
public string Text { get; set; }
public bool State { get; set; }
public List<TagData> TagDataList()
{
List<TagData> tag = new List<TagData>();
tag.Add(new TagData { Text = "Add to KB", State = false });
tag.Add(new TagData { Text = "Crisis", State = false });
tag.Add(new TagData { Text = "Enhancement", State = true });
tag.Add(new TagData { Text = "Presale", State = false });
tag.Add(new TagData { Text = "Needs Approval", State = false });
tag.Add(new TagData { Text = "Approved", State = true });
tag.Add(new TagData { Text = "Internal Issue", State = true });
tag.Add(new TagData { Text = "Breaking Issue", State = false });
tag.Add(new TagData { Text = "New Feature", State = true });
tag.Add(new TagData { Text = "New Component", State = false });
tag.Add(new TagData { Text = "Mobile Issue", State = false });
return tag;
}
}
}
Disable Item Method
The disableItem method can be used to handle dynamic changing in disable state of a specific item. Only one item can be disabled in this method. To disable multiple items, this method can be iterated with the items list or array. The disabled field state will to be updated in the DataSource, when the item is disabled using this method. If the selected item is disabled dynamically, then the selection will be cleared.
Parameter | Type | Description |
---|---|---|
itemValue |
string | number | boolean | object
|
It accepts the string, number, boolean and object type value of the item to be removed. |
itemIndex | number |
It accepts the index of the item to be removed. |
Enabled
If you want to disabled the overall component to set the Enabled property to false.