在调度程序的“编辑”事件中(我已经自定义了编辑模板)需要 退出当前编辑事件并以编程方式插入多个约会
我试过这样
editable: {
template: $("#customEditorTemplate").html(),
},
edit: function(e){
if(e.event.isNew()){
//get formcontrols referenece
var title = e.container.find("[name=title][data-role=textbox]");
var start = e.container.find("[name=start][data-role=datetimepicker]");
var end = e.container.find("[name=end][data-role=datetimepicker]");
... other code
..
//set formcontrols value
$(title).data("kendoTextBox").value(sTitle);
$(start).data("kendoDateTimePicker").value(startTime); //set start date to the current date and time
$(end).data("kendoDateTimePicker").value(endTime); //set enddate to the current date and time
//when click on save i need to insert not the current event but multiple event that i prepared programmatically
this.one("save", function(e) {
e.preventDefault();
var x1 = {
"start": new Date(2023,3,28,12,00,00),
"end": new Date(2023,3,28,18,00,00),
"title": "x1",
};
schedulerDataSource.add(x1);
var x2 = {
"start": new Date(2023,3,29,12,00,00),
"end": new Date(2023,3,29,18,00,00),
"title": "x2",
};
schedulerDataSource.add(x2);
scheduler.cancelEvent(); //remove/abort the current event
scheduler.refresh(); //doesn't work, doesn't refresh the scheduler
});
}
},
这不会在调度程序中显示 x1 和 x2 事件,即使当数据源将数据发送到服务器时,添加的事件确实已添加到数据源
除此之外,在外部按钮上单击下面的代码可以正常工作,向我显示调度程序上新添加的约会
schedulerDataSource.add(event);
scheduler.refresh();