Search code examples
asp.net-mvckendo-uikendo-scheduler

Kendo Scheduler Current Month in Controller (ASP.Net MVC)


I'm trying to get on the ServerSide the current month we are in the Scheduler, but i didn't find anything about it...

How can i send the current month/year to my mvc controller in the Read operation?

I need those informations to fetch new Data from database when we change month in scheduler!


Solution

  • Ok, here is the solution we found!

    In the DataSource.Read we added the .Data(javaScriptFunctionName)

    .DataSource(ds =>
    {
        ds.Model(model => model.Id(x => x.Id));
        ds.Read(read => read.Action("Lister", "Calendrier").Data("getAdditionalData"));
    })
    

    The javascript to get the data we are looking for

    function getAdditionalData() {
        var scheduler = $("#schedulerCalendrier").data("kendoScheduler");
    
        var result = {
            start: scheduler.view().startDate().toISOString(),
            end: scheduler.view().endDate().toISOString()
        }
    
        return result;
    }
    

    and in the controller we put those properties

    public ActionResult Lister([DataSourceRequest]DataSourceRequest request, DateTime start, DateTime end)