Hi,
do you use dhtmlxScheduler for ASP.NET (http://scheduler-net.com/) or a regular JS scheduler with ASP.NET backend (https://docs.dhtmlx.com/scheduler/howtostart_guides.html) ?
For javascript scheduler, you can initialize the client side with server lists being empty:
scheduler.serverList("sections", []);
scheduler.createTimelineView({
name: "timeline",
x_unit: "minute",
x_date: "%H:%i",
x_step: 30,
x_size: 24,
x_start: 16,
x_length: 48,
y_unit: scheduler.serverList("sections"),
y_property: "section_id",
render:"bar"
});
Then, you either add your sections to the data in the format shown here - https://docs.dhtmlx.com/scheduler/data_formats.html#jsonwithcollections - and they will be applied automatically,
e.g. something like this:
https://docs.dhtmlx.com/scheduler/howtostart_dotnet.html#step4implementingwebapi
public IEnumerable<WebAPIEvent> Get()
{
return new {
data = db.SchedulerEvents
.ToList()
.Select(e => (WebAPIEvent)e),
collections = new {
sections = new List<object>{
new { value = 1, label = "James Smith"},
new { value = 2, label = "John Williams"}
}
}
};
}
or, you can load them via ajax request manually:
$.get("/url").then(function(data){
// data - [{key:1, label:"James Smith"}, ...]
scheduler.updateCollection("sections", data);
});
If you use Scheduler .NET, you can specify the server list for the timeline:
var timeline = new TimelineView("timeline", "section_id") {
RenderMode = TimelineView.RenderModes.Bar,
X_Unit = TimelineView.XScaleUnits.Day,
X_Size = 7,
X_Date = "%d"
};
timeline.ServerList = "sections";
And populate them in the data action:
public ContentResult Data(DateTime from, DateTime to)
{
var sections = _GetSectionsByDate(from, to);
var events = _GetEventsByDate(from, to);
var data = new SchedulerAjaxData(events);
data.ServerList.Add("sections", sections);
return (data);
}
You can find the sample in Scheduler.MVC5\Controllers\LoadTimelineSectionsController.cs
of the samples package.
Loading options via ajax would also work, as well as updating sections on the client using scheduler.updateCollection