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

Hiding times that are non business days

Asked by Jay
12 years ago.

Hello Dan,

I was wondering if there is a way to render Daypilot so that it would only display the cells for business hours, ie from 8AM - 5PM and not 12AM to 11PM. It's a bit of a nitpick, but our clients would prefer just having the times that are(their)business hours to work with, and not having to scroll down large amounts when the intervals are small (say 5 minutes). I looked through to see if there is a functionality such as hiding cells or just turning off rows altogether, but there doesn't seem to be this feature. If thereisI'd love to know how to implement it. Thank you.

Comment posted by Jay
12 years ago.

Also, I was using ScrollPositionHour as a temporary solution, but I noticed that whenever I switch time intervals and do a callback, daypilot does not automatically scroll to the businesshour (8AM) in this case. This is especially true on 5 and 10 min intervals, which I've been testing on - they usually start me off at 2AM or 3AM if the first business hour is 8AM.

Comment posted by Dan Letecky
12 years ago.
If you mean DayPilotCalendar, you can do almost exactly this by using HeightSpec="BusinessHours". It hides the non-business hours (set using BusinessBeginsHour and BusinessEndsHours). What it can't do, however, is to keep the vertical scrollbar (it automatically hides the scrollbar so you have to use the page scrollbar).

For DayPilotScheduler, it's not so trivial (because it can show multiple days on the X axis one after another). I've scheduled this feature for 4.4. release.
Comment posted by Dan Letecky
12 years ago.
> Also, I was using ScrollPositionHour as a temporary solution

There is something weird going on with the ScrollPositionHour. I will be investigating this issue.
Comment posted by Jay
12 years ago.

Thanks Dan, it worked great. Just to clarify for others who may have same problem, you need to use DayPilot.Web.Ui.Enums.HeightSpecEnum.BusinessHoursNoScroll and not DayPilot.Web.Ui.Enums.HeightSpecEnum.BusinessHours. Afterwards, set the following times:

DayPilotCalendar1.BusinessBeginsHour = 8
DayPilotCalendar1.BusinessEndsHour = 17

The user will only be able to see the business hours time block. This is exactly what I'm looking for. Thank you.

Comment posted by Jay
12 years ago.

Upon further investigation, it works with the exception of a small bug (in IE7 only I'm assuming):

the columns and the header in Daypilot calendar are not lining up. This only occurs the first time, as after each subsequent refresh, the calendar looks ok. I mentioned this issue when I tried to change heightspec to "full" mode as well.

Are there any plans to fix this bug in a future release?

Comment posted by Dan Letecky
12 years ago.
Jay, Thanks for the clarification, it was my mistake.

Yes, I know about the IE7 bug. I'm investigating it at the moment. It should be fixed quite soon.
Comment posted by Jay
12 years ago.

Glad to hear it'll be fixed soon. =)

A quick workaround I've used is to put this in javascript:

Page.ClientScript.RegisterStartupScript(this.GetType(), "refresh", "window.location.href=window.location;", true);

So when your page first loads, javascript will cause the page to refresh, and daypilot calendar will be rendered correctly. I know this isn't the best way to go about doing things, but it's a quick fix until the next release for those interested.

Comment posted by Anonymous
12 years ago.

Hi all,

I'm using version 4.1.1252.1 of DayPilot within visual studio 2005 sp1. When I change the .ScrollPositionHour with .HeightSpec = Fixed (or = BusinessHours) and then databind/update, no scroll change is happening.

From what I've read in this thread this seems to be an issue identified previously, but there's no mention of it being resolved in any version. Has it been resolved? I've checked the online notes against each release version and can find no mention.

Please can you let me know if it has been resolved, or will be resolved.

Cheers for now


Comment posted by Dan Letecky
12 years ago.
The current behavior of DayPilotCalendar is following:
  • ScrollPositionHour is used for the initial rendering (i.e. no PostBack, no CallBack).
  • During CallBack, the scroll position can't be changed (it keeps the current position).
  • During PostBack, the scroll position can't be changed (the controls is redrawn in full and autoscrolled into the original position).
The reason why it wasn't designed to be updatable during postback/callback is that the current position can't be mapped exactly back into the ScrollPositionHour (it works with integer hour values). However, I could detect a change in the setter and reset the scrollbar position only if ScrollPositionHour was updated during postback/callback.

At this moment, you can change the scroll position using a client-side API:
dpc.$('scroll').scrollTop = valueInPixels; 
("dpc" being the value of ClientObjectName)
Comment posted by Dan Letecky
12 years ago.
And back to the original title (hiding non-business days):

To hide the non-business days (e.g. weekends) in DayPilotCalendar, you can use the following trick:
  1. Switch to ViewType="Resources".
  2. Generate the Columns collection manually in Page_Load. Remember to specify the correct Column.Date.
An example can be found in Demo/Test/NonBusinessDays.aspx in the download package (both full and trial):
    protected void Page_Load(object sender, EventArgs e)
DateTime first = new DateTime(2007, 1, 1);

for (int i = 0; i < 7; i++)
Column c = new Column();
DateTime date = first.AddDays(i);

if (date.DayOfWeek == DayOfWeek.Wednesday || date.DayOfWeek == DayOfWeek.Friday)

c.Name = date.ToShortDateString();
c.Date = date;
This question is more than 3 months old and has been closed. Please create a new question if you have anything to add.