0

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#?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Stephen Sugumar
  • 545
  • 3
  • 9
  • 35

2 Answers2

1

Please see this part of the documentation for an explanation on adding custom y-axis values from the database:

http://docs.dhtmlx.com/scheduler/timeline_view.html#datafortheyaxissectionsfromtheserver

Hope it is what you are looking for and let me know if you need any further help.

Ray Meyer
  • 143
  • 12
  • Hello, Thank you for the reply. Unfortunately, I'm working with a Asp.Net application and prefer not to use php If there is another option which incorporates C#, may you please share. If there is no other option, how would I incorporate the php code into my asp.net project? Thanks! – Stephen Sugumar Jun 25 '14 at 12:42
  • Hi, sorry I have actually never worked with asp.net so I hope the following helps; -Firstly, you would then instead be using the asp.net connector instead of the php one. Find its documentation [here](http://docs.dhtmlx.com/connector__net__index.html) -Next, on the client side you would still use the [serverList](http://docs.dhtmlx.com/scheduler/api__scheduler_serverlist.html) method. -Lastly, when setting up the dataProcessor create a list and assign it in similar manner, using the .net connector calls, as in my initial link. – Ray Meyer Jun 25 '14 at 14:52
  • Thank you! After snooping around the Dhtmlx website a bit more, and reviewing your initial link. I started to look into the .NET connectors. I'm still a little confused as to how everything ties together, but I'll continue to read the documentation and try things myself. Thanks! – Stephen Sugumar Jun 25 '14 at 15:00
  • I think [this](http://docs.dhtmlx.com/connector__net__scheduler-specific_howtos.html) is what we were looking for. – Ray Meyer Jun 25 '14 at 15:07
0

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!

Stephen Sugumar
  • 545
  • 3
  • 9
  • 35