This is a migrated thread and some comments may be shown as answers.

Reload resources

2 Answers 567 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Chad
Top achievements
Rank 2
Chad asked on 23 Jul 2015, 08:56 PM

I have a number of options on the page for users to choose which resources they want to load on the scheduler. On scheduler load I make a call to load the resources that they have previously save but I'm not able to manipulate or change them once the page loads. Here is my configuration. 

@(Html.Kendo().Scheduler<Avianis.Models.Scheduler.AppointmentViewModel>()
        .Name("scheduler")
        .Date(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day))
        .AutoBind(false)
        .Snap(true)
        .Timezone("UTC")
        .Events(e =>
        {
            e.Navigate("scheduler_navigate");
        })
        .Views(views =>
        {   
            views.TimelineView(timeline => timeline
                .Title("Day")
                .MajorTick(60)
                .MinorTickCount(1)
                .EventHeight(77)
                .ColumnWidth(150)
                .EventTemplateId("more-template")
            );
            views.CustomView("TimelineViewFiveDays");
            views.CustomView("TimelineViewSevenDays");
            views.CustomView("TimelineViewThirtyDays");
            views.MonthView(timeline => timeline
                .EventHeight(40)
            );
        })
        .EventTemplateId("event-template")
        .Group(group => group.Resources("Aircraft").Orientation(SchedulerGroupOrientation.Vertical))
        .Resources(resource => resource.Add(m => m.ResourceID)
            .Name("Aircraft")
            .Title("Aircraft")            
            .DataValueField("id")
            .DataTextField("text")
            .DataSource(source => source.Read("GetResources", "Calendar"))
        )
        .Editable(editable => editable
            .Update(false)
            .Create(false)
            .Destroy(false)
            .Move(false)
            .Resize(false)
        )
        .DataSource(dataSource => dataSource            
            .SignalR()
            .Transport(tr => tr                
                .Promise("hubStart")
                .Hub("calendarHub")
                .Server(s => s
                    .Read("LoadAircraft"))
            )
            .Schema(schema => schema
                .Model(model =>
                {
                    model.Id(m => m.ID);
                    model.Field(m => m.ID).Editable(false);
                    model.Field("start", typeof(DateTime)).From("Start");
                    model.Field("end", typeof(DateTime)).From("End");
                    model.Field("title", typeof(string)).From("Subject");
                    model.Field("description", typeof(string)).From("Description");
                    model.Field("isAllDay", typeof(bool)).From("IsAllDay");
                    model.Field("ownerId", typeof(string)).From("OwnerId");
                })
            )
        )
    )

 

I've trying to change resources by saving the selected resources to the database then calling the line below. 

$('#scheduler').data().kendoScheduler.resources[0].dataSource.read();

 

And I've tried it this way as well. 

var scheduler = $("#scheduler").data("kendoScheduler");
scheduler.resources[0].dataSource.data(data);
scheduler.view(scheduler.view().name);

 

Both ways do not refresh the UI. Any help would be appreciated. 

 

 

2 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 28 Jul 2015, 06:54 AM
Hello Chad,

In general, the right way to reload/update the resources is to read the data source, like you mentioned in your message:
scheduler.resources[0].dataSource.read()

Here is a Dojo demo that shows how the resource is updated on every dataSource.read():


Would it be possible to modify the demo in order to demonstrate the erroneous behavior.

Regards, Georgi Krustev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Yoichi
Top achievements
Rank 1
answered on 18 Jul 2016, 09:27 AM

Hello,

Have you solved it ?

var scheduler = $("#scheduler").data("kendoScheduler");
scheduler.resources[0].dataSource.read().then(
    function () {
        scheduler.view(scheduler.view().name);
    });

Tags
Scheduler
Asked by
Chad
Top achievements
Rank 2
Answers by
Georgi Krustev
Telerik team
Yoichi
Top achievements
Rank 1
Share this question
or