Get section label onBeforeLightbox

Hi,

I try to get the section label in timeline view (treemode) with onBeforeLightbox, but I have only managed to have the section_id.
Also I have to get the section label by levels (the two parent sections)… How can I do that please?
I Tried with :

scheduler.attachEvent("onBeforeLightbox", function (event_id){
   		alert(scheduler.getEvent(event_id).section_label);
};

And the result is “undefined”.

Thank you for your help.
Loïc

Hi,
if you have lightbox control for section, you can use scheduler.getLabel
docs.dhtmlx.com/doku.php?id=dhtm … r_getlabel

var sections=[ {key:1, label:"James Smith"}, ... ]; scheduler.createTimelineView({ name: "timeline", ... y_unit: sections }); scheduler.config.lightbox.sections=[ {name:"custom", height:23, type:"select", options:sections, map_to:"section_id" }, ... ]; scheduler.attachEvent("onBeforeLightbox", function (event_id){ alert(scheduler.getLabel("section_id", scheduler.getEvent(event_id).section_id)); });
Othervise you may just iterate sections array. Timeline sections can be accessed following way

var sections = scheduler.matrix[timelineViewName].sections;

Thank you for your answer but the alert returns null/empty. :frowning:
I forgot to tell you that I have my problem when I want to create/draw an event (I don’t know if it is important).

I don’t use the lightbox but a dhtmlx window to show event details, this is why I don’t use : scheduler.config.lightbox.sections=[

I give you my scheduler config if it can help :

[code]
scheduler.createTimelineView({
section_autoheight: false,
name: “timeline”,
x_unit: “day”,
x_date: “%d”,
x_step: 1,
x_size: 7,
x_start: 0,
//x_length: 48,
//y_unit: elements,
second_scale: {
x_unit: “month”,
x_date: “%F”
},
y_unit: scheduler.serverList(“timeline_sections”, parent.sections),
y_property: “section_id”,
render: “tree”,
folder_dy: 20,
dy: 40
});

scheduler.date.timeline_start = scheduler.date.week_start;
		
scheduler.createUnitsView({
	name:"unit",
	property:"section_id",
	list:scheduler.serverList("units", parent.sections),
	//size:20,
	//step:1
});	

scheduler.init('scheduler_here',new Date(),"timeline");
		
scheduler.parse([{ start_date: "", end_date: "", text:"", section_id:"" , sid:"", section:"", label:""}],"json");

parent.wslay2.cells("a").progressOff();

};

function UnitView(units){
if (units==‘myyear’){
scheduler.matrix[“timeline”].x_unit = “month”;
scheduler.matrix[“timeline”].x_size = 12;
scheduler.date.timeline_start = scheduler.date.year_start;
} else if (units==‘mymonth’){
scheduler.matrix[“timeline”].x_unit = “day”;
scheduler.matrix[“timeline”].x_size = 31;
scheduler.date.timeline_start = scheduler.date.month_start;
} else if (units==‘myweek’){
scheduler.matrix[“timeline”].x_unit = “hour”;
scheduler.matrix[“timeline”].x_date = “%H:%i”;
scheduler.matrix[“timeline”].x_step = 30;
scheduler.matrix[“timeline”].x_size = 7;
scheduler.matrix[“timeline”].x_start = 14;
scheduler.matrix[“timeline”].x_length = 48;
scheduler.date.timeline_start = scheduler.date.day_start;
}
scheduler.updateView();
document.getElementById(‘todaybtn’).onclick();
};[/code]

Thank you again,
Loïc

Hello,

I’m still trying to get the label for each level of my tree timeline but I still have an issue to get it. :frowning:

Please, have you got any idea?

thank you,
loïc

Hello,
you could use recursive function like following to bypass sections tree and find needed section[code] function findSection(root, id){
if(!root)
return;
var result;

	for(var i=0; i < root.length; i++){
		if(id == root[i].key){
			result = root[i];
			break;
		}else{
			var foundChild = findSection(root[i].children, id);
			if(foundChild){
				result = foundChild;
				break;
			}
		}
	}

	return result;
}[/code]and usage:[code]var sections = scheduler.serverList("timeline_sections");

var id = event.section_id;
var section = findSection(sections, id);
alert(section.label);[/code]

hi,

Thank you very much, it work’s fine. I couldn’t find it by my own.

Thanks again,
loïc