Error with units view in version 4.3

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 = "&nbsp;", 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 = "&nbsp;", c.lastChild.appendChild(h), h.onclick = function () { scheduler.scrollUnit(e.step) }) } } return t };

Hello,
the ‘scroll’ and ‘step’ are not supported by the multiday mode, please check the notes
docs.dhtmlx.com/scheduler/units_ … ltipledays

but thanks for the patch, i’ll check it and give you an update soon

Hi,
Thanks but I must not have been clear. The following exhibits the same error without the use of the days mode.

scheduler.createUnitsView({
name: "unit",
property: "unit",
list: [
{key:1,label:"one"},
{key:2,label:"two"},
{key:3,label:"three"},
{key:4,label:"four"},
{key:5,label:"five"}
],
size: 3,
step: 5,
skip_incorrect: true
});

Hello,

This bug can be seen by using your own example at http://docs.dhtmlx.com/scheduler/samples/03_extensions/18_scroll_units.html and clicking the “today” button. A javascript error will be thrown showing the problem.

Thanks.

Hi,
thanks, we’ve confirmed the problem. We’ll publish a bugfix release in the nearest time