Hiding Time Units in the X-Axis of a View

Hiding Time Units in the X-Axis of a View

Starting from version 3.0, you got the possibility to hide time units in the horizontal scale of a view. For example, to hide weekends and display only working days.

Technique

Generally, to hide a time unit in the scale of a view (an hour in the Timeline view, a day in the Month, Week view etc.), use one of two methods:

  • SchedulerView.Scale.Ignore(params int[] units) - hides specific units
    • units - an array of units to hide (specified in the view's X-Axis units, e.g. a day in the Week view, an hour in the Timeline view).
  • SchedulerView.Scale.IgnoreRange(int from, int to) - hides a range of units
    • from - the start unit of the range to hide (specified in the view's X-Axis units)
    • to - the end unit of the range to hide (specified in the view's X-Axis units)

For example, to hide non-working hours from the Timeline view (18.00 - 08.00 or 6 PM - 8 AM) and weekends from the Week view, use the code as in:

var sched = new DHXScheduler(this);
...
var timeline = new TimelineView("timeline", "room_id");
timeline.X_Unit = TimelineView.XScaleUnits.Hour;
timeline.X_Size = 48;
 
timeline.Scale.IgnoreRange(19, 23);
timeline.Scale.IgnoreRange(0, 7);
sched.Views.Add(timeline);            
 
var month = sched.Views[0];
month.Scale.Ignore((int)DayOfWeek.Saturday, (int)DayOfWeek.Sunday);

hide time units

Displaying a marker at the place of hidden scale units

To highlight the place where you hide scale units, you may use the DHXMarkTime class. For example, in the Timeline view we preserve hours from 10:00 till 18:00 and hide the remaining ones. To highlight the place of omitted hours we will use a marker of 40-minute duration: 20 minute in each of bordering cells.

.day_split{
      background-color: #77ff77;
      opacity: 0.25;
}
sched.TimeSpans.Add(new DHXMarkTime
{
      FullWeek = true,
      Zones = new List<Zone>{ new Zone( 9*60 + 30, 20*60 + 30)},
      CssClass = "day_split",
      InvertZones = true
});

hide marker


comments powered by Disqus