C1Schedule in TimeLineView mode: scroll to date

Posted by: wknauf on 2 February 2021, 6:26 am EST

    • Post Options:
    • Link

    Posted 2 February 2021, 6:26 am EST

    Hi C1,

    attached sample shows the problem: a C1Schedule is in “ViewType = TimeLineView” mode.

    The API does not provide a methode to scroll a specific date into view. “EnsureVisibleTime” does not help, because it does not work in timeline mode.

    Workaround my use case: as I know that the target date is in the middle of the date range, I could set the “ScrollPosition”:

    
          //"Refresh" is required. Otherwise "ScrollSize" is 0.
          this.c1Schedule1.Refresh();
          this.c1Schedule1.ScrollPosition = new Point(-1 * this.c1Schedule1.ScrollSize.Width / 2, 0);
    
    

    So, I request a method “ScrollToDateTime (datetimevalue)”.

    Best regards

    WolfgangC1ScheduleScrollExample.zip

  • Posted 3 February 2021, 8:30 am EST

    Hi Wolfgang,

    The C1Schedule has a method called GoToDate(DateTime date) which does what you require, please refer to the sample attached.

    Documentation Link: https://www.grapecity.com/componentone/docs/win/online-schedule/C1.Win.C1Schedule.4.5.2~C1.Win.C1Schedule.C1Schedule~GoToDate.html?highlight=gotodate%2C

    Regards.

    Avnish

    C1ScheduleScrollExample_mod.zip

  • Posted 4 February 2021, 4:59 am EST

    Hi Avnish,

    this method does not help: I want to show a date range from “refdate -x days to refdate+x days” and scroll to “ref date” which is the middle of this range. "

    GoToDate" changes the current visible date range to “refdate + 2*x days”, which breaks my use case.

    Best regards

    Wolfgang

  • Posted 4 February 2021, 5:01 am EST

    Attached is a reworked sample: first button creates the view range, second button tries to scroll.

    C1ScheduleScrollExample_2021-02-04.zip

  • Posted 4 February 2021, 11:41 pm EST - Updated 3 October 2022, 11:24 pm EST

    Hi Wolfgang,

    If you call the ShowDates method after using the GoToDate method, you will get the desired behavior. Please refer to the sample and GIF attached.

    Regards.

    Avnish

    C1ScheduleScrollExample_mod2.zip

  • Posted 5 February 2021, 3:08 am EST

    Thanks, this works - though it sounds a bit weird ;-).

    Remaining open issue: scrolling to a time of the day (or to an appointment) is not possible.

    Best regards

    Wolfgang

  • Posted 8 February 2021, 4:20 am EST

    Ohhhhh, this makes sense.

    Please tell the developers to improve the API doc for this method. The current comment does not mention this:

    Ensures that the specified time is visible within the control, scrolling the contents if necessary. This method doesn’t make sense for MonthView and Office 2003 WeekView modes.

    Thanks for your help!

    Wolfgang

  • Posted 8 February 2021, 5:33 am EST

    Well, it does not seem to work - see attached sample.

    C1ScheduleScrollExample_2021-02-08.zip

    The sample attached to your previous post was probably meant for another thread?

    Best regards

    Wolfgang

  • Posted 8 February 2021, 6:00 am EST

    Hi,

    Sorry about that, Please find the working sample attached.

    If you face any issues, please let us know.

    Regards.

    C1ScheduleScrollExample_mod00.zip

  • Posted 8 February 2021, 6:00 am EST

    Hi Wolfgang,

    The EnsureVisibleTime() method calculates the TimeSpan starting from the start date of the visible date range. So if you specify 10h30m it will scroll to the time of the first date of the visible range you provided.

    To scroll to a specific time of a specific day when you have shown a date range, you need to specify the full-time span from the starting of the start date to the specific time you want to scroll to.

    For Example, You need to specify 1Day 10H 30m as the TimeSpan in EnsureVisibleTime if you want to scroll to 10h 30m of 6 FEB when the start date of the date range is 5 FEB. Please refer to the sample attached.

    You can use the GoToDate() method to scroll to an appointment by using the start date of the appointment as follows.

    c1Schedule1.GoToDate(appointment.Start);
    

    Regards.

    Avnish

    C1ScheduleScrollExample_mod00.zip

  • Posted 8 February 2021, 6:18 am EST

    OK, the call to “c1Schedule.Refresh()” was missing in my sample. Thanks again! Now we are done I hope ;-).

    Best regards

    Wolfgang

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels