Sort Resources after Adding New Resource

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

    Posted 13 Sep Link to this post

    I added a resource using the following code: 

     var scheduler = $("#scheduler").data("kendoScheduler");
                scheduler.resources[0].dataSource.add({
                    Text: "aaaaaBBBBBB",
                    Value: 23,
                    Color: "#FFFFFF"
                    
                });

    scheduler.view(scheduler.view().name);

    How can I get the resources to sort by Text so that it shows up in order and not at the end?

  2. Dimitar
    Admin
    Dimitar avatar
    225 posts

    Posted 15 Sep Link to this post

    Hello Ben,

    On the following Dojo example you can find a simple Scheduler implementation, where I have demonstrated in the click event of a button how to sort the Scheduler resources.

    To achieve this, the DataSource's sort() method can be used, by supplying an object with the field that we want to sort and the direction: 
    <script>
    $("#add-resource").on("click", function() {
    scheduler.resources[0].dataSource.add({
    text: "aaaaaBBBBBB",
    value: 23,
    color: "#FFFFFF"
    });
            
    scheduler.resources[0].dataSource.sort({ field: "text", dir: "asc" })
    scheduler.view(scheduler.view().name);
    });
    </script>

    I hope this resolves the issue. In case you need further assistance with configuring the widget, please let me know.

    Regards,
    Dimitar
    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