This is a migrated thread and some comments may be shown as answers.

[Solved] Disabling ComboBox Items

3 Answers 150 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Beth
Top achievements
Rank 1
Beth asked on 15 Mar 2012, 04:13 PM

Hi,

I have a ComboBox that is defined as follows:

 

 

@(Html.Telerik().ComboBoxFor(m => m.AvailablePIDs)
.Name("ComboPids")
.HtmlAttributes(new { style = "width:400px;vertical-align:baseline" })
.Filterable(f => f.FilterMode(AutoCompleteFilterMode.Contains))
.ClientEvents(events => events.OnChange("onComboPidsChange"))
.BindTo(Model.AvailablePIDs)                                    
 )

 
After the data is bound to this control, I want to go in and disable certain items in the drop down, and I can't for the life of me figure out how to do it.  In the API I see a way to disable the entire control, but no way to access the individual items other than to highlight them.  Is there an easy way to disable items in a drop down?

Any help would be greatly appreciated.

Thanks,
Beth

3 Answers, 1 is accepted

Sort by
0
william
Top achievements
Rank 1
answered on 15 Mar 2012, 06:46 PM
surely, if you dont want the items to be selectable you shouldn't include them in the list in the first place. I'd change the underlying data that your binding to and just not include them.
0
Beth
Top achievements
Rank 1
answered on 15 Mar 2012, 08:21 PM
I agree, however, I don't make the rules.  I'm in a situation where groups are being created and each product can only belong to one group.  They want to see all the products but be able to visually determine which products already belong to other groups so there is no confusion about why a particular product is missing from the list.  Currently we are showing all products but giving an error if they select one that belongs to another group.
0
william
Top achievements
Rank 1
answered on 16 Mar 2012, 09:27 AM
I dont think what you are trying to do with the dropdowns is possible. I think you will struggle to find any dropdown control that could cater for that, since dropdown controls are generally designed to allow you to select from the list. The only way I can think is that in genreal, these lists use an id of some sort and the textual value. behind your code when you first build the list you could set all id's for those not selecteable above say 5000 then in the combo's onchange event check the value of the ID if it's greater than 5000 then cancel the event. this may stop them from selecting the item. Furthermore for those items that are not selectable, you could place a * or something at the front of the text to aid the user.

The other way may be to supply a 'helper' list of those items already selected and thus not available. The user ould always refer to this list if they need to check for an item that has already been selected.
Tags
ComboBox
Asked by
Beth
Top achievements
Rank 1
Answers by
william
Top achievements
Rank 1
Beth
Top achievements
Rank 1
Share this question
or