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

Is there a way to reject UPDATE, CREATE, or DESTROY requests?

3 Answers 152 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Phil
Top achievements
Rank 1
Phil asked on 16 Aug 2013, 12:48 PM
I've been playing with the Scheduler using the Javascript web-variant of the control.  I finally managed to get it to properly send UPDATE, CREATE, and DESTROY requests to my MVC4 controller.  I also captured some of the traffic from the online demo to see what the proper JSON responses were for those requests from the controller.

My question, though, is how do I reject a delete request, for instance, if the backend code and database (MySql in this case) cannot process and manage the request, for instance?  I haven't found any documentation (yet) that suggestions how to stop the scheduler from going ahead and removing the item from the control anyway, regardless of the response (it also removes right now even though my controller returns a "not implemented" server message).

3 Answers, 1 is accepted

Sort by
0
Phil
Top achievements
Rank 1
answered on 19 Aug 2013, 12:49 PM
Bump.

Anyone actually tried to respond to these type of requests negatively?

I did notice, for instance, that not responding properly to a CREATE request does just leave the CREATE popup displayed, but UPDATE and DESTROY seem to not care about what response comes back from the server and happily modify display on the control.
0
Accepted
Rosen
Telerik team
answered on 19 Aug 2013, 01:37 PM
Hi Phil,

There are two ways to notify the DataSource that the data CUD operation has failed:

- request returns an Error Status Code
        - or the response contains an error field.

In both cases error event will be raised and the DataSource changes will not be accepted, the modifications will stay in local context and will be resend with the next sync.

Having this in mind in order to restore the deleted event, you will need to call cancelChanges method of the DataSource if an error occur. For example:

$("#scheduler").kendoScheduler({
  //.. 
  dataSource: {
    error: function(e) {      
      if (e.errorThrown === "My error text") { // handle only the correct error
        this.cancelChanges();
      }
    },   
    transport: {
      //...
    },
    schema: {
      //...
    }
  }
});

Regards,
Rosen
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Phil
Top achievements
Rank 1
answered on 19 Aug 2013, 01:52 PM
Thank you for your response.  I will give that a try when I get a moment.
Tags
Scheduler
Asked by
Phil
Top achievements
Rank 1
Answers by
Phil
Top achievements
Rank 1
Rosen
Telerik team
Share this question
or