Display Labels from Options Connector in Event Text

I’m using the Options Connector to retrieve data and it’s populating the form well. What I want to do is to add the Label of the selected option (and the saved event data joined from the options table) to the event display, but I’m afraid my javascript skills are still a work in progress…

Can you provide me the correct syntax to achieve this, please? I’m attempting this (pseudocode in asterisks), but can’t get the right handle on the label value:

...
scheduler.templates.event_text=function(start,end,event){
  			 return event.text+"<br>"+scheduler.serverList("task")*label where key=event.task*;
...

Here’s my connector code, which seems to be working fine:

... $list = new OptionsConnector($res); $list->render_sql("select id as value, title as label from tasks order by title asc","id","id(value),title(label)"); $scheduler->set_options("task", $list); $scheduler->render_table("jobtime","id","start_date,end_date,event_name,details,activity_id (category),resource_id(resource),task_id(task)");

This connector is a great feature addition - Thanks!

Unfortunately there is no easy way to convert id to the label as for now ( you can iterate from collections and find necessary one - but it is a lot of code )

In next 10 days, we are releasing version 2.3 which will provide getLabel method for such kind of conversion.

Hi,
Can you point me to the documentation on this now, or indicate how to make use of the method you reference?
thanks

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

I am unable to get this method to work:

scheduler.templates.event_text=function(start,end,event){
 	return event.text+"<br>"+scheduler.getLabel("section_id", event.resource);

The DOM indicates a valid value for event.resource. When I substitute a valid numeral, still doesn’t return anything:

return event.text+"<br>"+scheduler.getLabel("section_id", 4);

Am I missing something?
Thanks for your reply.

Do you have this field as part of lightbox form?

Yes, js below:

[code]
var fc=0;
var post_category = 9;
function init() {

	var saveTitle = "";
	var saveDetails = "";
	var saveCategory = 0;
	
	scheduler.filter_day = filterEvents;
	scheduler.filter_week = filterEvents;
	scheduler.filter_month = filterEvents;

	scheduler.config.details_on_dblclick=true;
	scheduler.config.details_on_create=true;
	scheduler.config.hour_date="%h:%i%a";
	scheduler.config.xml_date="%Y-%m-%d %H:%i";
	scheduler.config.multi_day = true;
	scheduler.config.start_on_monday = 0
	scheduler.config.first_hour = 8;
	scheduler.config.last_hour = 23;
	scheduler.config.time_step = 30;
	scheduler.config.show_loading=true;	
     	
	scheduler.createTimelineView({
     name:		"timeline",
     x_unit:	"day",
     x_date:	"%D-%d",
     x_step:	1,
     x_size:		1,
     x_start:	0,
     x_length: 1,
     y_unit:
     	[	{key:1, label:"Adam"},
        	{key:2, label:"Benjamin"},
        	{key:3, label:"Charles"},
        	{key:4, label:"David"},
        	{key:5, label:"Gregory"},
        	{key:6, label:"Jason"},
        	{key:7, label:"Jen"},
        	{key:8, label:"Jerry"},
        	{key:9, label:"Joe"},
        	{key:10, label:"Joel"},
        	{key:11, label:"Lisa"},
        	{key:12, label:"Nicole"},
        	{key:13, label:"Other"}	],
     y_property:"resource",
     render:	"bar"
  });

    scheduler.templates.event_text=function(start,end,event){

// return event.text+"
"+scheduler.getLabel(“section_id”, event.resource);
return event.text+"
"+scheduler.getLabel(“section_id”, “3”);
// return event.text+"
"+“test-text”;
}

	scheduler.templates.month_date_class=function(date,today){
		if (date.getDay()==0 || date.getDay()==6)
			return "weekend";	
		return "";
		}
scheduler.templates.event_bar_text=function(start,end,event){
		var details = "";
			if (typeof event.details != "undefined")
			  var details = event.details.substr(0,100)||"";
			return event.text+"  "+details;
			}		

	scheduler.templates.event_bar_date=function(start,end,event){
		return "";
		}
	scheduler.templates.calendar_scale_date =  scheduler.date.date_to_str("%D");
	
	var formatDayPicker = scheduler.date.date_to_str("%M-%j-%Y");
	scheduler.templates.calendar_time=function(date){
		return formatDayPicker(date);
		}
	scheduler.init('scheduler_here',null,"timeline");
	scheduler.load("_pcal/time-connector.php?uid="+scheduler.uid());
	scheduler.locale.labels.timeline_tab = "Timeline";
	scheduler.locale.labels.section_title ="Title";
	scheduler.locale.labels.section_resource ="Resource";
	scheduler.locale.labels.section_task ="Project/Task";
	scheduler.locale.labels.section_master ="Activity";
			
	scheduler.form_blocks.master_select={
  		render:function(sns){
     		var height=(sns.height||"20")+"px";
     		var html="<div class='dhx_cal_ltext' style='height:"+height+";'><select style='width:302px;'>";				
			html+="<option value='0'>Unassigned</option>";
			html+="<option value='1'>Editing</option>";
			html+="<option value='2'>Color Correction</option>";
			html+="<option value='3'>Sound Recording</option>";
			html+="<option value='4'>Graphics</option>";
			html+="<option value='5'>Meetings</option>";				
			html+="<option value='6'>Production</option>";				
			html+="<option value='7'>Scouting</option>";				
			html+="<option value='8'>Other</option>";
			html+="</select></div>";
     		return html;
     	},
     	set_value:function(node,value,ev){
			node.childNodes[0].value=ev.category;
     	},
     	get_value:function(node,ev){
			ev.category = node.childNodes[0].value;
			return node.childNodes[0].value;
		}
	}  		

	scheduler.config.lightbox.sections=[	
		{ name:"title", height:30, map_to:"text", type:"textarea" , focus:true},
		{ name:"resource", height:30, map_to:"resource", type:"select", options:[
			{key:"1", label:"Adam"},
			{key:"2", label:"Benjamin"},
			{key:"3", label:"Charles"},
			{key:"4", label:"David"},
			{key:"5", label:"Gregory"},
			{key:"6", label:"Jason"},
			{key:"7", label:"Jen"},
			{key:"8", label:"Jerry"},
			{key:"9", label:"Joe"},
			{key:"10", label:"Joel"},
			{key:"11", label:"Lisa"},
			{key:"12", label:"Nicole"},
			{key:"13", label:"Other"}
	]},
			{name:"task", height:21, map_to:"task", type:"select", 
			options:scheduler.serverList("task")},
		{ name:"master", height:30, map_to:"category", type:"master_select", options:[
			{key:"0", label:"Unassigned"},
			{key:"1", label:"Editing"},
			{key:"2", label:"Color Correction"},
			{key:"3", label:"Sound Recording"},
			{key:"4", label:"Graphics"},
			{key:"5", label:"Meetings"},
			{key:"6", label:"Production"},
			{key:"7", label:"Scouting"},
			{key:"8", label:"Other"}
	]},				
		{ name:"description", height:40, map_to:"details", type:"textarea"},
		{ name:"time", height:72, type:"calendar_time", map_to:"auto" }

	];		
scheduler.templates.event_class=function(start,end,event){
		switch ( event.category ) {
  	    case "1" : return "ep";
        case "2" : return "w";
        case "3" : return "h";
        case "4" : return "c";
        case "5" : return "o";
        case "6" : return "d";
        case "7" : return "e";
        case "8" : return "w";
        case "0" : return "u";
		}
}
scheduler.attachEvent("onEventSave",function(id,data){
	saveTitle = data.text;
	saveDetails = data.details;
	saveCategory = data.category;
	return true;
	});
scheduler.attachEvent("onEventCreated",function(id){
	var event = scheduler.getEvent(id);
	event.text = saveTitle;
	event.details = saveDetails;
	event.category = saveCategory;
	});

var dp = new dataProcessor("_pcal/time-connector.php");
dp.init(scheduler);

} // end init

function show_minical(){
if (scheduler.isCalendarVisible())
scheduler.destroyCalendar();
else
scheduler.renderCalendar({
position:“dhx_minical_icon”,
date:scheduler._date,
navigation:true,
handler:function(date,calendar){
scheduler.setCurrentView(date);
scheduler.destroyCalendar()
}
});
}

function filterCategory(category) {
fc=category;
scheduler.setCurrentView(scheduler._date);
}

function filterEvents(id,event){
if(!fc || event.category == fc || fc==0) return true;
return false;
}[/code]

I can point you to a live link if it helps.
thanks!

Change your template code as

scheduler.getLabel(“resource”, event.resource);