The Units view is a view, where X-Axis is based on some property of events (not only on time).
To initialize the Units view and add it to the scheduler, use the code below:
public ActionResult Index() {
var sched = new DHXScheduler(this);
...
var unit = new UnitsView("unit1", "room_id");//initializes the view
sched.Views.Add(unit);//adds the view to the scheduler
return View(sched);
}
where
To configure the Units view, make use of the properties below:
In general, to set values for the X-Axis, you should use the AddOptions() method.
The method can take 2 types of data:
unit.AddOption( new Unit("1", "Room 1"));
var rooms = new List<object>(){
new { key = "1", label = "Room 1"},
new { key = "2", label = "Room 2"},
new { key = "3", label = "Room 3"}
};
unit.AddOptions(rooms);
Note, to be correctly processed data items must have 2 mandatory properties:
A single event can be assigned to several sections of the Timeline or Units view.
To enable multisection events:
var scheduler = new DHXScheduler(this);
scheduler.Extensions.Add(SchedulerExtensions.Extension.Multisection);
var units = new UnitsView("units", "y_property");
var options = new object[]{
new {key = 1, label = "Section #1" },
new {key = 2, label = "Section #2" },
new {key = 3, label = "Section #3" },
new {key = 4, label = "Section #4" }
};
units.AddOptions(options);
scheduler.Views.Add(units);
Optional multiselect configuration:
scheduler.Lightbox.Add(new LightboxText("text", "Title"));
var multiselect = new LightboxMultiselect("y_property", "Sections");
multiselect.AddOptions(options);
scheduler.Lightbox.Add(multiselect);
scheduler.Lightbox.Add(new LightboxMiniCalendar("time", "Time"));
After that, the related property of an event can contain several sections (by default, separated with comma) and the event will be displayed in all specified properties:
public ContentResult Data()
{
var evs = new List<object>{
new { text = "First", start_date = new DateTime(2014, 8, 1), end_date = new DateTime(2014, 8, 4), y_property = "1,3"},
new { text = "Second", start_date = new DateTime(2014, 8, 3), end_date = new DateTime(2014, 8, 5), y_property = "2,4"},
new { text = "Third", start_date = new DateTime(2014, 8, 2), end_date =new DateTime(2014, 8, 8), y_property = "1"},
new { text = "Fourth", start_date = new DateTime(2014, 8, 4), end_date = new DateTime(2014, 8, 5), y_property = "3"}
};
Â
return Content(new SchedulerAjaxData(evs).Render());
}
Scheduler supports loading Timeline and Units options with the data response.
In order to do so, you need to specify a 'ServerList' property of the Units view, the name is arbitrary:
var unit = new UnitsView("unit", "section_id");
scheduler.Views.Add(unit);
unit.ServerList = "sections";
During data loading you can add a list of timeline options to the SchedulerAjaxData object (note that the name of the list must be the same in both places, 'sections' in this example)
var data = new SchedulerAjaxData(events);
Â
data.ServerList.Add("sections", new List<object>{
new { key = "1", label = "Section 1" },
new { key = "2", label = "Section 2" },
new { key = "1", label = "Section 3" }
});
After that sections will be refreshed on the client automatically. See more details.
A number of displayed days can be specified in the Days property of the UnitsView object:
var unit = new UnitsView("unit", "section_id");
unit.Days = 7;//full week
scheduler.Views.Add(unit);
A view can contain any number of days. Note, that the Step and Scroll properties can't be used when UnitsView shows several days.