Autocomplete Combo inside form and first load of form info

Hi,
i have some autocomplete combos inside my form and my question is: how i can pass value and description to my combo inside form xml data?
I try with <id_combo_inside_form>value^description</id_combo_inside_form> but it doesn’t work and my combo show value^description.

This is my form structure:

<?xml version="1.0" encoding="UTF-8"?> <items> <item type="settings" labelWidth="100" inputWidth="160" position="label-top" /> <item type="block" width="630"> <item type="input" name="ext_cod" label="Codice" /> <item type="combo" name="codice_vettore" label="Area" required="true"/> <item type="combo" name="id_destinatario" label="Destinatario" required="true"/> <item type="input" name="provincia" label="provincia" /> <item type="input" name="email" label="email" /> <item type="calendar" name="data_fine" dateFormat="%d-%m-%Y %H:%i" enableTime="false" label="Data Fine" /> <item type="newcolumn" offset="5" /> <item type="input" name="data_eva" label="Data Evasione" disabled="disabled" /> <item type="combo" name="id_tipo_intervento" label="Tipo intervento" required="true" /> <item type="input" name="indirizzo" label="Indirizzo" /> <item type="input" name="tel" label="tel" /> <item type="combo" name="id_committente" label="Committente" /> <item type="newcolumn" offset="5" /> <item type="input" name="stato_descr" label="Stato Intervento" disabled="disabled" /> <item type="combo" name="codice_operatore" label="Operatore" /> <item type="input" name="localita" label="località" /> <item type="input" name="fax" label="fax" /> <item type="calendar" name="data_ini" dateFormat="%d-%m-%Y %H:%i" enableTime="false" label="Data Inizio" /> <item type="hidden" name="id_intervento"/> <item type="hidden" name="viag_cod"/> <item type="hidden" name="postBack"/> <item type="hidden" name="action"/> <item type="hidden" name="channel_id"/> <item type="hidden" name="stato"/> </item> <item type="block" width="630"> <item type="button" name="edit_dhtmlx" value="salva"/> </item> </items>

and this is xml data for the form:

<data><ext_cod>514955</ext_cod><codice_vettore>18</codice_vettore><codice_operatore><![CDATA[ROBUSTELLI GIUSEPPE]]></codice_operatore><id_committente>GEOX SPA</id_committente><id_tipo_intervento>379</id_tipo_intervento><id_destinatario>30985^'.GEOX GEOX SPA'</id_destinatario><indirizzo>'C/O C.C. I MORI DI LICATA'</indirizzo><localita>'92027 LICATA'</localita><provincia>AG</provincia><tel></tel><fax></fax><email></email><data_ini></data_ini><data_fine></data_fine><data_eva></data_eva><stato_descr>Programmato</stato_descr><id_intervento>1425</id_intervento><viag_cod>2038</viag_cod><stato>P</stato><postBack>false</postBack><action>getInterventTestata</action></data>

as you can see i have try only with id_destinatario combo.

Any help?

Thank you.

Jacopo

Hi Jacopo,

If option key and label are the same, the you just need to load the label as the value for combo item. However, if they are different, the approach will be a little more complicated:

// combo config var combo = yourForm.getCombo("codice_vettore"); combo.enableFilteringMode(true,url,true); /* load form data for combo value will be in format key^label (as you mentioned in your question) */ yourForm.load(formDataUrl, function(){ //get loaded value var value = yourForm.getItemValue("codice_vettore"); var arr = value.split("^"); //set option key as a value yourForm.setItemValue("codice_vettore",arr[0]); // set option label as combo text combo.setComboText(arr[1]); })

Thank you :slight_smile:
It works :slight_smile:

so using DHTMLXForm i have to do it manually, but with dhmlxGrid it’s a build-in feature right?

Yes, “combo” excell automatically sets these values. And Form doesn’t provide this feature.

Hi, i have antother question :slight_smile:

Now i have this function to insert value and text in my combos after first load of my form

[code]function selectComboAutocompleteValue (yourForm,codice_campo,callback)
{
var value = yourForm.getItemValue(codice_campo);
if(!isEmpyNullString(value))
{
var combo = yourForm.getCombo(codice_campo);
var arr = value.split("^");
yourForm.setItemValue(codice_campo,arr[0]);

	combo.setComboText(arr[1]);
}
if(callback != null)
	callback();

}[/code]

it seems work (in my combo i see option description and not option value) but when i call combo_lista_dipendente.getActualValue(); i get null or “”.

so i change a little bit this function:

[code]function selectComboAutocompleteValue (yourForm,codice_campo,callback)
{
var value = yourForm.getItemValue(codice_campo);
if(!isEmpyNullString(value))
{
var combo = yourForm.getCombo(codice_campo);
var arr = value.split("^");
yourForm.setItemValue(codice_campo,arr[0]);

	combo.setComboText(arr[1]);
	combo.openSelect();
	combo.selectOption(0,true,true);
	combo.closeAll();
	
}
if(callback != null)
	callback();

}[/code]

Now calling combo_lista_dipendente.getActualValue(); i get the right value.
My problem is that i want to show “progressOn” in my layout cell (that contain my form with this combo) until my combo has loaded the option. Infact with my code,this autocomplete combo, simulate a real selection and so it call my server loading response xml.
I have searched inside combo event but i cant find an event like “OnXLS” “onXLE”.

any help?

thank you :slight_smile:

Hi,

Both onXLS and onXLE events fire for Combo. Try something like so:

combo_lista_dipendente.attachEvent("onXLS",function(){ //loading start }); combo_lista_dipendente.attachEvent("onXLE",function(){ //loading end });

thank you :slight_smile: