Is there a way to disable a specific event in kendo ui scheduler?

左心房为你撑大大i 提交于 2019-12-11 03:12:15

问题


I am working with Kendo UI, js and the scheduler component.

My question is, if there is a way to disable a specific event from scheduler.

I find this, but this disables all events in scheduler. I want to disable just a specific event. The code should be something like this>

function disableEvents()
{
    var data = $("#scheduler").data("kendoScheduler").dataSource.data();
    data.forEach(function(event){
          if(event.ID='2') 
          {
               event.disable = true; //I have tried with event.editable = true;
          }
    });
}

I can't find the property editable nor disable, or something like that. Maybe there is a way to disable it using jquery. Can anybody help me?

Thank you!


回答1:


Use the event event's preventDefault method:

$("#scheduler").kendoScheduler({
    date: new Date("2013/6/6"),
    views: ["day", "month"],
    dataSource: [{
        id: 1,
        start: new Date("2013/6/6 08:00 AM"),
        end: new Date("2013/6/6 09:00 AM"),
        title: "Interview editable"
    }, {
        id: 2,
        start: new Date("2013/6/6 06:00 AM"),
        end: new Date("2013/6/6 07:00 AM"),
        title: "Interview not editable"
    }],
    edit: function (e) {
        if (e.event.id === 2) {
            e.preventDefault();
        }
    }
});

(demo)




回答2:


You will need to implement all the events specified in the restriction example of Kendo and preventDefault behaviour where ever your condition is not successfully.

For reference: Kendo Restriction Events Description.

You will need to take care of all the events (i.e. edit, save, resize, move) if you want to disable any event from any changes. The events are as below:

    resize: function(e) {
        if (e.event.meetingID = 1) {
            this.wrapper.find(".k-marquee-color").addClass("invalid-slot");
            e.preventDefault();
        }
    },
    move: function(e) {
        if (e.event.meetingId = 1) {
            this.wrapper.find(".k-event-drag-hint").addClass("invalid-slot");
        }
    },
    save: function(e) {
        if (e.event.meetinID = 1) {
            e.preventDefault();
        }
    },
   edit: function (e) {
        if (e.event.meetinID = 1) {
            e.preventDefault();
        }
    }

I have updated the Kendo Restriction example with your condition: Demo



来源:https://stackoverflow.com/questions/25193030/is-there-a-way-to-disable-a-specific-event-in-kendo-ui-scheduler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!