This is a migrated thread and some comments may be shown as answers.

monthview scroll date into view

7 Answers 61 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Kenneth
Top achievements
Rank 2
Iron
Kenneth asked on 07 Mar 2015, 02:46 PM
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?

7 Answers, 1 is accepted

Sort by
0
Rosi
Telerik team
answered on 09 Mar 2015, 12:27 PM
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.

 
0
Kenneth
Top achievements
Rank 2
Iron
answered on 09 Mar 2015, 01:50 PM
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).
0
Kenneth
Top achievements
Rank 2
Iron
answered on 09 Mar 2015, 01:52 PM
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.
0
Rosi
Telerik team
answered on 10 Mar 2015, 08:03 AM
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.

 
0
Kenneth
Top achievements
Rank 2
Iron
answered on 11 Mar 2015, 01:51 PM
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.
0
Accepted
Kalin
Telerik team
answered on 16 Mar 2015, 11:08 AM
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.

 
0
Kenneth
Top achievements
Rank 2
Iron
answered on 23 Mar 2015, 04:58 PM
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
Tags
ScheduleView
Asked by
Kenneth
Top achievements
Rank 2
Iron
Answers by
Rosi
Telerik team
Kenneth
Top achievements
Rank 2
Iron
Kalin
Telerik team
Share this question
or