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

Updating recurrences - single server request

14 Answers 109 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Simon
Top achievements
Rank 1
Simon asked on 11 Mar 2019, 08:50 AM

I am doing server validation on my create and update requests. However this causes an issue when updating a recurring event as it triggers both a create and update in some situations.

How can I "merge" 2 requests into 1 e.g. when making a recurrence exception by editing only single event?

14 Answers, 1 is accepted

Sort by
0
Simon
Top achievements
Rank 1
answered on 11 Mar 2019, 09:19 AM
UPDATE: I've looked at the transport submit function for my datasource, but it is unclear how to actually implement it correctly by using this method.
0
Ianko
Telerik team
answered on 12 Mar 2019, 12:14 PM
Hi Simon, 

I am afraid there is no possible way to accomplish that. The requests described are not triggered simultaneously so that they could be somehow prevented and replaced by a single request to the server. 

Even if it would be possible to achieve that, the Scheduler is designed to work with two requests in order to accomplish the exception with recurring events. Therefore, I am not sure whether the entire scenario with a single request would be feasible. 

Regards,
Ianko
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Simon
Top achievements
Rank 1
answered on 12 Mar 2019, 12:27 PM

This seems puzzling to me, as there must be people doing server side validation. If this validation fails  on one of the request, the changes have to be rolled back somehow if it was the last request that failed, otherwise further requests should be prevented.

What about the transport.submit function for the datasource? https://docs.telerik.com/kendo-ui/api/javascript/data/datasource/configuration/transport.submit

This seems to prevent the create, update and delete functions from getting triggered

0
Accepted
Ianko
Telerik team
answered on 13 Mar 2019, 05:54 AM
Hello Simon,

I can suggest you to check out this article about server validation: https://docs.telerik.com/kendo-ui/knowledge-base/scheduler-perform-server-validation-before-saving-task

In order to use the submit option you will need to have a unified server end-point that handles create, destroy and update actions. You can see a demo with our service here: https://dojo.telerik.com/erETUDik. This demo still uses different requests as the service is  implemented that way. What you can do is to implement the request according to the server operation you have and sent all the batch operations with a single request. 

Regards,
Ianko
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Simon
Top achievements
Rank 1
answered on 13 Mar 2019, 08:55 AM

Hi Ianko,

In the provided example it seems that the request data builds up. If I e.g. keep creating "create"-requests the data keeps growing. How do I reset/clear this data after the request has successfully been processed?

0
Ianko
Telerik team
answered on 13 Mar 2019, 11:53 AM
Hi Simon,

With the dojo I linked, I am unable to reproduce the described behavior. After calling the success method with the result from the request dirty data is being dismissed. Therefore, new one is processed as expected. 

Regards,
Ianko
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Simon
Top achievements
Rank 1
answered on 13 Mar 2019, 03:39 PM

Hi Ianko,

I was trying to replicate the issue I had in my dev environment to your dojo, so I basically changed your dojo to look more like the example from your documentation:

transport-submit

If I follow this documentation, e.g. by calling success like so: "e.success(e.data.created,"create");", I experience the build up of dirty data as seen in the attachment.

However if I do as you originally showed - pass the server response to e.success, the dirty data is being dismissed correctly.

Sorry for the confusion, I'm guessing theres a logical explanation for this behaviour, probably to do with the id being set in the response?

0
Ianko
Telerik team
answered on 14 Mar 2019, 07:56 AM
Hi Simon,

The documentation example shows it with the data available because there is no suitable to service to showcase this example. However, it is presumed that the success method should be always called with the data that is returned from the server. Otherwise, it would not make sense to have an AJAX server-side binding. 

Regards,
Ianko
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Simon
Top achievements
Rank 1
answered on 14 Mar 2019, 08:47 AM
It makes sense. Thanks Ianko!
0
Simon
Top achievements
Rank 1
answered on 16 Mar 2019, 01:04 PM

Maybe I should make a new thread, however currently I am facing a new challenge regarding using transport.submit.

I have added some custom fields to my data source schema. However updating values from these fields on an event does not update the data in my datasource on the page when I use transport.submit. They update as they should if I don't use transport.submit

fields: {
                    id: {from: 'id'},
                    title: {from: 'title', defaultValue: 'Ingen titel', validation: {required: true}},
                    start: {type: 'date', from: 'start_dt'},
                    end: {type: 'date', from: 'end_dt'},
                    description: {from: 'notes'},
                    price: {from: 'price', nullable: true},
                    location: {from: 'location'},
                    recurrenceId: {from: 'recurrence_id'},
                    recurrenceRule: {from: 'rrule'},
                    recurrenceException: {from: 'recurrence_exception'},
                    calendarIds: {from: 'calendar_ids', nullable: true},
                    customers: {from: 'customers', nullable: true},
                    isAllDay: {type: 'boolean', from: 'all_day'},
                    version: {from: 'version'},
                },
$.ajax({
type: 'POST',
url: '/events/update',
data: {'models': data.updated},
success: (response) => {
e.success(response.updated, "update");
},
error: (error) => {
e.error(error);
}
});

 

0
Simon
Top achievements
Rank 1
answered on 16 Mar 2019, 01:08 PM
Attached are examples of the data not being updated. I change the version server side and send back, however this change is not reflected
0
Simon
Top achievements
Rank 1
answered on 16 Mar 2019, 01:13 PM
0
Simon
Top achievements
Rank 1
answered on 16 Mar 2019, 01:19 PM

Looking further into it, what seems to happen is that the scheduler does not use the server response data at all! Instead it is simply using the data sent to the server, meaning server generated data is not updated.

0
Simon
Top achievements
Rank 1
answered on 16 Mar 2019, 01:52 PM
Wow, nevermind! I had overlooked how I handled the response. Sorry. Disregard all my last issues! :)
Tags
Scheduler
Asked by
Simon
Top achievements
Rank 1
Answers by
Simon
Top achievements
Rank 1
Ianko
Telerik team
Share this question
or