Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Marja on Nov 26, 2007 03:01
open dhtmlx forum
dhtmlCombo: set combo value/text from other control

On a screen in my webapplication I would like to offer 2 interactive ways to select an existing member from the database:

1) Using the dhtmlCombo with oCombo.enableFilteringMode(true,'myscript.asp',true,true), where the option value is the member's database ID and the option text is the member's full name.
In this case the member is selected by typing in (part of) his/her name.

2) Using a button that launches a popup screen where the member can be selected on more criteria than only his/her name.

Currently I have both options working correctly separately, but now I would like to be able to also set the combo value/text with the selected member's ID and name when the popup screen is used instead of the combo box.

I've tried oCombo.setComboValue(myMemberID) and oCombo.setComboText(myMemberName), but then the combobox displays the member ID instead of the member name.

I hope you understand what I'm trying to do here and that you can offer any directions to achieve my goal.

Thanks in advance.

Regards, Marja
Answer posted by Stanislav on Nov 26, 2007 03:45
You can set value|text by API command, it a bit more tricky in filtering mode, because in such case necessary option may be not loaded from server yet
The next must work

    combo.setComboValue(value_part);
    combo.setComboText(text_part);

where text_part - option text
           value_part - database ID
Answer posted on Nov 26, 2007 04:14

I've got it to work, and noticed that I need to use oCombo.getActualValue() instead of oCombo.getSelectedValue() lateron in succeeding scripts to work around the fact that the member data may indeed not be loaded into the combobox (yet).
The "getActualValue()" method correctly returns the option value of the combobox when it is set by the popup screen.

Thank you for your quick reply.

Best regards, Marja