Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Andres on Nov 20, 2009 10:55
open dhtmlx forum
Dhtmlx Combo

Hello again,

I`m working on PRO version of Dhtmlx.
I have a dhtmlXCombo with "n" options and I want each option to store apart from the value="" and text, extra attributes, for example:

<complete>
    <option code="ABCD" value="2">TEST 1</option>
    <option code="AB 3" value="3">TEST 2</option>
    <option code="A 1" value="1">TEST 3</option>
</complete>

Is there a way to do this and the retrieve this values?

Thanks a lot
Andres
Answer posted by Alex (support) on Nov 23, 2009 01:45

Hello,

there is no public method to add additional attributes to the option. But custom solution is possible.

For example, if you want to add "code" attribute, the dhtmlxcombo.js should be modified as follows:

try to locate dhtmlXCombo_defaultOption.prototype.setValue = function(attr){ line and add here the highlighted line:

dhtmlXCombo_defaultOption.prototype.setValue = function(attr){
  this.value = attr.value||"";
  this.text = attr.text||"";
  this.css = attr.css||"";
  this.content=null;
  this.code = attr.code||"";
}

To get code value you can use var combo = combo.getOption(optionValue).code approach.

Answer posted by Andres on Nov 23, 2009 04:58
Thanks a lot Alex!
It worked perfect.