Scheduler edit picking wrong day

0 Answers 53 Views
Scheduler
Kevin
Top achievements
Rank 2
Iron
Iron
Iron
Kevin asked on 11 Oct 2022, 02:00 PM

I have a scheduler that I've created in MVC and reset the data with via javascript

@(Html.Kendo().Scheduler<MyProject.Models.Schedule.Kendo.ISchedulerData>()
                .Name("edit-scheduler")
                .Date((DateTime)MyProject.Helper.Date.StringToDateTime(ViewBag.EventHeader.StartDate.ToString("MM/dd/yyyy")))
                .StartTime((DateTime)MyProject.Helper.Date.StringToDateTime(ViewBag.EventHeader.StartDate.ToString("MM/dd/yyyy")))
                .EndTime((DateTime)MyProject.Helper.Date.StringToDateTime(ViewBag.EventHeader.EndDate.ToString("MM/dd/yyyy")))
                .EventTemplate(
                    "#=eventTemplate(SupplierNumber,SupplierName, MeridiemDeliveryTime, OrdersReadable, OrderGroup1,OrderGroup2,OrderGroup3,OrderGroup4,OrderGroup5,OrderGroup6,OrderGroup7,OrderGroup8,IsEvent,Color)#"
                )
                .Views(views =>
                {
                    views.MonthView(month =>
                    {
                        month.Selected(true);
                        month.EventsPerDay(20);
                        month.AdaptiveSlotHeight(true);
                        month.EventHeight("auto");
                        month.EventSpacing(5);
                    });
                })
                .Timezone("EST")
                .Editable(true)
                .Editable(editable => editable.Confirmation(false))
                .Resources(resource =>
                {
                    resource.Add(m => m.ActiveSupplierNumber)
                    .Title("Owner")
                    .DataTextField("Text")
                    .DataValueField("Value")
                    .DataColorField("Color")
                    .BindTo(ViewBag.Colors);
                })
                .DataSource(d => d
                    .Read(read => read.Action("GetStoreSchedule", "ScheduleData").Data("scheduler_Data"))
                )
                .Events(e =>
                {
                    e.Remove("scheduler_Remove");
                    e.Edit("scheduler_Edit");
                    e.MoveEnd("scheduler_MoveEnd");
                    e.MoveStart("scheduler_MoveStart");
                    e.ResizeStart("scheduler_ResizeEnd");
                    e.DataBound("scheduler_DataBound");
                })
            )

With my scheduler_Data() like this

var _eventHeaderId = 1;
var _stageId = '0B579CE9-2CB8-4ACF-9EC1-892378632823'; // This changes frequently

function scheduler_Data() {
    var store = $("#edit-store-dropdown").data("kendoDropDownList").value();
    var supplier = $("#edit-supplier-dropdown").data("kendoDropDownList").value();
    var sdata = {};
    sdata["eventHeaderId"] = parseInt(_eventHeaderId);
    sdata["stageId"] = _stageId;
    sdata["store"] = parseInt(store);
    sdata["supplier"] = parseInt(supplier);
    return sdata;
}

The first time the page loads, there is no store, the controller does not return data, the scheduler remains blank (exactly as expected)

As I do other things on the page, the store dropdown has a value, and I run some code that updates the _stageId and does some database work, then it refreshes the scheduler, which basically is just me doing this.

    scheduler.dataSource.read();
    scheduler.refresh();

This all works perfectly.  My scheduler populates from the database.  However, if I click into a day (triggering scheduler_Edit) - it creates the event offset by one day, if there is at least 3 other events in the previous day.  So if Sunday has 3 events, and I click Monday, it adds the event to Sunday.  If I have 2 events on Sunday and click Monday, it adds the event to Monday

So I put some code into scheduler_Edit()

console.log("You clicked " + e.event.start);

If I cancel my custom edit window, and click in the same place on scheduler it populates exactly where it should

And the console bears that out

And from that point, it adds to the correct day until I redo the refresh scheduler code

scheduler.dataSource.read();
scheduler.refresh();

Then it happens again?

Am I doing something weirdly wrong?

Yanislav
Telerik team
commented on 14 Oct 2022, 10:29 AM

Hello Kevin,

I've reviewed the code snippets you've shared, but I was not able to spot any possible reason why such behavior might occur. With that said, what I can recommend you is to check the data received on the server and what the response from the server is. I suppose that somewhere in the process of communication, the date may be converted due to a different culture, and that is the reason for the discrepancy.

Please make the needed checks at your end and let me know if you still face the issue. In case further assistance is needed, may I ask you to try preparing an example in which the problem is reproducible so I can investigate the issue and try to find a possible solution?

No answers yet. Maybe you can help?

Tags
Scheduler
Asked by
Kevin
Top achievements
Rank 2
Iron
Iron
Iron
Share this question
or