Issues updating Kendo Scheduler data

2 posts, 0 answers
  1. Ben
    Ben avatar
    3 posts
    Member since:
    Mar 2017

    Posted 13 Sep 2017 Link to this post

    I am using a Kendo MVC Scheduler control with a TimeLine view and I am adding new events via an ajax call to my server to add to a table that holds scheduler events.  I need a way to refresh the scheduler or to add an event manually just so it will show up until the next refresh.  Is there an easy way to do that?  

    I tried the following but it doesn't call my read method:

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

    scheduler.resources[0].dataSource.read().then(
                    function () {
                        scheduler.view(scheduler.view().name);
                    });

    This is my client side code:

     <% Html.Kendo().Scheduler<WheresMyTool.Models.MeetingViewModel>()
        .Name("scheduler")
        .Date(new DateTime(2016, 12, 16))
        .StartTime(new DateTime(2016, 12, 16, 7, 00, 00))
        .MajorTick(60)
        .EventTemplate(
                    "<div class='#= eventStyle #' title='#= description #'>" +
                        "#= title #" +
                    "</div>")
        .Views(views =>
        {
            views.TimelineWeekView(timeline =>
            {
                timeline.EventHeight(25);
                timeline.ColumnWidth(1);
            });
            views.TimelineView(timeline => 
            {
                timeline.EventHeight(25);
                timeline.ColumnWidth(10);
            });
            views.TimelineMonthView(timeline =>
            {
                timeline.StartTime(new DateTime(2016, 12, 16, 00, 00, 00));
                timeline.EndTime(new DateTime(2016, 12, 16, 00, 00, 00));
                timeline.MajorTick(1440);
                timeline.MinorTickCount(1);
                timeline.EventHeight(25);
                timeline.ColumnWidth(10);
            });
        })
        .Editable(a => a.Confirmation(false))
        .Timezone("Etc/UTC")
        .Group(group => group.Resources("Attendees").Orientation(SchedulerGroupOrientation.Vertical))
        .Events(e =>
        {
            e.DataBound("schedulerDataBound");
            e.Edit("scheduler_edit");
            e.Add("scheduler_add");
        })
        .Resources(resource =>
        {

            resource.Add(m => m.Attendees)
                .Title("Attendees")
                .Name("Attendees")
                .Multiple(true)
                .DataTextField("Text")
                .DataValueField("Value")
                .DataColorField("Color")
                .BindTo(Model.resourceList);
        })
        .DataSource(d => d
            .AutoSync(true)
            .Read("SchedulerRead", "Scheduler")
            .Create("SchedulerCreate", "Scheduler")
        ).Render();
            %>

  2. Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    747 posts

    Posted 15 Sep 2017 Link to this post

    Hello Ben,

    I am not quite sure if I understand well the described scenario. Do you create a new Event in the Scheduler using the UI and the Add / Edit event pop-up form? If this is the case, apart from properly configuring the Create endpoint, you will also have to specify the Model.Id field from the SchedulerEvent view model:
    .DataSource(d => d
        .AutoSync(true)
        .Read("SchedulerRead", "Scheduler")
        .Create("SchedulerCreate", "Scheduler")
        .Model(m => m.Id("ID"))
    )

    Attached you will find a simple MVC project, implementing the above suggestion. May I ask you to use that sample as a starting point and explain a bit in details, what would you like to achieve?

    Regards,
    Veselin Tsvetanov
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top