Combo field with SQL Sentence

Hi everyone! Can you help me with this??

I’ve search the entire forum and tried every sample on the documentation, but cannot find a way to create a select box with a SQL sequence like “Select Field_1, Field_2 from Table Where field_3 = 1”

Here is the Client Side Code:

... {name:"contact", height:21, map_to:"type", type:"select", options:scheduler.serverList("type") }, ...
And the Server Side Code:

$scheduler = new schedulerConnector($res);
	$list = new OptionsConnector($res);
	$list->render_sql("Select contact_id, contact_name from sd_Contacts Where user_id=7","contact_id ","contact_id (value),contact_name(label)");	
	$scheduler->set_options("type", $list);

If I put the basic code:

[code]$scheduler = new schedulerConnector($res);

$list = new OptionsConnector($res);
$list->render_table("sd_Contacts","contact_id ","contact_id (value),contact_name(label)");	
$scheduler->set_options("type", $list);[/code] 

works fine.

Am I done something wrong or it´s not possible to do this?

Thank´s in advance.
Marcos Satorres

Change your code as

 $list->render_sql("Select contact_id as value, contact_name as label from sd_Contacts Where user_id=7","contact_id ","contact_id (value),contact_name(label)");   

We will add this info in documentation, because it really not clear how to load options by sql

Thank You!!!
It works fine!!
A little detail and it´s done!!

Hi, Stanislav.

Can you help me, again, in this subject??

Is everything ok with the system, however, is returning error when the SQL sentence does not bring any result. How to make the combo not appear, or showing it empty, when there are no results?


Local test works correctly when empty set of data is returned from server side.

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


With the new scheduler release (2.3) this problem was solved, but now there is another thing that I was unable to figure how to do it.

My schedule is mounted with one or two php files, as below:

scheduler.clearAll(); // clear cached events switch (sPar) { // load activities events case 'ACT': scheduler.load("codebase/php/events.php?user_id_view="+user); break; // load tasks events case 'TSK': scheduler.load("codebase/php/tasks.php?user_id_view="+user); break; // load ALL events case 'ALL': scheduler.load(["codebase/php/events.php?user_id_view="+user,"codebase/php/tasks.php?user_id_view="+user]); break; }

In the php files is returned a list to mount the select combo ‘contact_id’

{name:"contact_id", height:21, map_to:"contact_id", type:"select", options:scheduler.serverList("contact_id") }


$list = new OptionsConnector($res); $list->render_sql("SELECT contact_id as value, contact_name as label FROM sd_Contacts","contact_id ","contact_id (value),contact_name(label)"); $scheduler->set_options("contact_id", $list);

And the events(tasks for example):

$scheduler->render_sql("select task_id, contact_id,active_id,user_id_from,user_id_to,task_date_from,task_date_to,task_desc,task_priority,task_repeat,task_type, 'T' AS event_type from sd_Tasks where user_id_from=".$user_id,"task_id","task_date_from,task_date_to,task_desc,contact_id,active_id,user_id_from,user_id_to,task_priority,task_repeat,task_type,event_type");

Now the question:

Every time that I open the lightbox, the select combo is loaded with all names, correctly, but none was selected, this is suppose to happen for new events, but when i am editing old events, the select combo should come with the name that saved in data base before.

How can I set the right contact, that came from event query, in the select combo list when I open the ligthbox for editing?

Did you understand the issue?

Try to change

,"contact_id ",“contact_id (value),contact_name(label)”);


,“contact_id”,“contact_id(value),contact_name(label)”); //whitespaces removed

I think it must work with whitespaces as well, but this is the only strage point in your code , all other are definitely correct.