Cannot get events to load from MSSQL DB

I’m trying to get the dhtmlxScheduler to work and I’ve followed every instruction there is, but I’ve hit a wall so to speak.

Following the instructions, i’ve created a DB with the required fields in MSSQL Server 2012, been able to initialize the scheduler and also been able to get XML-output from the DB with events, yet the scheduler does not seem to be recognizing them as it will not load those events into the scheduler.

Using MVC4 with the Razor engine, my code is as following

Controller:

[code]using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using TimeSaverManager.Models;

namespace Manager.Controllers
{
public class CalendarController : Controller
{
//
// GET: /Calendar/

    public ActionResult Index()
    {
        return View();
    }

    public ActionResult Data()
    {
        Response.ContentType = "text/xml";
        TimesheetDataContext data = new TimesheetDataContext(); //Gets the events from the DB
        return View(data.Timesheets);
    }

}

}
[/code]

Data.cshtml:

[code]@inherits System.Web.Mvc.WebViewPage
@{
Layout = null;
}

@foreach (var myevent in Model) { } [/code]

Index.cshtml:

[code]@inherits System.Web.Mvc.WebViewPage
@{
Layout = null;
}

Index
<style type="text/css">
    html, body {
        height:100%;
        padding:0px;
        margin:0px;
}
</style>

<script type="text/javascript">
    function init() {
        scheduler.config.xml_date = "%Y/%m/%d %H:%i"; // format of dates in XML
        scheduler.init("scheduler_here", new Date(), "month");
        scheduler.load("/Calendar/Data"); //path to the newly created action
    }
</script>
[/code]

The XML-output:

[code]

<start_date>

</start_date>
<end_date>

</end_date>

[/code]

So my question is: What is stopping it from loading the events? Any help towards the solution of this problem is greatly appreciated, I’ve been stuck with this problem for 2 days now and I just cannot figure it out.

a) you are using yyyy/MM/dd HH:mm in the Data.cshtml, but xml contains 2013-11-07 16:00 - format with different separators ( it must not cause problems for data loading, but still strange )

b) Be sure that Data.cshtml served with text/xml content type

I’ve edited the data format but as you said, it’s not what’s causing the problem.

The controller is already setting the output to “text/xml” using the following line:

Response.ContentType = "text/xml";

The XML-output is generated by me going to the exact adress for just the Data.cshtml, so by that I’m 100% sure that’s being generated right. For no apparent reason, events are just not being loaded into the scheduler

Some pictures to show that the output is XML:

Using Google Chrome:

Looking at the source of the above page:

Well, finally the issue was resolved. I’m not sure if whether i’m just that blind or if the documentations truly weren’t that good at explaining this key factor, but anywho:

The solution:

scheduler.load("/Calendar/Data","xml");

instead of

scheduler.load("/Calendar/Data");

Adding the “xml”-parameter at the end fixed it, it should be specified somewhere that even thought you’re not loading from a saved/“static” xml-file (as one might think when reading so many guides and topics), you are infact creating a dynamical xml-file and therefor the additional parameter is still required for the same intents and purposes.

Your assistance is greatly appreciated Stanislav, thank you very much!

That is quite strange, as default loading type for the scheduler is XML. So when you are using the load command without second parameter it must process response as XML. We will investigate the problem, meanwhile you can use the above solution, as it doesn’t have any drawbacks.

Precisely :slight_smile: