Hi,
How can I disallow any selection in a dhtmlxcombo with checkboxes? I want the item at index 0 to always remain as the selected item, but allow users to check or uncheck other items in the list without making a selection.
Thanks,
Geoff
hello,
you can try to use the following approach (you should use the attached file instead of the original one):
combo.attachEvent(“onCheck”,function(val){
if(combo.getIndexByValue(val)==0) return false;
else return true;
})
dhtmlxcombo_extra.zip (1.54 KB)
Actually, that’s not quite what I’m looking for. I don’t want to prevent the user from checking any of the checkboxes; I want to prevent them from changing the selected item in the combo. I’m basically trying to disable any “onChange” event. My preference would be that nothing in the list even gets highlighted. Checking and unchecking checkboxes - yes, selecting item in the list and changing selected item - no.
Also, if I create dhtmlxcombo objects using dhtmlXComboFromSelect, and storing them in an ajax prototype Hash collection, can you think of some way that I can access the proper one later when the “onBlur” event occurs?
Example code:
var multiCombos = new Hash(); //Ajax prototype object
var filters = document.getElementsByClassName(‘dhxfilter’); //my code creates this classname
for(var i = 0; i < filters.length; i++) {
if(filters[i].id.substring(filters[i].id.lastIndexOf("_")) == “_multicombo”) { //all “multi” html select controls will have “_multicombo” as part of the id
var tmpcombo = new dhtmlXComboFromSelect(filters[i].id);
tmpcombo.attachEvent(“onBlur”,doSomething);
multiCombos.set(filters[i].id, tmpcombo); //add combo to Hash, key=original select id
}
}
When the “onBlur” event occurs, can you think of some way for me to know which combo caused the event and how I can use that knowledge to access the right object from the Hash? Is there some other value I can use for the key in the Hash object that I can find on the “onBlur” event?
Thanks,
Geoff
Never mind about my second question. I approached it all in a different manner by changing the “onBlur” event in your code to pass the dhtmlxcombo object. Now I am able to do what I want to with the object without holding each one in the Ajax prototype Hash.
I am still looking for an answer to the first question about disallowing a selection.
Thanks,
Geoff
Hello,
it isn’t possible to prevent selection in combo. Probably it will be better to use another component in this case or for example absolute-positioned container as a drop-down with checkboxes.
If you using combo is necessary, you can try to use the following approach to display in header input always the same text and don’t highlight the option while scrolling:
- comment the css class in the dhtmlxcombo.css
.dhx_selected_option{
background-color:navy;
color:white;
}
- use onChange and onSelectionChange events
combo.attachEvent(“onChange”,selectVal)
combo.attachEvent(“onSelectionChange”,selectVal)
function selectVal(){
window.setTimeout(function(){
combo.setComboText(some_text_here);
},1)
}