PDA

View Full Version : Combobox -> disable values based on a selection



kvchitnis
13 Nov 2014, 11:39 AM
I have a combobox of various values and there is an option 'All'. If 'All' is selected, the user shouldn't be able to select any other value from the combox.

listeners: {
change : function(me, newVal, oldVal){
var selectVal = (newVal !== null)?newVal:oldVal;
if(selectVal.contains("All")){
// Don't allow user to select any other value
}
}
}

How to acheieve this?

kvchitnis
13 Nov 2014, 2:31 PM
This is atemporary solution->
change: function(me, newVal, oldVal){
var tmp_values;
if((oldVal === "All") && (newVal !== null)){
tmp_values = me.getValue();
delete (tmp_values[0]);
me.setValue(tmp_values);
}else if(newVal.contains("All")){
me.setValue('All');
}
}

If 'All' is selected and any other value is selected, deselect All (always the first value in a combox). If multiple values are selected and 'All' is selected, remove all values and keep only 'All'