kendoui scheduler - insert multiple appointments in the "edit" event

43 views Asked by At

in the "edit" event of the scheduler (where i've customized the edit template) in need to ingore the current edit event and insert programmatically multiple appointments

i've tried in this way

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

                            

                        });


                    }

                },

this doesn't show the x1 and the x2 event in the scheduler even if when the datasource sends data to the server added events have been really added to the datasource

as note aside, on an external button click the code below works correctly showing me the new added appointments on the scheduler

schedulerDataSource.add(event);
scheduler.refresh();

I can't provide a live example but this is a full raw pastbin of the page the raw page

0

There are 0 answers