I'm working on a ASP.Net MVC (C# Razor Engine) application where I need to schedule workers to tasks within a given day.
I've decided to go with Dhtmlx Scheduler (free client side version, unfortunately), and need help in loading custom data for the y_unit.
var sections = [
{ key: 1, label: "James Smith" },
{ key: 2, label: "John Williams" },
{ key: 3, label: "David Miller" },
{ key: 4, label: "Linda Brown" }
];
scheduler.createTimelineView({
name: "timeline",
x_unit: "minute",
x_step: 30,
x_start: 16,
x_date: "%H:%i",
x_size: 24,
x_length: 48,
y_unit: sections, // Need to change this
event_dy: 'full',
y_property: "section_id",
render: "bar"
This is what I currently have, instead of "sections" I want to put my my info there (Workers ID and Name) from a database I have linked in my controller.
How would I accomplish this? Thanks for all the help in advance!
Edit: My .Net connector for Scheduler
public override IdhtmlxConnector CreateConnector(HttpContext context)
{
var connector = new dhtmlxSchedulerConnector(
"Events",
"EventID",
dhtmlxDatabaseAdapterType.SqlServer2005,
ConfigurationManager.ConnectionStrings["ServiceOptimization"].ConnectionString,
"FromDate",
"ToDate",
"Subject as text, Details as details, Tags"
);
var optionsConnector = new dhtmlxOptionsConnector(
"W6ENGINEERS",
"ID",
connector.Request.Adapter,
"Name"
);
// get an error here, no such method for connector.
connector.AddOptionsConnector("type", optionsConnector);
return connector;
}
I'm not sure if I'm on the right track here, but I want to retrieve the Engineers name and ID. From here i believe i have to use serverList to make the connection.
but right now I am getting an error with .AddOptionsConnector. Also how would i add the OptionsConnector to the serverList?
In php they use: $scheduler->set_options("sections", $list); what would be the equivalent in C#?
I figured it out in the end!
I had created an list form my controller, and sent it to the Javascript through JSON.
controller:
var engList = new List<object>();
foreach (var engineer in viewModel.engineers)
{
engList.Add(new { key = engineer.ID, label = engineer.Name });
}
ViewBag.engineers = engList;
Scheudler Script:
var engineers = @Html.Raw(Json.Encode(ViewBag.engineers))
[...]
y_unit: engineers,
Thanks Skapie19 for the help!