monthview scroll date into view

8 posts, 1 answers
  1. Kenneth
    Kenneth avatar
    101 posts
    Member since:
    Apr 2014

    Posted 07 Mar 2015 Link to this post

    I have a 'Show Today' button for the monthview as follows:

    ScheduleView.CurrentDate = Now.Date
    ScheduleView.ScrollIntoView(New Slot(Now.Date, Now.Date), True)

    If I am in the current month and I scroll down so the current date is not visible then It works.

    If I am on a different month and not scrolled down it works.

    It does not work when I am on a different month and scrolled down, it does reset the month but it remains scrolled down.

    If I then click 'Show Today' again it will scroll to display today's date.  If I change the 'Show Today' to this:

    ScheduleView.CurrentDate = Now.Date
    ScheduleView.ScrollIntoView(New Slot(Now.Date, Now.Date), True)
    ScheduleView.ScrollIntoView(New Slot(Now.Date, Now.Date), True)

    it still does not work.

    How can I reset the month view to display today's date no matter the current date or scroll position?

  2. Rosi
    Admin
    Rosi avatar
    2527 posts

    Posted 09 Mar 2015 Link to this post

    Hi,

    I suggest you modify your code like this and reset the scroll before changing the day:

    ScheduleView.HorizontalOffset =0;
    ScheduleView.VerticallOffset =0;

    ScheduleView.CurrentDate = Now.Date
    ScheduleView.ScrollIntoView(New Slot(Now.Date, Now.Date), True)



    Hope this helps.

    Regards,
    Rosi
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. DevCraft banner
  4. Kenneth
    Kenneth avatar
    101 posts
    Member since:
    Apr 2014

    Posted 09 Mar 2015 in reply to Rosi Link to this post

    That does not work if the current date is at the end of the month, then the scroll bars reset to the top/left and leaves the current date only partially visible (due to the height of my control).
  5. Kenneth
    Kenneth avatar
    101 posts
    Member since:
    Apr 2014

    Posted 09 Mar 2015 in reply to Kenneth Link to this post

    It seems to me the problem is with ScrollIntoView, which in monthview does not seem to work properly, as it does not Scroll the date into view.
  6. Rosi
    Admin
    Rosi avatar
    2527 posts

    Posted 10 Mar 2015 Link to this post

    Hi,

    After reviewing your code once again I noticed that you use the following code to scroll the date:

    ScheduleView.ScrollIntoView(New Slot(Now.Date, Now.Date), True)


    I suggest you change it as follows and let us known how this goes.

    ScheduleView.ScrollIntoView(New Slot(Now.Date, Now.Date.AddDays(1)), True)

    Regards,
    Rosi
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  7. Kenneth
    Kenneth avatar
    101 posts
    Member since:
    Apr 2014

    Posted 11 Mar 2015 in reply to Rosi Link to this post

    No, that does not work either.  See attached screen shots, assume today is Mar  11 2015. Before shows Apr 2015 scrolled to the end of the month, after the code is run After shows only the bottom portion of Mar 11 displayed.  A second click on 'show today' moves Mar 11 fully into view.

    To fix it for now I start a timer on the first click and make a second call after 1/4 sec.  That works but I'd rather now have to do such a hack.
  8. Answer
    Kalin
    Admin
    Kalin avatar
    1208 posts

    Posted 16 Mar 2015 Link to this post

    Hi Kenneth,

    Try calling the SrcollIntoView method through a Dispatcher - this way everything should work as expected (for this scenario might be needed).

    Hope this helps.

    Regards,
    Kalin
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  9. Kenneth
    Kenneth avatar
    101 posts
    Member since:
    Apr 2014

    Posted 23 Mar 2015 in reply to Kalin Link to this post

    That seems to work.  Here is the VB.NET solution:

    Delegate Sub ScrollIntoViewDelegate(occurnace As Telerik.Windows.Controls.ScheduleView.Slot, scrollToStart As Boolean)

     Private Sub TodayButton_Click(sender As Object, e As System.Windows.RoutedEventArgs)

            Dim ScrollDelegate As New ScrollIntoViewDelegate(AddressOf ScheduleView.ScrollIntoView)
            ScheduleView.CurrentDate = Now.Date
            Dispatcher.BeginInvoke(ScrollDelegate, New Slot(Now.Date, Now.Date), True)

        End Sub
Back to Top
DevCraft banner