We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to adjust the scrollbar based on current time ?

Platform: ASP.NET Web Forms |
Control: Schedule |
Published Date: October 16, 2018 |
Last Revised Date: May 23, 2019

This knowledge base article explains how to set the scroller position of scheduler based on the current system time.

 

Step 1: Create a default ASP.NET Web Forms Schedule sample by referring the below online link.

https://www.syncfusion.com/kb/3948/how-to-add-the-ejweb-schedule-control-in-the-asp-net-application

Step 2: Define the Scheduler Create and ActionComplete events which will be triggered during the initial load and on view navigation as shown below. 

<ej:Schedule ClientIDMode="Static" runat="server"
                ID="Schedule1" Orientation="Horizontal" Locale="en-US" Width="100%" DataSourceID="objectDataSource1" Height="525px" CurrentDate="10/12/2018"
                Views="Day,Week,WorkWeek,Month" StartHour="0" EndHour="24" CurrentView="Day" 
                AppointmentTemplateId="#MyTemplate" Create="onCreate" ActionComplete="onComplete">
                <Group Resources="Owners" />
                <Resources>
                    <ej:Resources Field="Owner" Name="Owners" Title="Owner" AllowMultiple="true">
                        <ResourceSettings Color="color" Id="id" Text="text">
                        </ResourceSettings>
                    </ej:Resources>
                </Resources>
                <ContextMenuSettings Enable="true">
                </ContextMenuSettings>
                <CategorizeSettings Enable="true">
                </CategorizeSettings>
                <PrioritySettings Enable="true"></PrioritySettings>
                <AppointmentSettings Id="ID" Subject="Subject" AllDay="AllDay" StartTime="StartTime" EndTime="EndTime" Description="Description" Recurrence="Recurrence" RecurrenceRule="RecurrenceRule" ResourceFields="Owner" />
            </ej:Schedule>

 

Step 3: By default, schedule scroller will be rendered based on work hour range (9 AM) as shown below.

Schedule control with scroll position on default work hour range

Figure 1: Schedule control with scroll position on default work hour range.

 

Step 4: To change its default position based on the current system time, scroller left value (for horizontal mode) / scroller top value (for vertical mode) needs to be updated with the current time cell range. The code to change the scroll position during the initial load and on view navigation is defined within the onCreate and onComplete functions as shown below.

function onCreate() {
    var scheduleObj = $("#Schedule1").data("ejSchedule");
    var scrollerObj = scheduleObj.element.find('div#' + scheduleObj._id + '_scroller').data("ejScroller");
    if ($(".e-highlightcurrenttimeline").length != 0 && (!ej.isNullOrUndefined(scrollerObj))) {
        if (scheduleObj.model.orientation == "horizontal")
            scheduleObj.element.find("div#" + scheduleObj._id + "_scroller").ejScroller({ scrollLeft: (parseInt($(".e-highlightcurrenttimeline").css("left")) - 100) });
        else
            scheduleObj.element.find("div#" + scheduleObj._id + "_scroller").ejScroller({ scrollTop: (parseInt($(".e-highlightcurrenttimeline").css("top")) - 100) });
    }
}
function onComplete(args) {
    if (args.requestType == "dateNavigate" || args.requestType == "viewNavigate")
        onCreate();
}

 

Step 5: Run the sample and the Schedule scroller will be displayed based on current time range (7 PM) as follows.

Schedule control display with new scroll position based on current time

Figure 2: Schedule control display with new scroll position based on current time.

 

Sample Link:

http://www.syncfusion.com/downloads/support/forum/133661/ze/Schedule_Scrollbar1051256954

2X faster development

The ultimate ASP.NET Web Forms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon