Updating recurrences - single server request

15 posts, 1 answers
  1. Simon
    Simon avatar
    22 posts
    Member since:
    Feb 2019

    Posted 11 Mar 2019 Link to this post

    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?

  2. Simon
    Simon avatar
    22 posts
    Member since:
    Feb 2019

    Posted 11 Mar 2019 in reply to Simon Link to this post

    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.
  3. Ianko
    Admin
    Ianko avatar
    1940 posts

    Posted 12 Mar 2019 Link to this post

    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.
  4. Simon
    Simon avatar
    22 posts
    Member since:
    Feb 2019

    Posted 12 Mar 2019 in reply to Ianko Link to this post

    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

  5. Answer
    Ianko
    Admin
    Ianko avatar
    1940 posts

    Posted 13 Mar 2019 Link to this post

    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.
  6. Simon
    Simon avatar
    22 posts
    Member since:
    Feb 2019

    Posted 13 Mar 2019 in reply to Ianko Link to this post

    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?

  7. Ianko
    Admin
    Ianko avatar
    1940 posts

    Posted 13 Mar 2019 Link to this post

    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.
  8. Simon
    Simon avatar
    22 posts
    Member since:
    Feb 2019

    Posted 13 Mar 2019 in reply to Ianko Link to this post

    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?

  9. Ianko
    Admin
    Ianko avatar
    1940 posts

    Posted 14 Mar 2019 Link to this post

    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.
  10. Simon
    Simon avatar
    22 posts
    Member since:
    Feb 2019

    Posted 14 Mar 2019 in reply to Ianko Link to this post

    It makes sense. Thanks Ianko!
  11. Simon
    Simon avatar
    22 posts
    Member since:
    Feb 2019

    Posted 16 Mar 2019 Link to this post

    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);
    }
    });

     

  12. Simon
    Simon avatar
    22 posts
    Member since:
    Feb 2019

    Posted 16 Mar 2019 in reply to Simon Link to this post

    Attached are examples of the data not being updated. I change the version server side and send back, however this change is not reflected
  13. Simon
    Simon avatar
    22 posts
    Member since:
    Feb 2019
  14. Simon
    Simon avatar
    22 posts
    Member since:
    Feb 2019

    Posted 16 Mar 2019 Link to this post

    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.

  15. Simon
    Simon avatar
    22 posts
    Member since:
    Feb 2019

    Posted 16 Mar 2019 Link to this post

    Wow, nevermind! I had overlooked how I handled the response. Sorry. Disregard all my last issues! :)
Back to Top