Question

I've created a Kendo Scheduler that binds to a remote data source. The remote datasource is actually a combination of two separate data sources. This part is working okay.

Question is... is there any way to prevent certain events from being destroyed?

I've stopped other forms of editing by checking a certain field in the event's properties and calling e.preventDefault() on the edit, moveStart and resizeStart events if it should be read-only. This works fine, but I can't prevent deletes.

Any suggestions greatly appreciated.

Was it helpful?

Solution

Just capture the remove event and process it as you have with the edit, moveStart, and reviseStart events. You should see a remove event option off the kendo scheduler. I can see it and capture it in version 2013.3.1119.340.

OTHER TIPS

I think better way is to prevent user from going to remove event in the first place. Handling the remove event still has its validity as you can delete event for example by pressing "Delete" key).

In example below I'm assuming event has custom property called category and events with category equal to "Holiday" can't be deleted.

remove: function(e)
{
  var event = e.event;
  if (event.category === "Holiday")
  {
    e.preventDefault();
    e.stopPropagation();
  }
},
dataBound: function(e)
{
  var scheduler = e.sender;
  $(".k-event").each(function() {
    var uid = $(this).data("uid");
    var event = scheduler.occurrenceByUid(uid);
    if (event.category === "Holiday")
    {
      // use .k-event-delete,.k-resize-handle if you want to prevent also resizing
      $(this).find(".k-event-delete").hide();
    }
  });
},
edit: function (e) {
   var event = e.event;
   if (event.category === "Holiday")
   {
     e.container.find(".k-scheduler-delete").hide();
   }
}

FYI, you can do this...

@(Html.Kendo().Scheduler<ScheduledEventViewModel>()
    .Name("scheduler")
    .Editable(e => e.Confirmation(false))
)

which will deactivate the default confirmation prompt for the scheduler. Then you can do your own prompt on items you want.

There is also a

.Editable(e => e.Destroy(false))

that you can do to remove the X on the event window. This particular example would remove it for all of the events, but there might be a way to remove it for specific ones.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top