iterating through serverlist

Hi -
I’m using addMarkedTimespan to highlight the different sections of a unit view to indicate availablity in the background. The input to the addMarkedTimespan is from a separate database table that includes start and end values, and I set that up through the connector.php file in the following manner -

$scheduler->set_options(“personavail”, $list_personavail);

where personavail_id is also the column/section name in the database used for the unit view.

In the scheduler.load callback function, I have the following -
scheduler.load("./data/connector.php", function (){
var time_spans = scheduler.serverList(“personavail”);
for(i in time_spans) {
var d1 = new Date(time_spans[i].start_date); … etc.
I use the time_span[i].whatever assignments in scheduler.addMarkedTimespan (whatever being either start_date,end_date, personaval_id) and I try and iterate through i but it doesn’t work. I believe that I’m not accessing the time_spans object properly.


Try moving
var timespans = scheduler.serverList(“personavail”);
before scheduler init. And then in callback function use it.

Kind regards,

Hi Ilya -
Thanks for getting back to me on this one.
I tried moving it before scheduler.init and that doesn’t work. The i in the for(i in seems to be null so it never enters the loop. If I do a time_spans.size, the result is undefined.
Is it something specific to how scheduler.serverList creates the object that is not compatible with the way I’m trying to iterate with a for in loop? If I do a time_spans.size the result is undefined.

Any other ideas?

Move only that single line before scheduler.init

and then in load callback simply use “timespans” variable. Server lists should be defined before loading but can be used after.

Kind regards,

Hi Ilya -
That’s what I’m doing now and it doesn’t work. Here’s a snippet of the code, followed by the connector.php code -

	var time_spans = scheduler.serverList("personavail");

	scheduler.init('scheduler_here',new Date(),"month");

	scheduler.load("./data/connector.php", function (){

		for(i in time_spans) {
			var d1 = new Date(time_spans[i].start_date);
			var d2 = new Date(time_spans[i].end_date);

				start_date: d1,
				end_date: d2,
				css: "green_section",
				sections: {
					junk: time_spans[i].personavail_id

		}; // end of for loop
	}); // end of sheduler.load
   var dp = new dataProcessor("./data/connector.php");

} // end of init()


<?php require_once('../../../codebase/connector/scheduler_connector.php'); $res=mysql_connect("","skooze","password"); mysql_select_db("skooze"); $list_personavail = new OptionsConnector($res); $list_personavail->render_table("personavail_database","id","id(value),personavail_id(value)"); $scheduler = new SchedulerConnector($res); $scheduler->enable_log("temp.log",true); $scheduler->set_options("personavail", $list_personavail); $scheduler->render_table("skooze_massageappmnt","id","start_date,end_date,id,massagelocation_id,student_id,user_id,company_id,massagetype_id,personavail_id,created_at,updated_at"); ?>


Based on the dhtmlxScheduler/samples/01_initialization_loading/09_connector_options.html sample I would like to demonstrate it. Please update sample contant or create new file there:


<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"

<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.config.multi_day = true;
		scheduler.config.prevent_cache = true;

		scheduler.config.xml_date = "%Y-%m-%d %H:%i";
		var types = scheduler.serverList("type");

		scheduler.init('scheduler_here', new Date(2010, 2, 1), "month");

		scheduler.locale.labels.section_type = "Type";
		scheduler.config.lightbox.sections = [
			{name: "description", height: 200, map_to: "text", type: "textarea", focus: true},
			{name: "type", height: 21, map_to: "type", type: "select",
				options: types },
			{name: "time", height: 72, type: "time", map_to: "auto"}
		scheduler.load("./data/types.php", function() {
			for (var i = 0; i < types.length; i++) {
				var type = types[i];
				console.log(i, type);
[/code] Best regards, Ilya

Once again, thanks for getting back to me on this.
I ran your code and for some reason it’s not getting the types info properly. I usually use chrome, but I ran it through IE and I get the following message from webpage alert -
Fatal error: Class ‘SQLite3’ not found in /DHX/samples/common/config/php on line 7.

Anyway, I didn’t spend time trying to fix this because it’s a different issue and I didn’t want to go off on a tangent. I’m also pretty sure that your code will work.
So I implemented pretty much what you did on my code and it may have shed a little light on the issue in that it’s a slighly different scenario. I’ll explain -

I didn’t provide ALL the details when I sent you the connection.php file. It’s actually something like this -

<?php require_once('../../../codebase/connector/scheduler_connector.php'); $res=mysql_connect("","skooze","password"); mysql_select_db("skooze"); $list_personavail = new OptionsConnector($res); $list_personavail->render_table("personavail_database","id","id(value),persons_id(value),start_date(value),end_date(value)"); $list_persons = new OptionsConnector($res); $list_persons->render_table("person_database","id","id(value),name(value)"); $scheduler = new SchedulerConnector($res); $scheduler->enable_log("temp.log",true); $scheduler->set_options("personavail", $list_personavail); $scheduler->set_options("persons", $list_persons); $scheduler->render_table("skooze_massageappmnt","id","start_date,end_date,id,persons_id"); ?>

So to clarify a little - the main events database is skooze_massageappmnt and there is a foreign key into the person_database table (persons_id). No problem using serverList with the person_database in order to have a selector in a lightbox to choose from the list of names (name) in person_database.
A separate table - personavail_database also has a foreign key (persons_id) into the person_database and this table holds the availabilities (start_date, end_date) that I want to use to mark the background.

As mentioned, I have implemented a similar loop to what you sent me as follows -

var time_spans = scheduler.serverList(“personavail”);
scheduler.init(‘scheduler_here’,new Date(),“month”);
scheduler.load("./data/connector_skoozetest.php", function (){
for (var i = 0; i < time_spans.length; i++) {
var tspan = time_spans[i];
alert("The holy grail: "+tspan);
… etc.

If I run the above, it does not even enter the loop. time_spans is undefined.
However, if I change schedule.serverList(“personavail”) to schedule.serverList(“persons”), then it does go into the loop and iterates based on the number of records in time_spans as it’s supposed to. So there’s an issue related to the foreign key stuff and the relationship to the main database I assume??

By the way, as an aside (and not the main issue) - when I set it to schedule.serverList(“persons”), the alert box prints - “The holy grail: [object Object]”. How do I get it to print the contents of tspan. I tried without avail. Sorry about the noob question.


Ok, so I spent some more time on this one. Based on what I mentioned in my previous post - “issue related to the foreign key stuff and the relationship to the main database I assume??”,
I created a foreigh key field (personavail_id) in the main database (skooze_massageappmnt) to the personavail_database. It now works perfectly (didn’t modify any of my scheduler code, just add the foreign key to the database).
However, this is a kludge and probably bad practice as theres really no direct relationship there (it just makes your software happy). Theres probably a better way to do this. Any ideas?

As an aside, I also figured out how to to access the object.

Thanks in advance,



Sorry, didn’t notice it before.
Actually the the first option should be value, second label and the rest can go as is, so:


Same with your other select.
On client side value will be change to key. Rest stay as is.

Kind regards,

Another note - you can separate this issue into two parts. The first part is to make server return correct data. You can check it by simply opening url in your browser. If the properties are named correctly and the data correct as well then you can move forward and start working with it on client-side.

Kind regards,

Fatal error: Class ‘SQLite3’ not found in /DHX/samples/common/config/php on line 7.

Default samples in scheduler’s package use SQLLite3 as database, above error means that you have not enabled SQLLite3 in php.ini ( enabled by default for latest PHP builds )

Hi Ilya -
Once again, thank you for the great help! I’ve got it working properly now and learned a lot in the process. I still have this weird problem (posted it yesterday) with addMarkedTimespan not working in my application on safari, IE and iPad. It works in Chrome.
Yes your samples using addMarkedTimespan work on all browsers.
I’ve seen some posts in the forum that discuss the order of things and thought it might be that.