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
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
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
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
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?
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
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:
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?
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
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);
}
});
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.