Multiple Schedulers on the Page

Hello,

I can’t find how to integrate two schedulers using MVC ?

Multiple Schedulers

On the link above the explanation is for Webforms but there is no example for MVC, or maybe I missed something.

Sample:

    public ActionResult Index()
    {
       var  sched = new DHXScheduler(this);
        sched.Skin = DHXScheduler.Skins.Material;
        sched.LoadData = true;
        sched.EnableDataprocessor = true;
        sched.InitialDate = DateTime.Now;

        return View(sched);
    }

Best regards,
Thanks for your help !

Can someone help me, please ?

Hi,
you can create multiple instances by providing a second parameter into the DHXScheduler constructor:

 var firstCalendar = new DHXScheduler(this, "firstScheduler");
 var secondCalendar = new DHXScheduler(this, "secondScheduler");

this string value will be used as a name of a global instance of the scheduler, which is available from javascript.
Please note that this functionality is only available width Enterprise/Ultimate licenses, you’ll get Not Implemented exception if you use anything else.
It’s also should work with evaluation licenses as well, but I’m noticing that in the current build it doesn’t. We’ll check it and will update the scheduler package in the nearest couple of days.

Thanks for your answer, but I have understand how to initialize a second scheduler. However, can you explain me how to return those variables to the view.

I have already try to create a Model with those variables and return the model but it didn’t work.

 public ActionResult Index()
{
    var firstCalendar = new DHXScheduler(this, "firstScheduler");
    var secondCalendar = new DHXScheduler(this, "secondScheduler");

   //How to return those Calendars
    return View();
}

front-end

<div style="height:800px;width:144%">
    @Html.Raw(Model.Render())
</div>

Best regards.

Hi!

You’ll need to define a new class for the view model, since View accepts only one argument.
I mean something like the following:

model:

using DHTMLX.Scheduler;

public class CalendarPageModel
{
    public DHXScheduler FirstScheduler { get; set; }
    public DHXScheduler SecondScheduler { get; set; }
}

controller:

public ActionResult Index()
{
    var firstCalendar = new DHXScheduler(this, "firstScheduler");
    var secondCalendar = new DHXScheduler(this, "secondScheduler");

   //How to return those Calendars
    return View(new CalendarPageModel{
        FirstScheduler = firstCalendar,
        SecondScheduler = secondCalendar
    });
}

view:

<div style="height:800px;width:144%">
    @Html.Raw(Model.FirstScheduler.Render())
</div>
<div style="height:800px;width:144%">
    @Html.Raw(Model.SecondScheduler.Render())
</div>

Thanks a lot for your help, it finally works !

It’s this synthax that I missed

@Html.Raw(Model.FirstScheduler.Render())

Best regards.