Get lightbox combo text... Urgent

get combo value…

Section:
scheduler.config.lightbox.sections = [
{name:“staff”, height:21, map_to:“staff”, type:“select”,
options:scheduler.serverList(“staff”)},
{name:“time”, height:72, type:“time”, map_to:“auto”}
];

Staff
Manager Ass.Manager Mod.Leader Leader Trainee

Im using the above combo. i want to get combo text like Manager, Leader in the scheduler.templates.event_text.

scheduler.templates.event_text=function(start,end,event){		
	return "Staff:"+event.staff;
}

    the above code displayed option values like 400, 310..

    But i need Text values. Help me.

      Thanks in advance......

Hi Vijai,
You could always make your own select form_block, and generate an ID for the select list, then retrieve the element in JavaScript by using document.getElementById(‘theIdOfYourElement’);

Too generate my own form_block for a select list, I looked through the dhtmlxScheduler’s code and found where they defined their select by searching for form_blocks.scheduler in their JavaScript files, and re-used most of the code, and modified what I needed too.

        scheduler.form_blocks["mySelect"] = {
            render:function(sns){
			    var height=(sns.height||"23")+"px";
			    var html= "<div class='dhx_cal_ltext' style='height:"+height+";'><label>" + sns.LabelText + "</label><select id='" + sns.ctrlId + "' style='width:352px;'>";
			    for (var i=0; i < sns.options.length; i++)
				    html+="<option value='"+sns.options[i].key+"'>"+sns.options[i].label+"</option>";
			    html+="</select></div>";
			    return html;
		    },
		    set_value:function(node,value,ev){

			    if (typeof value == "undefined")
				    value = (node.childNodes[1].options[0]||{}).value;

			    node.childNodes[1].value= value || "";
		    },
		    get_value:function(node,ev){
			    return node.childNodes[1].value;
		    },
		    focus:function(node){
			    var a=node.firstChild; if (a.select) a.select(); a.focus(); 
		    }
        }

and I used the following lightbox sections code to declare my select list:

{ name: "UserId", height: 20, type:"mySelect", options:sections, map_to:"UserId", LabelText: "Scheduled User:", ctrlId:"TheHTMLIdYouWantTooUse" }

Hope that helps.
Kind regards
Greg

I forgot to mention, you must make another form block to return the text value of the select list, so that you can retrieve it directly from the event for the event_text (It can be a hidden input for example?)
Greg

I'm using the above combo. i want to get combo text like Manager, Leader in the scheduler.templates.event_text.

Try to use

scheduler.templates.event_text=function(start,end,event){ return "Staff:"+scheduler.getLabel("staff",event.staff); }

It requires Scheduler 2.3+

Thank you so much Stanislav . Its working perfectly…

Hello,

I want to do the same thing but i have some issues.
It doesn’t work, my event text stay at “new event”…

function init() {
		
		scheduler.config.multi_day = true;
		scheduler.config.details_on_create=true;
		scheduler.config.details_on_dblclick=true;
		scheduler.config.xml_date="%Y-%m-%d %H:%i";
		scheduler.config.first_hour=4;
		scheduler.config.prevent_cache = true;

		
		/***********************************************/
	scheduler.templates.event_text=function(start,end,event)
	{ 
		return "Chauffeur: "+scheduler.getLabel("idchauffeur",event.idchauffeur);
	}
	
		/******* MATRIX CONFIG ******************/
	scheduler.locale.labels.matrix_tab = "Chauffeur";
	scheduler.templates.matrix_scale_date = function(date)
	{
		var format = scheduler.date.date_to_str("%D, %d.%m.%Y");
		return format(date);
	}
	scheduler.templates.matrix_scale_label = function(section_id, section_label, section_options)
	{
		return section_label; 
	};
	
	scheduler.date.matrix_start = scheduler.date.week_start;
		/***********************************************/

		/************ INITIALISATION *******************/
	scheduler.init('scheduler_here',new Date(2011,1,1),"week");
	scheduler.load("events_multiselect_static.php");
	
	var dp = new dataProcessor("events_multiselect_static.php");
	dp.init(scheduler);
	
		/***********************************************/
	
		/********* LIGHTBOX CONFIG *******************/
	scheduler.locale.labels.section_chauffeur="Chauffeur";
	scheduler.locale.labels.section_ligne="Ligne";
	scheduler.locale.labels.section_description = "Nom";

	scheduler.config.lightbox.sections=
	[	
		//{ name:"description", height:50, map_to:"text", type:"textarea", focus:true },
		{ name:"chauffeur", height:22, map_to:"idchauffeur", type:"select", options: scheduler.serverList("idchauffeur"), script_url: 'events_multiselect_options.php', vertical:"false"  },
		{ name:"ligne", height:23, type:"select", options:scheduler.serverList("idLigne"),script_url: 'events_multiselect_options.php', map_to:"idLigne" },
		{ name:"time", height:72, type:"time", map_to:"auto"}
	]
	//scheduler.config.xml_date="%Y-%m-%d %H:%i";
	
	scheduler.createTimelineView
	(
		{
		 name:	"matrix",
		 x_unit:	"day",
		 x_date:	"%d %M",		 
		 x_step:	1,
		 x_size:	7,
		 y_unit: scheduler.serverList("idLigne"),
		 y_property:"idLigne",
		 render:"bar"
		}
	);
		/***********************************************/
	
	}

In the same time, if i put “matrix” in scheduler.init(), the scheduler doesn’t load :frowning:

In case of timeline view, you need to use
scheduler.templates.event_bar_text
instead of
scheduler.templates.event_text

Thanks, it’s working !
Now i have an other issue…
If i load on my timeline view i have this error(javascript)

Uncaught TypeError: Cannot read property ‘heights’ of undefined

Do you know why ? :frowning:

Not sure, but seem related to the moment of scheduler’s initialization.
Maybe you are calling init, while timeline mode is not fully configured yet.

If issue still occurs for you - please provide any kind of sample or demo link where it can be reconstructed.

Also you can try to update timeline extension from here
docs.dhtmlx.com/doku.php?id=dhtm … own_issues

Ok i move scheduler’s initialization to the bottom of the init() function and it’s working :slight_smile:.

Now i have an other problem.
When data are stored in the database,
"event_name"col of “event_ms” table stay at “New event”.

I want the name of the “chauffeur” section(lightbox) in this col.
I don’t see where and how the “event_name” col is filled.

By the way thanks to your help !

Hello,

In you php file you have something similar:

$scheduler->render_table("events","event_id","start_date,end_date,event_name,details");

First three columns have predefined names in the scheduler, they are: start_date, end_date, text.

That’s why you need section in lightbox to handle that field. Right now you have:

scheduler.config.lightbox.sections= [ //{ name:"description", height:50, map_to:"text", type:"textarea", focus:true }, { name:"chauffeur", height:22, map_to:"idchauffeur", type:"select", options: scheduler.serverList("idchauffeur"), script_url: 'events_multiselect_options.php', vertical:"false" }, ... ]
text field is not used but new events are assigned with the ‘New event’ text anyway which in turn is saved in the database.
To display chauffeur in the column change configuration following way:

scheduler.config.lightbox.sections= [ { name:"chauffeur", height:22, map_to:"text", type:"select", options: scheduler.serverList("idchauffeur"), script_url: 'events_multiselect_options.php', vertical:"false" }, ... ]
Now chauffeur is linked to the text property which in turn is linked to the event_name field in the database.

Hope this helps.

Best regards,
Ilya

Also, you can use something like next to modify default values of event during new event creation

scheduler.attachEvent("onEventCreated", function(id){ scheduler.getEvent(id).text = "any value here"; return true; })

Ilya : if i try your way, it’s working, in my database i see now the id of the “chauffeur”.
But a problem appears. I don’t see anymore the label in the scheduler.

So i tried the stanislav’s way and it’s working. I see now “any value here” in my database.
I tried this code :

scheduler.attachEvent("onEventCreated", function(id){
    scheduler.getEvent(id).text = scheduler.getLabel("idEmp",event.idEmp);
    return true;
})

Without succes :frowning:.
Show me the way pls :slight_smile:.

Hum, i use scheduler on Chrome. (working)

If i try on IE8 i have a problem on the scheduler’s initialization.
In an javascript box, i see data :

<?xml version='1.0' encoding............................... but my scheduler isn't loaded. :frowning: I don't understand why...

Your code must look as

scheduler.getEvent(id).text = scheduler.getLabel("idEmp",scheduler.getEvent(id).idEmp);

In an javascript box, i see data :
Incorrect xml generation. Most probably invalid content-type or non utf data.

it’s not working with your code, i have an empty result… :frowning:

Incorrect xml generation. Most probably invalid content-type or non utf data.

How is it possible to have an incorrect xml generation on IE and everything run weel on Chrome ?
This is a screenshot of the error.
marc.milard.free.fr/images/erreur.jpg

How is it possible to have an incorrect xml generation on IE and everything run weel on Chrome ?
They are using different xml parsers. While chrome doesn’t care about content type of data stream, IE requires that it must be text/xml.

IE requires that it must be text/xml.

Where can i do it ?

For data loading you are using something like

scheduler.load(“data.php”)

so, the first line of data.php must be

<?php header("Content-type:text/xml");

This code doesn’t work.

If you want in local, with IE it’s working but on the web, it doesn’t work with IE.
Something to do with a HTACCESS maybe ?

Try to load the xml feed in separate window of browser - if it have any parsing error - detailed error info will be shown.