Domanda

I am having issue of using Kendo UI scheduler,

When I schedule task ,

Kendo UI start and end date not returning on server side.

Start and end date always return default date.

Here a Razor Code :

@model IEnumerable<Web.Models.PlantColor>
@{
   ViewBag.Title = "Schedule View";
}

<h2>Schedule View</h2>


@(Html.Kendo().Scheduler<WorkScheduler.Web.Models.KendoSchedular>()
.Name("scheduler")

.Date(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day))
.StartTime(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 08, 00, 00))
.Height(600)
.Views(views =>
{

    views.DayView();
    views.WorkWeekView();
    views.WeekView();
    views.MonthView();
    views.AgendaView();
})

 .Resources(resource =>
{
    resource.Add(m => m.PlantId)
        .Title("Owner")
        .DataTextField("Text")
        .DataValueField("Value")
        .DataColorField("Color")
        .BindTo(Model);
})
.DataSource(d => d
    .Model(m =>
    {
        m.Id(f => f.id);
    })
    .Read("ReadSchedule", "ScheduleView")
    .Create("CreateSchedule", "ScheduleView")
    .Destroy("Destroy", "ScheduleView")
    .Update("Update", "ScheduleView")

)

)

È stato utile?

Soluzione

Make sure that you have the start and end fields defined in your Model that you are posting back (and model inherits from ISchedulerEvent):

 public class CalendarAppointmentViewModel : ISchedulerEvent
{
    public int Id { get; set; }

    public string Title { get; set; }
    public string Description { get; set; }
    public string Recurrence { get; set; }
    public string StartTimezone { get; set; }
    public string EndTimezone { get; set; }

    private DateTime start;
    public DateTime Start
    {
        get
        {
            return start;
        }
        set
        {
            start = value.ToUniversalTime();
        }
    }


    private DateTime end;
    public DateTime End
    {
        get
        {
            return end;
        }
        set
        {
            end = value.ToUniversalTime();
        }
    }

    public string RecurrenceRule { get; set; }
    public int? RecurrenceID { get; set; }
    public string RecurrenceException { get; set; }
    public bool IsAllDay { get; set; }

Altri suggerimenti

I can see this question is already accepted as best answer. Perhaps following might be helpful also for someone struggling to return Start/End dates from Editor of Kendo Scheduler.

I had same issue, and followed the solutions provided here, still no success. In my case defining the culture and creating a Model inherited from "ISchedulerEvent" was still returning default date to the server side in Create & Update events handler methods of the Controller.

For me problem was a missing .js file. kendo.timezones.min.js

So for anyone who is in the same shoes like me, kindly look at your Scripts folder in the project, and if that .js file is missing.

And please follow these steps in setting up the project.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top