Multiple rulers

4 posts, 0 answers
  1. Bernhard
    Bernhard avatar
    8 posts
    Member since:
    Jul 2013

    Posted 27 Jun Link to this post

    Hi.

    I'd like to use the scheduler for a work time recording software where users can enter their worktime by creating events in the scheduler.
    There is also a time clock in the office and I'd like to highlight the times when users came in or left the office, just like the ruler does.
    So, is it possible to draw two rulers per day? Or is it possible to draw custom lines?
    Right now, I am changing the background color of the timespan where the user is in the office, but that approach has a low performance
    because I handle that in the CellFormatting event and I have to check if the current cell is in that timespan.

  2. Dess
    Admin
    Dess avatar
    2100 posts

    Posted 28 Jun Link to this post

    Hello Bernhard, 

    Thank you for writing.  

    By design, RadScheduler will display multiple rulers if several times zones are added. The following help article is quite useful on this topic: http://docs.telerik.com/devtools/winforms/scheduler/views/time-zones

    However, according to the provided information, I don't think that you need multiple rulers. RadScheduler supports work time. The work time hours is a predefined range of hours, which can be specified within the timeline to make it easier for end-users to carry out scheduling. They are properly indicated by a lighter color, similar to Microsoft Outlook, and are controlled by the TimeInterval property. Additional information is available here: http://docs.telerik.com/devtools/winforms/scheduler/views/day-view

    An alternative approach is to use the CellFormatting event. However, note that this event is purposed to customize the style for the cells and you should avoid performing long-lasting operations in the event handler. Otherwise, performance will be affected.

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

    Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Ronald
    Ronald avatar
    1 posts
    Member since:
    Jul 2017

    Posted 06 Jul in reply to Dess Link to this post

    Hi Dess.

    We've used the CellFormatting event for that, which works fine. The work time of the RadScheduler is not the right approach for that, because the times when our employees come to or leave the office are different on every other day.

    The question of my colleague was a bit misleading. Is it possible to draw multiple time pointers, just like the current time pointer (not rulers)?

    Another issue we've got is, that the AppointmentAdded event is fired whenever the user types in a text in an appointment, independent from whether an appointment is actually created or the subject of an existing appointment is edited. So every time one would edit the appointment's subject inline, another appointment is created. We also want to avoid using a pop-up for editing appointments.
    So, what's the workaround for this?

    Regards,
    Ronald

  4. Dess
    Admin
    Dess avatar
    2100 posts

    Posted 07 Jul Link to this post

    Hello Ronald, 

    Thank you for writing.  

    If you set the AllowAppointmentCreateInline property to true, you will be able to create appointments by using an inline editor which is activated as soon as you type some text over a selected cell. Skip the edit dialog by canceling the AppointmentEditDialogShowing event. In order to use an inline editor for editing already existing appointments, it is necessary to set the SchedulerElement.EditorManager.EditorViewMode to Editor. Additional information about editing in RadScheduler is available here: http://docs.telerik.com/devtools/winforms/scheduler/end-user-functionality/editing-appointments-

    As to the multiple current time indicators, RadScheduler doesn't support it out of the box. However, RadScheduler provides a convenient API and you can override the default rendering of the current time indicator and add your custom rendering logic for other locations. Here is the default code for rendering the current time indicator in the DayViewAppointmentsTable which is replaced with a SchedulerElementProvider:
    public class MyElementProvider : SchedulerElementProvider
    {
        RadScheduler scheduler;
     
        public MyElementProvider(RadScheduler scheduler) : base(scheduler)
        {
            this.scheduler = scheduler;
        }
     
        protected override T CreateElement<T>(SchedulerView view, object context)
        {
            if (typeof(T) == typeof(DayViewAppointmentsTable))
            {
                return new CustomDayViewAppointmentsTable(scheduler, view, (DayViewAppointmentsArea)context)as T;
            }
     
            return base.CreateElement<T>(view, context);
        }
    }
     
    public class CustomDayViewAppointmentsTable : DayViewAppointmentsTable
    {
        DayViewAppointmentsArea area;
     
        public CustomDayViewAppointmentsTable(RadScheduler scheduler, SchedulerView view, DayViewAppointmentsArea area) : base(scheduler, view, area)
        {
            this.area = area;
        }
     
        protected override void DrawCurrentTimeIndicator(DateTime currentDateTime, SchedulerCellElement todayCell, Telerik.WinControls.Paint.IGraphics graphics)
        {
            TimeSpan span = currentDateTime - currentDateTime.Date.AddHours(this.GetDayViewBase().RulerStartScale).AddMinutes(this.GetDayViewBase().RulerStartScaleMinutes);
            TimeSpan hours24 = TimeSpan.FromMinutes(this.GetDayViewBase().RulerEndScale * 60 + this.GetDayViewBase().RulerEndScaleMinutes) -
                               TimeSpan.FromMinutes(this.GetDayViewBase().RulerStartScale * 60 + this.GetDayViewBase().RulerStartScaleMinutes);
            float p = (float)(span.TotalMinutes / hours24.TotalMinutes);
     
            float y = this.area.Ruler.SeparatorsOffset * this.GetDayViewBase().GetRowsCount() * p;
            float x = todayCell.BoundingRectangle.X + todayCell.BorderLeftWidth;
            float width = todayCell.BoundingRectangle.Width + todayCell.BoundingRectangle.X - todayCell.BorderLeftWidth;
     
            y = (float)Math.Ceiling(y);
            graphics.DrawLine(this.area.Ruler.CurrentTimePointerColor, x, y, width, y, this.area.Ruler.CurrentTimePointerWidth);
        }
    }


    this.radScheduler1.ElementProvider = new MyElementProvider(this.radScheduler1);

    Feel free to use a similar approach and draw any additional elements you need. Alternatively, you can just use the CellFormatting event and display a bottom border for the desired cells considering the cell's time.

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

    Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top