Scheduler ScrollToTime not scrolling far enough

4 posts, 0 answers
  1. Grant Fish
    Grant Fish avatar
    10 posts
    Member since:
    Apr 2010

    Posted 13 May 2014 Link to this post

    I am having problems with the Scheduler's ScrollToTime method not working properly. It does change the scroll position, but not far enough.

    I am using the Scheduler with an ActiveViewType of Day and displaying one week of data in 15 minute increments. The combinatin of  RulerScale and in the control's size this displays about 10 hours of data. I am trying to get the control to scroll to a position that a normal work day is in the middle of the screen.

    I am using ScrollToTime and it appears to be doing something, but does not scroll far enough. No matter what TimeSpan value I enter in the ScrollToTime method, it will only scroll the control forward about 2 hours.

    I suspect that ScrollToTime attempts to determine how far (in actual distance) to scroll, but is possibly ignoring the RulerScale setting when calculating this value.

    These are the values that I am using for the RadScheduler control:

    SchedulerDayView WeekSchedulerDayView = WeekScheduler.GetDayView();
    WeekSchedulerDayView.DayCount = 7;
     WeekScheduler.HeaderFormat = "dddd";

    WeekSchedulerDayView.RulerScaleSize = 10;
    WeekSchedulerDayView.RulerTimeFormat = RulerTimeFormat.hours12;
    WeekSchedulerDayView.WorkTime.Start = TimeSpan.Parse("08:00");
    WeekSchedulerDayView.WorkTime.End = TimeSpan.Parse("17:00");

    WeekSchedulerDayView.RangeFactor = ScaleRange.QuarterHour;
    WeekSchedulerDayView.ShowAllDayArea = false;

    SchedulerDayViewElement dayViewElement = WeekScheduler.SchedulerElement.ViewElement as SchedulerDayViewElement;
    if (dayViewElement != null)
    {
     dayViewElement.DataAreaElement.Table.ScrollToTime(TimeSpan.Parse("18:00"));
    }
  2. Dess
    Admin
    Dess avatar
    1601 posts

    Posted 16 May 2014 Link to this post

    Hello Grant,

    Thank you for writing.

    It is appropriate to call the ScrollToTime method, after the RadScheduler layout is performed completely, e.g. in the Form.Load event or later:
    public Form1()
    {
        InitializeComponent();
        SchedulerDayView WeekSchedulerDayView = this.radScheduler1.GetDayView();
        WeekSchedulerDayView.DayCount = 7;
        this.radScheduler1.HeaderFormat = "dddd";
        WeekSchedulerDayView.RulerScaleSize = 10;
        WeekSchedulerDayView.RulerTimeFormat = RulerTimeFormat.hours12;
        WeekSchedulerDayView.WorkTime.Start = TimeSpan.Parse("08:00");
        WeekSchedulerDayView.WorkTime.End = TimeSpan.Parse("17:00");
        WeekSchedulerDayView.RangeFactor = ScaleRange.QuarterHour;
        WeekSchedulerDayView.ShowAllDayArea = false;
    }
     
    private void Form1_Load(object sender, EventArgs e)
    {
        SchedulerDayViewElement dayViewElement = this.radScheduler1.SchedulerElement.ViewElement as SchedulerDayViewElement;
        if (dayViewElement != null)
        {
            dayViewElement.DataAreaElement.Table.ScrollToTime(TimeSpan.Parse("18:00"));
        }
    }

    I hope this information helps. Should you have further questions, I would be glad to help.

    Regards,
    Desislava
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Grant Fish
    Grant Fish avatar
    10 posts
    Member since:
    Apr 2010

    Posted 16 May 2014 in reply to Dess Link to this post

    Thanks, this did work.

    I also discovered that if a RadScheduler is on a tab control and the tab isn't the default tab, you need to delay the ScrollToTime call until the tab is initially selected.
  5. Dess
    Admin
    Dess avatar
    1601 posts

    Posted 19 May 2014 Link to this post

    Hello Grant,

    Thank you for writing back.

    The ScrollToTime method should be called after the RadScheduler's layout is performed successfully. If you have several RadPageViewPages and the one, containing the RadScheduler, is currently not selected, it is necessary to subscribe to the SelectedPageChanged event and there to call the ScrollToTime method.
    RadPageView pv = new RadPageView();
    RadScheduler scheduler = new RadScheduler();
     
    public Form1()
    {
        InitializeComponent();
     
        for (int i = 0; i < 3; i++)
        {
            RadPageViewPage page = new RadPageViewPage();
            if (i == 1)
            {
                page.Controls.Add(scheduler);
                scheduler.Dock = DockStyle.Fill;
     
                scheduler.SchedulerElement.InvalidateMeasure(true);
                scheduler.SchedulerElement.UpdateLayout();
            }
            pv.Pages.Add(page);
        }
        this.Controls.Add(pv);
        pv.Dock = DockStyle.Fill;
     
        pv.SelectedPageChanged += radPageView1_SelectedPageChanged;
    }
     
    private void radPageView1_SelectedPageChanged(object sender, EventArgs e)
    {
        if (pv.SelectedPage.Text == "Page2")
        {
            SchedulerDayViewElement dayViewElement = scheduler.SchedulerElement.ViewElement as SchedulerDayViewElement;
            if (dayViewElement != null)
            {
                dayViewElement.DataAreaElement.Table.ScrollToTime(TimeSpan.Parse("18:00"));
            }
        }
    }

    Another approach that I can suggest is to force the scheduler's layout when adding to the RadPageViewPage:
    public Form1()
    {
        InitializeComponent();
     
        for (int i = 0; i < 3; i++)
        {
            RadPageViewPage page = new RadPageViewPage();
            if (i == 1)
            {
                page.Controls.Add(scheduler);
                scheduler.Dock = DockStyle.Fill;
     
                scheduler.SchedulerElement.InvalidateMeasure(true);
                scheduler.SchedulerElement.UpdateLayout();
                scheduler.LoadElementTree();
     
                SchedulerDayViewElement dayViewElement = scheduler.SchedulerElement.ViewElement as SchedulerDayViewElement;
                if (dayViewElement != null)
                {
                    dayViewElement.DataAreaElement.Table.ScrollToTime(TimeSpan.Parse("18:00"));
                }
            }
            pv.Pages.Add(page);
        }
        this.Controls.Add(pv);
        pv.Dock = DockStyle.Fill;
    }

    I hope this information helps. If you have any additional questions, please let me know.

    Regards,
    Desislava
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
Back to Top