[Bug] Maked time span didn't work with timeline view

Hello,
I have used Dhtmlx Scheduler for a web application project.
Recently, I found a bug between marked time span and timeline view.
When I add a marked time span in unit view, it run perfectly (see Unit View.png). But, when I switch to timeline view and then click the next or prev button, the marked time span gone away and the Chrome’s console shows the error trace (see Timeline View.png).
I also attached the native file dhtmlxscheduler_treetimeline.js from Dhtmlx Scheduler version 4.0.1.

The error in the console points to line 1189 in the function scheduler._get_date_index().
I tried to debug but I cannot find where the problem is.
So, If any body already faced and resolved with this error, please help me!

@ Support team: I would appreciate if you could fix this bug in next release.

Thank you so much.
Files.zip (34.2 KB)

Hi,
can you provide some kind of demo where we could reproduce the issue?

You can use my account to login here: alpha.invo3.com/
Username:
Password:

Here is the steps:

  • Click the Calendar menu after login to access the dhtmlx scheduler screen
  • Click button Stylist under “Sort by” to switch to unit view first
  • Click on the scheduler and select the option “Black out time slot” to create a marked time span
  • Click button Time under “Sort by” to switch to timeline view
  • Click Next or Prev button above the scheduler and you will see the error I mentioned.

Thank you for your help.

Probably the issue is caused by multiple calls of createViews. Re-initializing the views is not an intended way to manipulate configuration of the component, and may have some side-effects that results in an error.
In order to change number of displayed sections of units/timeline, you can use serverList/updateCollection methods.
These methods allows to define sections of the units/timeline as a named collections and then update them from the code.
E.g

[code]//initialize
units:scheduler.serverList(“collection-name”, collection);

//update when needed
scheduler.updateCollection(“collection-name”, newCollection);[/code]
updateCollection triggers all events that needed to redraw calendar and apply the changes.
In your code you’ll have to amend createViews and showStylistColSelector, so they would work with serverList methods, and then make sure createViews is called only once

[code]function createViews(){

//create named collection
scheduler.serverList(“stylist”, calStylistJSON);

scheduler.createTimelineView({
y_unit: scheduler.serverList(“stylist”),//use named collection for both views

});
scheduler.createUnitsView({
list: scheduler.serverList(“stylist”),

});

}

function showStylistColSelector() {

//create new array
var newOptions = stylistJSON.slice();

for(…){

newOptions.splice(index, 1);//filter it as required
}

//update named collection with new array
scheduler.updateCollection(“stylist”, newOptions);
}[/code]

docs.dhtmlx.com/scheduler/api__s … rlist.html
docs.dhtmlx.com/scheduler/api__s … ction.html

Thank you very much, Aliaksandr.
It worked like a charm :wink: