If a units view is created with the following config a JS error will be thrown as the code attempts to assign a class to a node that doesn’t exist if the days one and a size is defined.
Using this config will generate the error.
scheduler.createUnitsView({
name: "unit",
property: "unitsview",
list: [
{key:"Unit_One",label:"Unit One"},
{key:"Unit_Two",label:"Unit Two"},
{key:"Unit_Three",label:"Unit Three"},
{key:"Unit_Four",label:"Unit Four"}
],
size: 2,
step: 2,
days: 0, // can be null or left out completely and same error results.
skip_incorrect: true
});
I edited the dhtmlxscheduler_units.js file to correct for the error as follows. This seems to work.
scheduler._reset_scale = function () {
var e = scheduler._props[this._mode],
t = a.apply(this, arguments);
if (e) {
this._max_date = this.date.add(this._min_date, e.days, "day");
for (var r = this._els.dhx_cal_data[0].childNodes, s = 0; s < r.length; s++)
r[s].className = r[s].className.replace("_now", "");
var n = new Date;
if (n.valueOf() >= this._min_date && n.valueOf() < this._max_date) {
var i = 864e5,
d = Math.floor((n - scheduler._min_date) / i),
l = e.options.length,
_ = d * l,
o = _ + l;
//************The error occurs here without this fix.*******************
if(e.days > 1){ //added in if clause to check if more than one day - JJC Feb 7, 2015
for (s = _; o > s; s++)
r[s].className = r[s].className.replace("dhx_scale_holder", "dhx_scale_holder_now");
}else{
for(s=0; s < r.length; s++)
r[s].className = r[s].className.replace("dhx_scale_holder", "dhx_scale_holder_now");
}
}
if (e.size && e.size < e.options.length) {
var c = this._els.dhx_cal_header[0],
h = document.createElement("DIV");
e.position && (h.className = "dhx_cal_prev_button", h.style.cssText = "left:1px;top:2px;position:absolute;", h.innerHTML = " ", c.firstChild.appendChild(h), h.onclick = function () {
scheduler.scrollUnit(-1 * e.step)
}),
e.position + e.size < e.options.length && (h = document.createElement("DIV"), h.className = "dhx_cal_next_button", h.style.cssText = "left:auto; right:0px;top:2px;position:absolute;", h.innerHTML = " ", c.lastChild.appendChild(h), h.onclick = function () {
scheduler.scrollUnit(e.step)
})
}
}
return t
};