Combo Questions

I have just started to mess with the Combo control and have several questions:

– It appears that some of the functionality I require may be new. I.e., I can see some API methods on the website, but when I try to use some of them things go inoperative. I’m betting that the version used on the website is now 2.6, whereras I’m using 2.5. Assuming this to be the case, can I use 2.6 Combo with 2.5 other stuff? I’d like to avoid having to retrofit 2.6 all over the place at this point.

– Can you point me to the option/property/method that restricts the value to one of those in the list?

– I would like the combo box value to be different than what’s presented in the list. I.e., something is selected in the list, but only a subset of what’s in the drop-down is left in the input area. For example, the drop-down might have something like this: Hello (Ellopay) / How Are You (Ohay Areay Ouyay) / Goodbye (Oodbyegay) but all I want to have in the cmbo input area when the user selects an option to be Hello, or How Are You, or Goodbye. Would this be possible using one of the events and then setting the text using setComboText?

– Is there a way to add some style formatting to the contents of the drop-down? I.e., to use the example above, suppose I wanted the Hello, How Are You, and Goodbye to be in blue.

– I can see from the samples on the website that there’s a way to set up child combos. I understand that this is a very useful and necessary function. I have a different slant on that I’d like to run by you. Suppose I want to have a series of combos that all have the same data source. For example, suppose you have a 2 x 7 array of such combos, where each combo represents a menu selection of Bread, Water, Gruel, and there’s a combo for the AM and another for the PM, which repeats itself over 7 rows, representing 7 days of the week. In each case the xml loading program reading from a database will function the same. As I see it now, there would end up being 14 separate combo objects. Of course I’m concerned about the overhead if, say, instead of 14 there might be 62 (again, using the silly example, instead of 7 days for a week, 31 days for a month). Any thoughts?

Re: my first point above… by conducting some almost random changes I discovered that the order in which methods are called is important. It is irritating that the documentation is so silent on such matters.

I have succeeded in getting some things to work, but am disappointed in others. For example

enableOptionAutoWidth does not seem to work as it should. It actually shrinks the width when it should be widening the drop-down list. Is this supported with auto-filter lists loaded by XML??

– I would like the combo box value to be different than what’s presented in the list. I.e., something is selected in the list, but only a subset of what’s in the drop-down is left in the input area. For example, the drop-down might have something like this: Hello (Ellopay) / How Are You (Ohay Areay Ouyay) / Goodbye (Oodbyegay) but all I want to have in the cmbo input area when the user selects an option to be Hello, or How Are You, or Goodbye. Would this be possible using one of the events and then setting the text using setComboText? UPDATE: I tried to handle this using the onChange event, and have met with only modest success. My test code is basically

function onChangeEvent(combo,rownum){ // split off the descriptive info and save it elsewhere document.getElementById('row_'+rowNum).value = combo.getSelectedText().substr(5,999); var mainPart = combo.getSelectedText().substr(0,4); combo.closeAll(); combo.setComboText(mainPart); alert(combo.getComboText()); }
The alert above shows the 4 characters I want, but the setComboText does not replace the visible text of the combobox. The original, selected text remains there. Either I’m missing something fundamental, or the setComboText method is just available to tease us.

– Can you point me to the option/property/method that restricts the value to one of those in the list?

– Is there a way to add some style formatting to the contents of the drop-down? I.e., to use the example above, suppose I wanted the Hello, How Are You, and Goodbye to be in blue.

– I can see from the samples on the website that there’s a way to set up child combos. I understand that this is a very useful and necessary function. I have a different slant on that I’d like to run by you. Suppose I want to have a series of combos that all have the same data source. For example, suppose you have a 2 x 7 array of such combos, where each combo represents a menu selection of Bread, Water, Gruel, and there’s a combo for the AM and another for the PM, which repeats itself over 7 rows, representing 7 days of the week. In each case the xml loading program reading from a database will function the same. As I see it now, there would end up being 14 separate combo objects. Of course I’m concerned about the overhead if, say, instead of 14 there might be 62 (again, using the silly example, instead of 7 days for a week, 31 days for a month). Any thoughts?

  1. There were not any changes in combo functionality in 2.6 version. It’s the same as 2.5.

  2. enableOptionAutoWidth doesn’t work with dynamic loading.

  3. You may try to use the following approach to change the text in combo input after the options is selected:

combo.attachEvent("onSelectionChange",doOnSelect); function doOnSelect(){ var mainPart = this.getComboText().substr(0,4); this.setComboText(mainPart); }

  1. The style of the option can be set by the css attribute:
<option value="1" css="color:blue">option 1</option>

if options are added by the addOption method:

combo.addOption([{value:1,text:"option 1",css:"color:blue"},{value:2,text:"option 2",css:"color:green"}])

  1. here are the details for “groups” extention:

docs.dhtmlx.com/doku.php?id=dhtm … _extension

Also you may find the sample in combo package