Hi,
I tried the code snippet attached in the previous post but the timespans persist in different views. The following is my code sample.
I want the timespans to be shows correctly in different views, there could be exceptions added by anyone they all should be shows correctly.
For example, in the resource view an exception is added for all the sections between 2 am - 9 am, and an exception for section-4 between 10 am - 12 pm, I want all the sections to show the common timespan and section-4 to show 10 am -12 pm timespan for March 24. When i load the resource view for tomorrow, it should only show the timespans for tomorrow and not display the ones from today. My problem is when I load March 24 for the first time, the timespans are shown correctly but when I load March 25 which has no timespans, all the timespans from March 24 are showing in March 25. I need to prevent this from happening since I pass in the list of exception every time a new view is loaded. Could you please point me to a way where i could remove the timespans from the previous views and load them again correctly for the current view?
I pass in an array that has details of the timespans
["{ start_date:“2016,2,24,0,0,0,0”, end_date:“2016,2,24,0,1,0,0”, color:“green”, section_id:1, excepid:“9F1E1509-3D1A-4ACE-946F-19DAEE23B5F3”}","{ start_date:“2016,2,24,23,59,0,0”, end_date:“2016,2,25,0,0,0,0”, color:“green”, section_id:1, excepid:“2F38FDE1-46D4-44F7-892C-72FFD35D0DAC”}"]
function refreshExceptions(excep, refreshScreen){
if(excep && excep.length > 0){
var sBlockTime;
for (var i=0; i < excep.length; i++){
var aStart = excep[i].start_date.split(",");
var dStart = new Date();
dStart.setFullYear(aStart[0],aStart[1],aStart[2]);
dStart.setHours(aStart[3]);
dStart.setMinutes(aStart[4],aStart[5],0);
var aEnd = excep[i].end_date.split(",");
var dEnd = new Date();
dEnd.setFullYear(aEnd[0],aEnd[1],aEnd[2]);
dEnd.setHours(aEnd[3]);
dEnd.setMinutes(aEnd[4],aEnd[5],0);
var id = excep[i].section_id;
sBlockTime = {
start_date: dStart,
end_date: dEnd,
css: "BlockTime",
type: "dhx_time_block",
sections: { timeline:id, unit:id}
}
if (sBlockTime){
scheduler.addMarkedTimespan(sBlockTime);
}
}
if(refreshScreen){
scheduler.updateView(_DisplayDate, _mode);
}
}
}