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

Sort Resources after Adding New Resource

1 Answer 172 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Ben
Top achievements
Rank 1
Ben asked on 13 Sep 2017, 09:01 PM

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?

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 15 Sep 2017, 02:43 PM
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.
Tags
Scheduler
Asked by
Ben
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or