Adding resources to scheduler in external javascript event handlers

5 posts, 0 answers
  1. Mohomed
    Mohomed avatar
    22 posts
    Member since:
    Sep 2017

    Posted 12 Oct 2017 Link to this post

    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");
  2. Tyler
    Tyler avatar
    63 posts
    Member since:
    Feb 2017

    Posted 12 Oct 2017 in reply to Mohomed Link to this post

    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.

  3. Mohomed
    Mohomed avatar
    22 posts
    Member since:
    Sep 2017

    Posted 12 Oct 2017 in reply to Tyler Link to this post

    Thanks for the Reply, I figured it out.
  4. Ody
    Ody avatar
    11 posts
    Member since:
    Oct 2016

    Posted 29 Dec 2017 in reply to Tyler Link to this post

    "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.

  5. Tyler
    Tyler avatar
    63 posts
    Member since:
    Feb 2017

    Posted 02 Jan in reply to Ody Link to this post

    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.

Back to Top