Skip to main content

GanttSettings.WorkTimeRules Property

Provides access to the work time rules collection.

Namespace: DevExpress.Web.Mvc

Assembly: DevExpress.Web.Mvc5.v24.1.dll

NuGet Package: DevExpress.Web.Mvc5

Declaration

public WorkTimeRulesCollection WorkTimeRules { get; }

Property Value

Type Description
WorkTimeRulesCollection

A collection of work time rules.

Remarks

The Gantt allows you to specify work days, work hours, and holidays.

Run Demo: MVCxGantt - Work Time Schedule

The Gantt stores its work time rules in the WorkTimeRules collection. The following work time rules are available:

  • Daily Rule (DailyRule)

    var dailyRule = new DevExpress.Web.ASPxGantt.DailyRule();
    dailyRule.WorkTimeRanges.Add(new DevExpress.Web.ASPxGantt.WorkTimeRange() { Start = new TimeSpan(8, 0, 0), End = new TimeSpan(11, 55, 00) });
    dailyRule.WorkTimeRanges.Add(new DevExpress.Web.ASPxGantt.WorkTimeRange() { Start = new TimeSpan(13, 0, 0), End = new TimeSpan(17, 00, 00) });
    settings.WorkTimeRules.Add(dailyRule);
    
  • Weekly Rule (WeeklyRule)

    var weeklyRule = new DevExpress.Web.ASPxGantt.WeeklyRule() { IsWorkDay = false };
    weeklyRule.Recurrence.DayOfWeek = DayOfWeek.Saturday;
    settings.WorkTimeRules.Add(weeklyRule);
    
    weeklyRule = new DevExpress.Web.ASPxGantt.WeeklyRule() { IsWorkDay = false };
    weeklyRule.Recurrence.DayOfWeek = DayOfWeek.Sunday;
    settings.WorkTimeRules.Add(weeklyRule);
    
  • Monthly Rule (MonthlyRule)

    var monthlyRule = new DevExpress.Web.ASPxGantt.MonthlyRule();
    monthlyRule1.WorkTimeRanges.AddRange(new List<WorkTimeRange>
    {
        new WorkTimeRange(){ Start=new TimeSpan(08,00,00), End=new TimeSpan(16,00,00)}
    });
    monthlyRule1.Recurrence.DayOfWeek = DayOfWeek.Thursday;
    monthlyRule1.Recurrence.DayOfWeekOccurrence = DayOfWeekMonthlyOccurrence.Second;
    monthlyRule1.Recurrence.CalculateByDayOfWeek = true;
    settings.WorkTimeRules.Add(monthlyRule);
    
  • Yearly Rule (YearlyRule)

    var yearlyRule = new DevExpress.Web.ASPxGantt.YearlyRule() { IsWorkDay = false };
    yearlyRule.Recurrence.Month = DevExpress.Web.ASPxGantt.Month.May;
    yearlyRule.Recurrence.Day = 27;
    settings.WorkTimeRules.Add(yearlyRule); 
    

The following table lists common rule settings:

Property

Description

IsWorkDay

Specifies whether a day is a work day.

Recurrence

Provides a rule’s recurrence settings. Each rule type provides an individual set of recurrence settings:

WorkTimeRanges

Provides settings for work time ranges.

See Also