Date discrepancy when moving/resizing events

5 posts, 1 answers
  1. Grant
    Grant avatar
    163 posts
    Member since:
    Jul 2016

    Posted 17 Oct 2017 Link to this post

    Hi, 

    Im not going to pretend to know what is happening here, so I'll just explain how to duplicate it.

    I have a demo (https://dojo.telerik.com/iQEtE). Monitor the web console.

    1. Create an event, at 10:30am (for example).
    2. Resize the event so it starts at 10:00

    In the console, I've printed the event object which displays the start time as 10:00, the new time of the event. But on the next line I've explicitly printed the start value and it reads as 10:30, the original time.

    I have no idea what is happening, please advise.

    Thanks,
    Grant

  2. Tyler
    Tyler avatar
    68 posts
    Member since:
    Feb 2017

    Posted 17 Oct 2017 in reply to Grant Link to this post

    This isn't an issue I don't believe. In my own scheduler, I just checked and confirmed that in the moveEnd function, the e.event has the original times (before moving), but the e.start and e.end are the correct times.

    This modify dojo has a dataBound and dataBinding event in your Scheduler. You will see that dataBinding happens after the moveEnd, and dataBound follows dataBinding. When you look at the event in the dataBinding function (under e.items), the times are the new times you moved the event to.

    I believe what is happening is that the event is not updated and synced at the time you print the event in the moveEnd. It then gets synced to the new times in dataBinding. 

    Also, the e.event and e.event.start console.log/error both print the original time of 10:30am. 

     

    So, I believe things are fine. The event updates and moves and stays in the correct time slot, and the time gets correctly set in the dataBinding event for that event. 

  3. Answer
    Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    1201 posts

    Posted 19 Oct 2017 Link to this post

    Hi Grant,

    The reason for the observed difference is the fact, that the logged e.event object on the console keeps a reference to the event object stored in the Scheduler DataSource. At the time when the event handler is executed both values are equal. Nevertheless, when you click to expand the logged event object, as it actually holds a reference to the event object, the updated time will be seen.

    Here you will find a modified version of the Dojo, which demonstrates the above. In order to keep all the values in the e.event object as they are at the time of execution of the event, I am converting to JSON string this object. You will notice that the ISO date string for the start field is the same as the one logged from the following expression: console.error(e.event.start.toISOString());

    The time fields in the e.event object will always keep their initial value. As Tyler mentioned, the updated values could found in the e.start and e.end fields.

    Regards,
    Veselin Tsvetanov
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  4. Grant
    Grant avatar
    163 posts
    Member since:
    Jul 2016

    Posted 19 Oct 2017 in reply to Veselin Tsvetanov Link to this post

    Hi Veselin, 

    Thanks for the explanation it really clears things up. As both yourself and Tyler suggested, I've updated my work to use e.start and e.end instead.

    Just a heads up in the scheduler API the resizeEnd event does not mention that it has start and end date like the moveEnd does. (https://docs.telerik.com/kendo-ui/api/javascript/ui/scheduler#events-resizeEnd)

    Thanks,
    Grant

  5. Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    1201 posts

    Posted 23 Oct 2017 Link to this post

    Hi Grant,

    Thank you for bringing the missing information from our API reference to our attention. I have just added the discussed fields to the resizeEnd event description and they will be live very soon.

    As a small token of gratitude for helping us to improve our documentation, I have updated your Telerik points.

    Regards,
    Veselin Tsvetanov
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top