How to get the label of a combo (combo_select)


I have a custom field in Lightbox ( route_name ), type : combo. I need to get the label of the combo, but with this code I get only the key. How do i get label of the combo?

	// the code 

	scheduler.attachEvent("onEventChanged", function(event_id,data,event_object){
		var ev = scheduler.getEvent(event_id);	
		var RouteName = data.combo_select;  // this is the combo defined in scheduler.config.lightbox.sections
		ev.text = RouteName; // I get ( 1 or 2 or 3 ) and I ned get ( Berlín, París, Madrid...)
		dp.setUpdated(event_id, true, "updated");  

	// the code in config.lightbox

	{ name: "route_name", map_to: "combo_select", type: "combo", image_path: "../common/dhtmlxCombo/imgs/", filtering: true, script_path: "datapg/combo_select.php", cache: false },


Any idea??


you can get options from the .cached_options property of the combo control, it contains key-label pairs of loaded options.

[code]var config = scheduler.formSection(“route_name”).section;//getting config of the control
var label = getLabel(config, route_id);

function getLabel(config, item_id){
var options = config.cached_options || {};
var label = “”;
for(var i in options){
if(i == item_id){
label = options[i];
return label;


First of all, sorry for my english.

Sorry but i dont understand your explain, it’s my first week with dhtmlx and im following this sample:

This sample insert a combo in the lightbox. This combo gets de names of a mysql table with the name of some countries. I just need to get the name of the country and WRITE it in the ev.text of the ligthbox to save it in the field event_name of my table.

Sorry but im starting with dtmlx



<script src="../../codebase/dhtmlxscheduler.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" href="../../codebase/dhtmlxscheduler.css" type="text/css" media="screen" title="no title"
<link rel="stylesheet" href="../../codebase/ext/dhtmlxscheduler_ext.css" type="text/css" media="screen"
      title="no title" charset="utf-8">

<script src="../../codebase/ext/dhtmlxscheduler_editors.js" type="text/javascript" charset="utf-8"></script>

<link rel="stylesheet" type="text/css" href="../../samples/common/dhtmlxCombo/dhtmlxcombo.css">
<script src="../../samples/common/dhtmlxCombo/dhtmlxcombo.js"></script>

<style type="text/css" media="screen">
	html, body {
		margin: 0px;
		padding: 0px;
		height: 100%;
		overflow: hidden;

<script type="text/javascript" charset="utf-8">
	function init() {

                 scheduler.attachEvent("onEventChanged", function(event_id,data,event_object){
		var ev = scheduler.getEvent(event_id);
		var country_name = data.combo_select; //  ¡¡¡ OBTAINS THE ID COUNTRY, NOT THE NAME. !!"
		ev.text = country_name; // WRITE THE ID COUNTRY, NOT THE NAME.
		dp.setUpdated(event_id, true, "updated"); 
                  // END MY CODE

		scheduler.config.multi_day = true;

		scheduler.config.event_duration = 30;
		scheduler.config.auto_end_date = true;
		scheduler.config.details_on_create = true;
		scheduler.config.details_on_dblclick = true;

		scheduler.locale.labels.section_country = "Select country:";

		var snacks = [
			{ key: 5, label: 'Pineapple' },
			{ key: 6, label: 'Chocolate' },
			{ key: 7, label: 'Chips' },
			{ key: 8, label: 'Apple pie' }

		scheduler.config.lightbox.sections = [
			{ name: "description", height: 50, map_to: "text", type: "textarea", focus: true },
			{ name: "country", options: snacks, map_to: "combo_select", type: "combo", image_path: "../../samples/common/dhtmlxCombo/imgs/", filtering: true, script_path: "data/combo_select.php", cache: false },
			{ name: "time", height: 72, type: "time", map_to: "auto"}

		scheduler.config.xml_date = "%Y-%m-%d %H:%i";
		scheduler.init('scheduler_here', new Date(2012, 3, 3), "timeline");

                   // mycode. Call another table to get an save the events of timeline
		var dp = new dataProcessor("datapg/typespg.php");
                   // end mycode


combo is filled with label-value pairs, where ‘label’ is displayed text(country name in your case) and ‘value’ is an value that must be assigned to the event(in your case it’s country id).
So only the ‘value’ is assigned to the event.
If you open 02_customization/data/combo_select.php you can find connector initialization code

[/code]parameters are
- table name
- column that goes for combo 'value'
- column for combo 'label'

since you don't use country id, you can use country name as a value and a label:[code]

After that event will get country name, instead of country id.

If you need it to be saved in ev.text, you should change ‘map_to’ property of the combo configuration in scheduler.config.lightbox.sections:
from: { name: "country", options: snacks, map_to: "combo_select", ...}, to: { name: "country", options: snacks, map_to: "text", ...},


Thank you very much. Now I understand it and my sample work’s fine.

Thank you for your patience.