search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Set timerange to 8 am until 3am the next day

Asked by Rik Slendebroek
7 years ago.

We have a construct where you can set the beginning of the day and the end. To get this to work I uuse dp.onIncludeTimeCell (I first used bussinessHours, but those skip saturday and sunday). It works fine until you try to set the endTime to the next day (example given 8am until 3am next day).

// start 8 end 3
if (startHours > endHours)
{
dp.days = 2;
var currentDay = parseInt(self.searchDate().format("D"));
dp.onIncludeTimeCell = function (args)
{
if (args.cell.end.getDay() != currentDay)
return args.cell.start.getHours() < endHours;
else
return args.cell.start.getHours() > startHours;
};
} else
{
dp.onIncludeTimeCell = function (args)
{
return !(args.cell.start.getHours() > endHours || args.cell.start.getHours() < startHours)
}
}

If i run through the ifs it gets the right return, however it still shows every hour (my guess is that it gets overriden when it checks the time for the current day).
Is there a way to get this to work?

Answer posted by Dan Letecky [DayPilot]
7 years ago.

Rik,

I didn't check the actual logic of your sample but the result should be set using args.cell.visible property instead of the return statement.

See also:
https://api.daypilot.org/daypilot-scheduler-onincludetimecell/

The last snippet updated:

dp.onIncludeTimeCell = function (args) 
{ 
  args.cell.visible = !(args.cell.start.getHours() > endHours || args.cell.start.getHours() < startHours);
} 

Let me know if it didn't help.

Comment posted by Rik Slendebroek
7 years ago.

Thats indeed the solution, thanks!

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.