ComboBox getOptionByLabel() throws Exception on special char

My data string has some special characters in it (&, <, etc.) and getOptionByLabel throws an Exception.  I tried escaping the character as well as putting in the html syntax for them but it still threw an exception.  If wanting to use an “&” what syntax should be sent to getOptionByLabel() so that it doesn’t throw an exception?


Possibly the following example will help.

if xml is

The option can be got by:

var option = combo.getOptionByLabel(“some&text”);

Combo shows “some&text” as option text on the page.

The xml is

<option value=“28>Z&AA&123-&ZZ</option>

and the code to get the option is

var option = combo.getOptionByLabel(“Z&AA&123-&ZZ”);

I have also tried

var option = combo.getOptionByLabel(“Z&AA&123-&ZZ”);

and this throws an exception as well.

Please, take a look at the attached sample. Possibly it’ll help to resolve the issue (16.6 KB)

Nothing shows up on the html page from the xml initialization…

I don’t understand the “!CDATA” string.  Is it just a random string value or is this supposed to be attached to strings with special characters?

I changed my xml to look like the following, but I am still getting an exception when calling combo.getOptionByLabel(“Z&AA&123-&ZZ”);

  2009-04-20 14:04:34
  Airborne Systems

What is wrong with the above?

Is there a way to print out all of the options of the combo box?

>> What is wrong with the above?

If the 4th column has “combo” type, you can use getOptionByLabel method as follows:


var combo.getColumnCombo(3);


Locally it works correctly.

If issue still persists, please provide the sample to (combo excell is available only in PRO version)

>> Is there a way to print out all of the options of the combo box?

Unfortunately there is not public method to get all options of combo.

But you can use the internal property - optionsArr array:

var text = [];

for(var i=0; i<combo.optionsArr.length; i++)
text[i] = combo.optionsArr[i].text;

combo.getOptionByLabel(“Z&AA&123-&ZZ”); DOES NOT WORK but

combo.getOptionByLabel(“Z&AA&123-&ZZ”); DOES work.  Why does it have to be stripped of the html syntax even though the grid contains the html syntax?


Which combo version do you use ?

Please, try to use the latest combo (it can be downloaded from our website).

With it combo.getOptionByLabel(“Z&AA&123-&ZZ”); works.

We are using

dhtmlxCombo v.1.3 Standard edition build 81009

The version, that you use, is not the latest. The latest one is 9026 and it is available on our website.

Why does the xml need the CDATA encoding?  & is valid xml?

Yes, & gives valid xml. So, using CDATA is not necessary.

If we don’t use the CDATA syntax, it doesn’t work.

We are using grid.xml:

<?xml version="1.0" encoding="UTF-8" ?>

- <complete>
  <option value="27">A&B&C&D</option>
  <option value="10">newCust</option>
custComboBox = new dhtmlXCombo("CustCombo", "CustCombo", 200);
The option on the combo box with the ampersands does not show up normally on the combo box screen.  It gets truncated.
Screen shot.rtf (5.58 MB)

Please, check attached sample - all is correct here. (17.4 KB)

When I view the sample the drop down is not correct

Sorry for teh misleading information.

Actually, yes, the &d is not shown.

Possibly IE tries to read &D as some special symbol.

So, please, use CDATA to place the correct html into the combo:


If you don’t use it, A&B&C&D is placed into the combo.

I don’t think it’s a problem with IE.  When displaying the same information in the dhtmlxgrid component, I was getting the same behavior until I specified setColType(“rotxt”) to account for the special character.  This fixed the string so that it displayed correctly.  Is there something similar to specify the types of the string values in the combo box?