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

ScrollPositionHour not working properly

Asked by brandon
11 years ago.

Hi Dan,

So I'm continuing work on the same MVC3 calendar from before (using version 1.5.5402.1) and I've come across another problem that I think might be a bug. I've had trouble finding exactly how it works, but it's my understanding that the dpc's ScrollPositionHour property can be set to an int of the hour that should be the uppermost visible hour upon page load. So if i set it to 8 (in the same way I would set BusinessBeginsHour = 8) then 8 o' clock should be scrolled to when the page loads. My calendar loads scrolled all the way up, displaying 12am - 7am instead of 8am - 3pm as I would like. I've tried changing ScrollPositionHour to many different things but nothing so far has had any effect. A few weeks ago it would load as I want with 8am being the first hour you see (I think just because that's BusinessBeginsHour) and I don't quite know what I changed to lose that effect. Hopefully I'm just using the property wrong and you can just point me in the right direction..

Thanks,
Brandon

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

It should be working as you describe, i.e. it will scroll to the set position after the initial page load. The default value is set to BusinessBeginsHour and you can override it as needed:

        <%=Html.DayPilotCalendar("dpc", new DayPilotCalendarConfig(Silver.Theme)
           {
               ViewType = DayPilot.Web.Mvc.Enums.Calendar.ViewType.Week,
               BackendUrl = ResolveUrl("~/Calendar/Backend"),
               ScrollPositionHour = 10
            })%>

It seems to work fine in the demo.

The problem may be the if the Calendar is not visible during initialization (e.g. it's placed on a tab which is hidden) then the scrollbar position update has no effect (that's a browser limitation).

You can fix it by calling:

dpc.enableScrolling();
You can also set the scrollbar position directly (in pixels):
dpc.nav.scroll.scrollTop = 9 * dpc.cellHeight + 1;

Please let me know if it still doesn't work.

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