(defect) scheduler.load() 'xml' param not taken into account

Hi,

(v3.7)

If I do not mistakes while testing, above one (1/)defect and one (2/)feature :

1/ Defect

I try and use ‘json’ value as scheduler load() method param : that works file, well done !
However, in a flexibility goal I have decided to use a dynamic param for the “type” of data.

But in this way, when I use ‘xml’ instead of ‘json’, an error is triggered :

TypeError: this[this._process] is undefined
in dhtmlxscheduler.js (source file) line 181

‘xml’ is using by default in this method if no type or an empty string is specified, but it seems not taken into account if it is hard-specified : scheduler.load(<myUrl>, 'xml');
It probably could be added to allowed types param values ?

2/ Feature

While talking about dynamic params, it is not obvious to work with them in this load() method, which can take as second parameter either a string either a method, and as third param a method if second one is a string.

Today, two solutions :

a. Deal with some “IF” statements for the 3/4 cases :

// "json", "ical" or "" for xml  
if (<i have only a type>) {
    scheduler.load(<myUrl>, <myType>);
}

// a function(){}
else if (<i have only a function>) {
    scheduler.load(<myUrl>, <myFunc>);
}

// "json", "ical" or "" for xml + a function(){}
else if (<i have both>) {
    scheduler.load(<myUrl>, <myType>, <myFunc>);
}

// nothing, xml by default
else {
    scheduler.load(<myUrl>);
}

b. Store params in an array and call the load method with apply() :

// array of load() arguments with at least myURL
var loadArgs = [<myUrl>];

// "json", "ical" or "" for xml  
if (<i have a type>) {
    loadArgs.push(<myType>);
}

// a function(){}
if (<i have a function>) {
    loadArgs.push(<myFunc>);
}

// call load() with well-ordered params
scheduler.load.apply(scheduler, loadArgs);

The “feature” idea, to keep backward compatibility, could be directly accepting an object as second parameter, like :

scheduler.load(<myUrl>, {type:<myType>, func:<myFunc>});

But in this way, scheduler.load() function need to be improved :

scheduler.load = function(url, call) {
	// added
	if ('object' === typeof call) {
		if (undefined !== call.type) {
			this._process = call.type;
		}
		call = call.func;
	}
	else
	// /added
	if (typeof call == "string") {
		this._process = call;
		call = arguments[2];
	}

	this._load_url = url;
	this._after_call = call;
	this._load(url, this._date);
};

(1)
yep, this is the logical inconsistence in API, we will fix it in the next update

(2)

It has sense, but assuming that above issues will be fixed, you can always provide 3 parameters to the method

  • url
  • type ( string “xml”, “json”, etc )
  • callback ( false if not necessary )

So it can be used as a method with 3 mandatory parameters, which removes complexity with parameters order.

Exactly, fixing first issue will solve second one.

PS: Is there a bug tracker or something else, or bugs can be posted there as I did ?

There is no public bug tracker, you can post any issues directly on forum