@model DevExtreme.MVC.Demos.ViewModels.SchedulerResourcesViewModel
@{
var resourcesList = new[] { "Assignee", "Room", "Priority" };
}
@(Html.DevExtreme().Scheduler()
.ID("scheduler")
.DataSource(Model.Appointments)
.TimeZone("America/Los_Angeles")
.Views(new[] { SchedulerViewType.WorkWeek })
.CurrentView(SchedulerViewType.WorkWeek)
.CurrentDate(new DateTime(2021, 4, 27))
.StartDayHour(9)
.EndDayHour(19)
.Resources(res => {
res.Add()
.FieldExpr("RoomId")
.ValueExpr("Id")
.ColorExpr("Color")
.Label("Room")
.DisplayExpr("Text")
.DataSource(Model.Rooms);
res.Add()
.FieldExpr("PriorityId")
.ValueExpr("Id")
.ColorExpr("Color")
.Label("Priority")
.DisplayExpr("Text")
.DataSource(Model.Priorities);
res.Add()
.FieldExpr("AssigneeId")
.ValueExpr("Id")
.ColorExpr("Color")
.Label("Assignee")
.DisplayExpr("Text")
.AllowMultiple(true)
.DataSource(Model.Assignees);
})
.Height(600)
.TextExpr("Text")
.StartDateExpr("StartDate")
.EndDateExpr("EndDate")
.AllDayExpr("AllDay")
.RecurrenceRuleExpr("RecurrenceRule")
.RecurrenceExceptionExpr("RecurrenceException")
)
<div class="options">
<div class="caption">Use colors of:</div>
<div class="option">
@(Html.DevExtreme().RadioGroup()
.Items(resourcesList)
.Value(resourcesList[0])
.Layout(Orientation.Horizontal)
.OnValueChanged("resources_valueChanged")
)
</div>
</div>
<script>
function resources_valueChanged(e) {
var scheduler = $("#scheduler").dxScheduler("instance"),
resources = scheduler.option("resources");
for(var i = 0; i < resources.length; i++) {
resources[i].useColorAsDefault = resources[i].label == e.value;
}
scheduler.repaint();
}
</script>
using DevExtreme.MVC.Demos.Models.SampleData;
using DevExtreme.MVC.Demos.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
namespace DevExtreme.MVC.Demos.Controllers {
public class SchedulerController : Controller {
public ActionResult Resources() {
return View(new SchedulerResourcesViewModel {
Appointments = SampleData.AppointmentsWithResources,
Assignees = SampleData.AssigneeResources,
Rooms = SampleData.RoomResources,
Priorities = SampleData.PriorityResources
});
}
}
}
using System;
using System.Collections.Generic;
namespace DevExtreme.MVC.Demos.Models.SampleData {
public partial class SampleData {
public static readonly IEnumerable<AppointmentWithResources> AppointmentsWithResources = new[] {
new AppointmentWithResources {
AppointmentId = 1,
Text = "Website Re-Design Plan",
AssigneeId = new int[] { 4 }, RoomId = 1, PriorityId = 2,
StartDate = "2021-04-26T16:30:00.000Z",
EndDate = "2021-04-26T18:30:00.000Z"
},
new AppointmentWithResources {
AppointmentId = 2,
Text = "Book Flights to San Fran for Sales Trip",
AssigneeId = new int[] { 2 }, RoomId = 2, PriorityId = 1,
StartDate = "2021-04-26T19:00:00.000Z",
EndDate = "2021-04-26T20:00:00.000Z",
AllDay = true
},
new AppointmentWithResources {
AppointmentId = 3,
Text = "Install New Router in Dev Room",
AssigneeId = new int[] { 1 }, RoomId = 1, PriorityId = 2,
StartDate = "2021-04-26T21:30:00.000Z",
EndDate = "2021-04-26T22:30:00.000Z"
},
new AppointmentWithResources {
AppointmentId = 4,
Text = "Approve Personal Computer Upgrade Plan",
AssigneeId = new int[] { 3 }, RoomId = 2, PriorityId = 2,
StartDate = "2021-04-27T17:00:00.000Z",
EndDate = "2021-04-27T18:00:00.000Z"
},
new AppointmentWithResources {
AppointmentId = 5,
Text = "Final Budget Review",
AssigneeId = new int[] { 1 }, RoomId = 1, PriorityId = 1,
StartDate = "2021-04-27T19:00:00.000Z",
EndDate = "2021-04-27T20:35:00.000Z"
},
new AppointmentWithResources {
AppointmentId = 6,
Text = "New Brochures",
AssigneeId = new int[] { 4 }, RoomId = 3, PriorityId = 2,
StartDate = "2021-04-27T21:30:00.000Z",
EndDate = "2021-04-27T22:45:00.000Z"
},
new AppointmentWithResources {
AppointmentId = 7,
Text = "Install New Database",
AssigneeId = new int[] { 2 }, RoomId = 3, PriorityId = 1,
StartDate = "2021-04-28T16:45:00.000Z",
EndDate = "2021-04-28T18:15:00.000Z"
},
new AppointmentWithResources {
AppointmentId = 8,
Text = "Approve New Online Marketing Strategy",
AssigneeId = new int[] { 4 }, RoomId = 2, PriorityId = 1,
StartDate = "2021-04-28T19:00:00.000Z",
EndDate = "2021-04-28T21:00:00.000Z"
},
new AppointmentWithResources {
AppointmentId = 9,
Text = "Upgrade Personal Computers",
AssigneeId = new int[] { 2 }, RoomId = 2, PriorityId = 2,
StartDate = "2021-04-28T22:15:00.000Z",
EndDate = "2021-04-28T23:30:00.000Z"
},
new AppointmentWithResources {
AppointmentId = 10,
Text = "Customer Workshop",
AssigneeId = new int[] { 3 }, RoomId = 3, PriorityId = 1,
StartDate = "2021-04-29T18:00:00.000Z",
EndDate = "2021-04-29T19:00:00.000Z",
AllDay = true
},
new AppointmentWithResources {
AppointmentId = 11,
Text = "Prepare 2021 Marketing Plan",
AssigneeId = new int[] { 1 }, RoomId = 1, PriorityId = 2,
StartDate = "2021-04-29T18:00:00.000Z",
EndDate = "2021-04-29T20:30:00.000Z"
},
new AppointmentWithResources {
AppointmentId = 12,
Text = "Brochure Design Review",
AssigneeId = new int[] { 4 }, RoomId = 1, PriorityId = 1,
StartDate = "2021-04-29T21:00:00.000Z",
EndDate = "2021-04-29T22:30:00.000Z"
},
new AppointmentWithResources {
AppointmentId = 13,
Text = "Create Icons for Website",
AssigneeId = new int[] { 3 }, RoomId = 3, PriorityId = 1,
StartDate = "2021-04-30T17:00:00.000Z",
EndDate = "2021-04-30T18:30:00.000Z"
},
new AppointmentWithResources {
AppointmentId = 14,
Text = "Upgrade Server Hardware",
AssigneeId = new int[] { 4 }, RoomId = 2, PriorityId = 2,
StartDate = "2021-04-30T21:30:00.000Z",
EndDate = "2021-04-30T23:00:00.000Z"
},
new AppointmentWithResources {
AppointmentId = 15,
Text = "Submit New Website Design",
AssigneeId = new int[] { 1 }, RoomId = 1, PriorityId = 2,
StartDate = "2021-04-30T23:30:00.000Z",
EndDate = "2021-05-01T01:00:00.000Z"
},
new AppointmentWithResources {
AppointmentId = 16,
Text = "Launch New Website",
AssigneeId = new int[] { 2 }, RoomId = 3, PriorityId = 1,
StartDate = "2021-04-30T19:20:00.000Z",
EndDate = "2021-04-30T21:00:00.000Z"
}
};
}
}
using System;
using System.Collections.Generic;
using System.Linq;
namespace DevExtreme.MVC.Demos.Models {
public class AppointmentWithResources : Appointment {
public int[] AssigneeId { get; set; }
public int RoomId { get; set; }
public int PriorityId { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
namespace DevExtreme.MVC.Demos.Models {
public class AssigneeResource {
public int Id { get; set; }
public string Text { get; set; }
public string Color { get; set; }
}
}
using System;
using System.Collections.Generic;
namespace DevExtreme.MVC.Demos.Models.SampleData {
public partial class SampleData {
public static readonly IEnumerable<AssigneeResource> AssigneeResources = new[] {
new AssigneeResource {
Id = 1,
Text = "Samantha Bright",
Color = "#727bd2"
},
new AssigneeResource {
Id = 2,
Text = "John Heart",
Color = "#32c9ed"
},
new AssigneeResource {
Id = 3,
Text = "Todd Hoffman",
Color = "#2a7ee4"
},
new AssigneeResource {
Id = 4,
Text = "Sandra Johnson",
Color = "#7b49d3"
}
};
}
}
using System;
using System.Collections.Generic;
using System.Linq;
namespace DevExtreme.MVC.Demos.Models {
public class PriorityResource {
public int Id { get; set; }
public string Text { get; set; }
public string Color { get; set; }
}
}
using System;
using System.Collections.Generic;
namespace DevExtreme.MVC.Demos.Models.SampleData {
public partial class SampleData {
public static readonly IEnumerable<PriorityResource> PriorityResources = new[] {
new PriorityResource {
Id = 1,
Text = "High",
Color = "#cc5c53"
},
new PriorityResource {
Id = 2,
Text = "Low",
Color = "#ff9747"
}
};
}
}
using System;
using System.Collections.Generic;
using System.Linq;
namespace DevExtreme.MVC.Demos.Models {
public class RoomResource {
public int Id { get; set; }
public string Text { get; set; }
public string Color { get; set; }
}
}
using System;
using System.Collections.Generic;
namespace DevExtreme.MVC.Demos.Models.SampleData {
public partial class SampleData {
public static readonly IEnumerable<RoomResource> RoomResources = new[] {
new RoomResource {
Id = 1,
Text = "Room 1",
Color = "#00af2c"
},
new RoomResource {
Id = 2,
Text = "Room 2",
Color = "#56ca85"
},
new RoomResource {
Id = 3,
Text = "Room 3",
Color = "#8ecd3c"
}
};
}
}
.options {
padding: 20px;
background-color: rgba(191, 191, 191, 0.15);
margin-top: 20px;
}
.caption {
font-size: 18px;
font-weight: 500;
}
.option {
margin-top: 10px;
display: inline-block;
}