)
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 horizontal scrollbar automatically to display the current date at the initial position of the timeline month view?

Platform: ASP.NET MVC |
Control: Schedule |
Published Date: December 1, 2017 |
Last Revised Date: May 23, 2019

The following steps shows the way to adjust the horizontal scroll value, to display the current date at the initial position of the timeline month view.

 

Step 1:  Create an MVC application and include the EJMVC Schedule control in it by referring the following KB link,

https://syncfusion.com/kb/3606/how-to-add-the-ejmvc-schedule-control-in-the-mvc-application

 

Step 2:  Define the ActionComplete event of Schedule with appropriate handler, which gets triggered on every successful schedule action completion. 

@(Html.EJ().Schedule("Schedule1")

        .Width("100%")

        .CellWidth("70px")

        .Height("525px")

        .CurrentDate(new DateTime(2016, 10, 25))

        .Orientation(Orientation.Horizontal)

        .AppointmentSettings(fields => fields.Datasource(ViewBag.datasource)

            .Id("Id")

            .Subject("Subject")

            .StartTime("StartTime")

            .EndTime("EndTime")

            .Description("Description")

            .AllDay("AllDay")

            .Recurrence("Recurrence")

            .RecurrenceRule("RecurrenceRule"))

            .ScheduleClientSideEvents(evt =>

            evt.ActionComplete("OnActionComplete"))

)

 

Step 3: Here, OnActionComplete is an event handler function, within which the code to move the horizontal scrollbar to specific position has been added, so that the current date in the month view is positioned to display first. It is done by checking whether the current request type is ‘viewNavigate’ and also the current view is ‘month’ as shown in the below code example.

function OnActionComplete(args) {

        var scheduleObj = $("#Schedule1").data("ejSchedule");

        var scrollerObj = scheduleObj.element.find('div#' + scheduleObj._id + '_scroller').data("ejScroller");

        if ((!ej.isNullOrUndefined(scrollerObj)) && args.requestType == "viewNavigate" && args.data.currentView == "month") {

            scheduleObj.element.find("div#" + scheduleObj._id + "_scroller").ejScroller({ scrollLeft: (scheduleObj.cellwidth * (scheduleObj.currentDate().getDate() - 1)) });

        }

    }

 

Sample: http://www.syncfusion.com/downloads/support/directtrac/general/ze/sample-800205219

 

Step 4: Run the above sample and the horizontal scrollbar will be adjusted automatically to display the current date at the initial position as shown below.

Month view with adjusted horizontal scrollbar

Figure 1: Month view with adjusted horizontal scrollbar.

2X faster development

The ultimate ASP.NET MVC 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