Disabled Items in Blazor ComboBox Component

4 Nov 20253 minutes to read

The ComboBox allows individual items to be enabled or disabled based on application logic. Map a boolean field from the data source to the Disabled property in field settings to mark specific items as disabled. Disabled items remain visible but cannot be selected as the value of the component.

In the following sample, items are disabled based on a data field mapped to Disabled.

  • CSHTML
  • @using Syncfusion.Blazor.DropDowns
    
    <SfComboBox TValue="string" TItem="StatusData" Placeholder="Select Status" DataSource="@LocalData">
        <ComboBoxFieldSettings Value="Text" Disabled="State" ></ComboBoxFieldSettings>
    </SfComboBox>
    
    @code {
    
        public IEnumerable<StatusData> LocalData { get; set; } = new StatusData().StatusDataList();
    
        public class StatusData
        {
            public string Text { get; set; }
            public bool State { get; set; }
    
            public List<StatusData> StatusDataList()
            {
                List<StatusData> staus = new List<StatusData>();
                staus.Add(new StatusData { Text = "Open", State = false });
                staus.Add(new StatusData { Text = "Waiting for Customer", State = false });
                staus.Add(new StatusData { Text = "On Hold", State = true });
                staus.Add(new StatusData { Text = "Follow-up", State = false });
                staus.Add(new StatusData { Text = "Closed", State = true });
                staus.Add(new StatusData { Text = "Solved", State = false });
                staus.Add(new StatusData { Text = "Feature Request", State = false });
                return staus;
    
            }
        }
    }

    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 Not applicable for Blazor ComboBox; update the data-bound Disabled field instead.
    itemIndex number Not applicable for Blazor ComboBox; update the data-bound Disabled field instead.

    Enabled

    To disable the entire component, set the Enabled property to false.

    Disabled ComboBox Component