end Date time of event

Hi I am trying to set the end date time of a created event when it is saved. The user selects a drop down list that I created and when they hit save the end date gets adjusted based on the selection. For some reason the end date is not being set. Code as follows.

// Save the appointment type selected as display text.
 scheduler.attachEvent("onEventSave",function(id,data,is_new_event){
		
	     
                // get the current start date choosen
		  var endDateTime = new Date(scheduler.getEventStartDate(id));

		  // get the time for service
		 var addedTime = service_time[data.section_id].time;

		 //set total time for service
		endDateTime.setMinutes(endDateTime.getMinutes() + addedTime);

		//set the appointment end time
		 scheduler.setEventEndDate(id, endDateTime);

		
		return true;
});

Try to use onEventChanged | onEventAdded handlers.
When onEventSave called, the saving process is not finished yet, and data which you set by api will be overwritten by data from the lightbox form.

Stanislav,

That will not work in my case but I have found another solution kind of a hack way of doing it. I am using onAfterLightbox to set the time but the problem is I need the ID of the current event and the data of the event so I can apply the time change. My solution works it uses two global variables but I would rather have a handle to the event in the function call. The onAfterLightBox doesn’t allow a function call with the id for the current event so I had to do it this way.

var currentData = 0;      <-- global's
var currentID = 0;

// Save the appointment type selected as display text.
scheduler.attachEvent("onEventSave",function(id,data,is_new_event){
			   	var text = scheduler.getLabel("section_id", data.section_id);
			   	currentData = data.section_id; <--- Values getting saved to global
			   	currentID = id;                        <--  
			    	this.setEventText(id, text);
			    	 
				return true;
			});
			
			
			scheduler.attachEvent("onAfterLightbox", function (){
				 // get the current start date chosen
			   	
				  var endDateTime = new Date(scheduler.getEventStartDate(currentID));
				  
			   	     // get the time for service
			   	    var addedTime = service_time[currentData].time;
			   	     //set total time for service
			   	    
			   	   endDateTime.setMinutes(endDateTime.getMinutes() + addedTime);
			   	     //set the appointment end time
			   	     scheduler.setEventEndDate(currentID, endDateTime);
			    	currentID = currentData = 0; <-- clearing globals
			  });

How can I block the user from adjusting the time by dragging the event time in the view?

We will change behavior of onEventSave in the next version, so it will be possible to modify data there.

How can I block the user from adjusting the time by dragging the event time in the view?

scheduler.attachEvent("onBeforeDrag", function(){ return false; });