Lightbox Load combo option onBeforeLightbox

Hi :slight_smile:
I have a problem, i am trying to load options of my combo in lightbox depending on selected event.
My code is

[code]var lista_utenti=“”;
/**
*
*/

function caricaUtenti (event_id)
{
var ev = scheduler.getEvent(event_id);
var url = “PresenzeTurniSave?action=getSecondoOperatoreJson”;
url += “&id_vettore=”+ev.idArea;
url += “&tipo_int=”+ev.idTipoInt;
var loader = dhtmlxAjax.getSync(url);
lista_utenti = loader.xmlDoc.responseText;
}[/code]

This method set in lista_utenti corect json

[{ key: 0, label: "nessuno" },{ key: 607, label: "Pippo" },{ key: 612, label: "Operatore Android Tablet" },{ key: 613, label: "Pianificatore Email test Pianificatore Email test" }]

i call caricaUtenti inside the onBeforeLightbox code:

 scheduler.attachEvent("onBeforeLightbox", function (event_id){
	    	var ev = scheduler.getEvent(event_id);
			 if(ev != null && typeof ev != 'undefined' && ev.isIntervento =="true")
			{
				 // carico i secondi operatori
				 caricaUtenti(event_id);
				
					 scheduler.resetLightbox();
					 if((!is_congelatoProgrammato(ev.StatoIntervento) || ev.StatoIntervento== 'P'))
					 	scheduler.config.lightbox.sections=<%=param.get("LIGHTBOX_INTERVENTO")%>;
					 else
						 scheduler.config.lightbox.sections=<%=param.get("LIGHTBOX_INTERVENTO_CONG")%>;
					 scheduler.config.buttons_right = [];
					 if(ev.readonly == true || ev.readonly == "true")
					 {
						scheduler.config.buttons_left=["dhx_cancel_btn"];
					 }
					 else
					{
						 scheduler.config.buttons_left=["dhx_save_btn","dhx_cancel_btn"];
					}
			}
			 else
				 {
				 scheduler.resetLightbox();
				 scheduler.config.lightbox.sections=<%=param.get("LIGHTBOX_PRESENZA")%>;
				 if(ev.readonly == true || ev.readonly == "true")
				 {
					scheduler.config.buttons_left=["dhx_cancel_btn"];
					scheduler.config.buttons_right=[];
				 }
				 else
				{
					 scheduler.config.buttons_left=["dhx_save_btn","dhx_cancel_btn"];
					 if(ev.isAssenza == "true")
					 	scheduler.config.buttons_right=["dhx_delete_btn"];
				}
				 }
			 return true;
	    	
	   });

where param.get(“LIGHTBOX_INTERVENTO”) is

<![CDATA[[ {name:"Assegnazione", height:38, map_to:"isAssIntConfermata", type:"checkbox" ,checked_value: "true",unchecked_value: "false"} ,{name:"description", height:200, map_to:"text", type:"textarea"} ,{name:"custom", height:23, type:"select", options:sections, map_to:"section_id"} ,{name:"secop", map_to:"n41_auti_cod_sec_op", type:"combo", image_path: "./js/dhtmlx/combo/imgs/", filtering: true, options: lista_utenti} ,{name:"time", height:72, type:"time", map_to:"auto"}]]]>

When i open lightbox i can see that my servlet is called and it response correctly with a correct json but in secop combo in lightbox i see a lot of empty option.

thank you.

P.s. Why my label shows undefined?


in your code it still not clear how the options is assigned to the select. You have statis configuration, where “options:sections”, and in your code there is no line which sets the section array at all.

I think you need to eval lista_utenti at end of caricaUtenti method, to return json object ( not a string ), and later use something like to define new set of options.

var sections =  caricaUtenti(event_id); 

You are right i have to “eval” the response text :slight_smile:

thank you.