Source code of the tutorial is available for download.
C#
@Html.DayPilotScheduler("dps", new DayPilotSchedulerConfig { BackendUrl = Url.Action("Backend", "Scheduler"), // ... HeaderColumns = new RowHeaderColumnCollection { new RowHeaderColumn("Day", 100), new RowHeaderColumn("Total", 100) } })
VB
@Html.DayPilotScheduler("dps", New DayPilotSchedulerConfig With { .BackendUrl = Url.Action("Backend", "Scheduler"), ' ... .HeaderColumns = New RowHeaderColumnCollection From { New RowHeaderColumn("Day", 100), New RowHeaderColumn("Total", 100) } })
The total hours are calculated in the MVC controller:
C#
class Dps : DayPilotScheduler { TimesheetDataContext dc = new TimesheetDataContext(); // ... protected override void OnBeforeResHeaderRender(BeforeResHeaderRenderArgs e) { if (e.Columns.Count > 0) { var start = e.Date; var end = start.AddDays(1); var employee = SelectedEmployee(); TimeSpan total = TimeSpan.Zero; (from tr in dc.TimesheetRecords where tr.EmployeeId == employee && !((tr.TimesheetOut <= start) || (tr.TimesheetIn >= end)) select tr).ToList().ForEach(tr => total = total.Add(tr.TimesheetOut - tr.TimesheetIn)); e.Columns[0].Html = total.ToString("hh\\:mm"); } } }
VB
Private Class Dps Inherits DayPilotScheduler Private dc As New TimesheetDataContext() ' ... Protected Overrides Sub OnBeforeResHeaderRender(ByVal e As BeforeResHeaderRenderArgs) If e.Columns.Count > 0 Then Dim start = e.Date Dim [end] = start.AddDays(1) Dim employee = SelectedEmployee() Dim total As TimeSpan = TimeSpan.Zero Dim records = (From tr In dc.TimesheetRecords _ Where tr.EmployeeId = employee AndAlso Not ((tr.TimesheetOut <= start) OrElse (tr.TimesheetIn >= [end])) _ Select tr) records.ToList().ForEach(Sub(tr) total = total.Add(tr.TimesheetOut - tr.TimesheetIn)) e.Columns(0).Html = total.ToString("hh\:mm") End If End Sub End Class