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

Adding resources to scheduler in external javascript event handlers

4 Answers 136 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Mohomed
Top achievements
Rank 1
Mohomed asked on 12 Oct 2017, 10:22 AM
var scheduler = $("#scheduler").data("kendoScheduler");
                    var filterR = {
                        logic: "or",
                        filters: [
                          { field: "workCent", operator: "eq", value: 'F1' }
                        ]
                    };
                    scheduler.dataSource.filter(filterR);
                    scheduler.view("month");

Hi, I've come across many examples where filters are added to the scheduler in javascript functions outside the definition of the scheduler as shown above. My issue is how to add resources like this in an external javascript function/event handler. I tried doing it as below and many other ways, but it doesn't seem to work. Does anyone know how ?

var ds = $("#scheduler").data("kendoScheduler");
var orderNoResource = {
                        field: "orderId",
                        title: "Order",
                        dataSource: [
                            { text: "Order 1", value: '200023', color: "#f8a398" },
                            { text: "Order 2", value: '200027', color: "#51a0ed" },
                            { text: "Order 3", value: '200033', color: "#56ca85" },
                            { text: "Order 3", value: '200025', color: "#45ca85" }
                        ]
                    };
 
ds.resources[0] = orderNoResource;
 
ds.view("month");

4 Answers, 1 is accepted

Sort by
0
Tyler
Top achievements
Rank 1
answered on 12 Oct 2017, 01:49 PM

You will have to destroy the widget and re-initialize with the new resource you want. 

Here is a forum post on the subject.

And here is a link to the destroy method of the scheduler that is linked in that forum post.

 

So whatever function is handling the event you want to change your resources with, destroy the scheduler, create a new one with the your new resources.

0
Mohomed
Top achievements
Rank 1
answered on 13 Oct 2017, 03:34 AM
Thanks for the Reply, I figured it out.
0
Ody
Top achievements
Rank 1
Veteran
answered on 29 Dec 2017, 08:22 PM

"Here is a forum post on the subject."

 

I updated that post with a solution using the .setOptions method of kendo widgets to update/modify the resources / grouping dynamically.

0
Tyler
Top achievements
Rank 1
answered on 02 Jan 2018, 03:46 PM

The issue with the setOptions, is for resources, those changes won't actually be reflected, even though if you console.log and debug your widget, you will see that setOptions did change the resources. 

I am not familiar with the rebind method of widgets, though. Not finding much documentation on that. That may be forcing some kind of re-rendering of the widget that allows the new option changes to actually take effect? That is interesting if this does work, as it allows you to do this without destroying the widget and recreating.

Tags
Scheduler
Asked by
Mohomed
Top achievements
Rank 1
Answers by
Tyler
Top achievements
Rank 1
Mohomed
Top achievements
Rank 1
Ody
Top achievements
Rank 1
Veteran
Share this question
or