Search code examples
asp.net-mvckendo-uikendo-scheduler

Kendo Scheduler datasource not Refresh


I created an mvc application that implements a Kendo Scheduler ... The problem: I have a button that makes an ajax call that returns new data to populate the DataSource, but I am not able to populate the dataSource again ...

Can someone help me ?


Solution

  • Follow the code I made

                                    $.ajax({
                                        url: '@Url.Action("Action", "Controller")',
                                        type: "POST",
                                        data: { 'checados': checked },
                                        dataType: "jsonp",
                                        cache: false,
                                        success: function (results) {
                                            var result = [];
                                            var event;
    
                                            for (var i = 0; i < results.length; i++) {
                                                event = results[i];
    
                                                result.push(new kendo.data.SchedulerEvent({
                                                    id: event.ID,
                                                    title: event.Title,
                                                    description: event.Description,
                                                    start: kendo.parseDate(event.Start),
                                                    end: kendo.parseDate(event.End),
                                                    isAllDay: event.IsAllDay,
                                                    recurrenceException: event.RecurrenceException,
                                                    recurrenceId: event.RecurrenceId,
                                                    recurrenceRule: event.RecurrenceRule,
                                                    resource: event.Resource,
                                                }));
                                            }
    
    
                                            var resource = sch.resources[0];
                                            resource.dataSource.read();
    
                                            sch.setDataSource(result);
                                            sch.refresh();
    
    
    
                                        },
                                        error: function () {
                                            alert('Error occured');
                                        }
                                    });