Вопрос

I want to use Kendo MVC Wrapper for Parameter Map in my scheduler for kendo scheduler,

Currently I am using ParameterMap into Javascript function after document load completes as:

  $(document).ready(function () {

            $("#scheduler").data("kendoScheduler").dataSource.transport.parameterMap = function (options, operation) {
            var scheduler = $("#scheduler").data("kendoScheduler");
            if (operation === "read") {
                var result = {
                    start: scheduler.view().startDate().toISOString(),
                    end: scheduler.view().endDate().toISOString()
                }
                return result;
            }
        };

    })

But I want to use MVC Wrapper for Kendo Scheduler. Is it possible to do?

Это было полезно?

Решение

MVC Wrapper does not allow you to specify a parameterMap, it uses a predefined parameterMap which should not be changed. Instead consider sending extra parameters through the Data function of the Read configuration.

Другие советы

You can try this way:

parameterMap: function (options, operation, data) {
                  if (operation === "read") {
                      return  models: kendo.stringify(options.models);
                 }
             }

On the controller side

public virtual JsonResult SomeMethod([DataSourceRequest] DataSourceRequest request)
{
    /*
        Your logic goes here
    */
    return Json(returnValue.ToDataSourceResult(request));
}

Exemplifying the answer given above:

 Read(read => read.Action("Read", "Calendar").Data("getAdditionalData"))

And the Javascript function for what you want to achieve:

function getAdditionalData() {
    var scheduler = $("#scheduler").data("kendoScheduler");

    var timezone = scheduler.options.timezone;
    var startDate = kendo.timezone.convert(scheduler.view().startDate(), timezone, "Etc/UTC");
    var endDate = kendo.timezone.convert(scheduler.view().endDate(), timezone, "Etc/UTC");

    var result = {
        Start: new Date(startDate.getTime() - (startDate.getTimezoneOffset() * kendo.date.MS_PER_MINUTE)),
        End: new Date(endDate.getTime() - (endDate.getTimezoneOffset() * kendo.date.MS_PER_MINUTE) + kendo.date.MS_PER_DAY)
    }

    return result;
}
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top