Prevent scheduled task from being deleted

4 posts, 0 answers
  1. Marc
    Marc avatar
    4 posts
    Member since:
    May 2012

    Posted 30 May 2016 Link to this post

    Hi,

    Is it possible to prevent certain scheduled tasks from being deleted in the user interface?

  2. Ivan Danchev
    Admin
    Ivan Danchev avatar
    2129 posts

    Posted 31 May 2016 Link to this post

    Hello Marc,

    The Scheduler can be configured so that the user cannot delete events. In order to do this you can call Destroy with a "false" parameter as shown below. By default it is "true" and deletion of events is enabled.
    .Editable(editable => editable.Destroy(false))

    This will have effect for all events. If you want to prevent the deletion only of specific events you can handle the Scheduler's Remove event, in which the event the user is trying to delete is accessible through the arguments, check whether the event fulfills a condition and cancel the deletion. In the following example we prevent the user from deleting an event with a specific title:
    function scheduler_remove(e) {
        if (e.event.title == "Take the dog to the vet") {
            e.preventDefault();
        }
    }

    Regards,
    Ivan Danchev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. Mark
    Mark avatar
    2 posts
    Member since:
    Nov 2017

    Posted 09 Aug 2018 in reply to Ivan Danchev Link to this post

    Hi,

    Unfortunately, scheduler_remove fires after the delete confirmation prompt, which looks really bad ("Do you want to delete this?" "yes?", "well you can't", "no, I don't know why we asked either"...)

    As I have a set of events, only some of which are to be deletable, I would like only to have a delete confirmation prompt when delete is actually going to be possible for that specific event. (Or of course, conditional removal of the delete button itself).

    Is this possible?

    Thanks

  4. Ivan Danchev
    Admin
    Ivan Danchev avatar
    2129 posts

    Posted 10 Aug 2018 Link to this post

    Hi,

    I agree that preventing the event is counter intuitive in the scenario you described. You could consider using a different approach - saving the information about whether an event can or cannot be removed in a field in the event itself. Then you can use template for the event render or not a custom class in the template based on that field value. In the databound event you can find all events that have that class (e.g. "non-removable") and hide their remove button. In addition to the databound event the edit event  can be used to hide the Delete button from the Scheduler's Editor, which appears on double-clicking an event.
    Here's a dojo example, which demonstrates this approach. The "Meeting" event has the nonRemovable field set to "non-removable". It is added as a class within its template. This allows its remove/Delete buttons to be hidden in mentioned event handlers.

    Regards,
    Ivan Danchev
    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.
Back to Top