Load combo from database using "collections"

I was loading a combo in lightbox fetching options from the database using:

scheduler.load("myWebService.asmx/GetComboOptions", "json");

and with the following configuration in scheduler.config.lightbox.sections:

{ name: "subject", height: 21, type: "select", map_to: "myComboOption", options: scheduler.serverList("myComboOption"), cache: true },

it was working great when using ASP.NET 2.0 (response from myWebService)

{"collections":{"myComboOption":[{"value":1,"label":"test1"},{"value":2,"label":"test2"},{"value":3,"label":"test3"}]}}

but after migrating to ASP.NET 3.5 (myWebService is returning also the “d” attribute breaking the json processing in dhtmlxscheduler)

{"d":{"collections":{"myComboOption":[{"value":1,"label":"test1"},{"value":2,"label":"test2"},{"value":3,"label":"test3"}]}}}

I make it work changing the following line in dhtmxScheduler source code:

var collections = (scheduler._temp && scheduler._temp.collections) ? scheduler._temp.collections : {};

With:

var collections = (scheduler._temp.d && scheduler._temp.d.collections) ? scheduler._temp.d.collections : {};

Another solution I think could work is using onBeforeLightbox event

scheduler.attachEvent("onBeforeLightbox", function (event_id){ //if the combo is empty load options from database using ajax });

Anyway, I’m trying to keep using “scheduler.load” but I would prefer not to change the source code just to process the “d” attribute correctly. Is that possible?
Thanks!

You can replace

scheduler.load(url, json)

with

dhtmlxAjax.get(url, function(response){ eval("scheduler.temp = "+response.xmlDoc.responseText); scheduler.parse(scheduler.temp.d, "json") });

Above code will load data, parse json, and load the necessary part of it through parse command

Thanks for your reply. It made it work but with some modifications:

dhtmlxAjax.get("myWebService.asmx/GetComboOptions", function(response){ jsonResponse=$.parseJSON(response.xmlDoc.responseText) scheduler._temp = jsonResponse.d; scheduler.parse(scheduler._temp, "json") });

Since loading of events doesn’t work because of “d” attribute I tried to use the same approach, but it’s more complex since I have to add “from” & “to” parameters to the url. I guess I’ll have to recreate this functionality:

[code]
var lf = this.templates.load_format;

	from = this.date[this._load_mode + "_start"](new Date(from.valueOf()));
	while (from > this._min_date) from = this.date.add(from, -1, this._load_mode);
	to = from;

	var cache_line = true;
	while (to < this._max_date) {
		to = this.date.add(to, 1, this._load_mode);
		if (this._loaded[lf(from)] && cache_line)
			from = this.date.add(from, 1, this._load_mode); else cache_line = false;
	}

	var temp_to = to;
	do {
		to = temp_to;
		temp_to = this.date.add(to, -1, this._load_mode);
	} while (temp_to > from && this._loaded[lf(temp_to)]);[/code]

Any hint on how to achieve this?

btw, the calendar is designed to work with asp.net MVC only?
I’m asking since I would expect to handle the “d” parameter by itself if I use only web services.

In few days we will release the dhtmlxScheduler 4.0, it will have extra events to handle above situation.

btw, the calendar is designed to work with asp.net MVC only?
The calendar was created to be server side agnostic. It works better with MVC frameworks but can be used with any server side. When parsing json data it expects common json format, which is the same for all platforms.