I am using a dhtmlxCombo with checkboxes. The values are used to filter a dhtmlxGrid.
When an item is selected it is put in the combo “title box” at the top. That item stays in the title box until another item is selected to replace it. So if that item is later unchecked in the combo, it still shows checked in the title box.
Is there a way to clear the title box after the filter is run?
Thanks, that is working perfectly. I’d like to work on manipulating the header box a little more since the default actions can be misleading with checkboxes (items checked but nothing in the header box and items staying checked in the header box when items in the dropdown are not checked).
Working with checkboxes I want the combo title box to display the first checkbox that is selected. If none are selected I want it to display “”. Here’s the code I’ve worked out so far, but when some items are unchecked, they remain in the title box.
combo.attachEvent("onCheck",function(val,state){
// check/uncheck All if this option selected
if(val=="All"){
for(var i=0; i<this.optionsArr.length; i++){
if(this.optionsArr[i].value != "All"){
this.optionsArr[i].content.firstChild.checked = state;
}
}
}
// combo header
var checked_array = combo.getChecked();
if(checked_array == ""){
// clear combo header if nothing is checked
combo.DOMelem_checkbox.checked = false;
combo.setComboValue("");
}
if(state == true){
// set combo header with selection when item is checked
combo.DOMelem_checkbox.checked = true;
combo.setComboValue(val);
} else if (state == false && checked_array.length > 1){
// if item unchecked but other checked values remain in the array, set combo header to the first checked value in array
var re_sort = checked_array;
re_sort.sort();
combo.DOMelem_checkbox.checked = true;
combo.setComboValue(re_sort[0]);
}
return true;
});
The check All/None box works perfectly. WI check or uncheck one item the title box displays or removes that item correctly. When I check several items, the last checked item displays in the title box, so this is working correctly also. However, when I start unchecking multiple items some items that are unchecked remain in the title box checked. Any ideas on how to achieve the desired action (only checked items to show in the title box) when unchecking boxes and others are still checked?
Get a guaranteed answer from DHTMLX technical support team
under the most suitable support plan