Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Mathiew on Jan 26, 2009 07:45
open dhtmlx forum
problem with enableOptionAutoWidth and spaces

I have a problem with the enableOptionAutoWidth function of dhtmlXCombo : the width adapts to the longest word of the option, not to the whole text of the option.

For exemple :
with this option :
<option value="1">d123 appareils automatiques</option>

the width of the combobox adapts to "automatiques", not to "d123 appareils automatiques".


Here is the javascript (/dhtmlxcombo_whp.is incuded) :

var z=new dhtmlXCombo("combo_zone1","alfa1","100");
z.loadXML("liste_codes_taxe.xml");
z.enableOptionAutoWidth(true); // enables auto width of combo options
    
    
Here is the xml file encoded in utf-8 :

<?xml version="1.0" encoding="UTF-8" ?>
<complete>
    <option value="1">d123 appareils automatiques</option>
    <option value="2">d234 droits de circulation vins mousseux</option>
    <option value="3">d345 droits de circulation vins tranquilles</option>
</complete>
Answer posted by Support on Jan 26, 2009 09:19
Combo allows to use wrap text inside options, and prefers it other sizing combo-list area. 
You can change behavior by adding next css style to the page. 

.dhx_combo_list div{
   white-space:nowrap;
}
Answer posted on Jan 26, 2009 09:51
Thank you very much, it worked.

I had to change the overflow-x to let it overflow the combobox :

.dhx_combo_list{
   overflow-x:auto;
  
}