[shed-3.5] Cut and Paste ignores collision

I can’t find anywhere to report bugs so I’m posting here.
When you cut and paste an event using the dhtmlxscheduler_key_nav.js it ignores the no collision part of dhtmlxscheduler_collision.js so that the pasted events appear at the same time.

It should (IMO) paste them in the next available free slot so that it can never be wrong.

Do I need to include anything else so that the pasted events don’t overlap existing events?

I am including the following libraries:

        <script src='../../codebase/dhtmlxscheduler.js' type="text/javascript" charset="utf-8"></script>
        <script src='../../codebase/ext/dhtmlxscheduler_timeline.js' type="text/javascript" charset="utf-8"></script>
        <script src='../../codebase/ext/dhtmlxscheduler_treetimeline.js' type="text/javascript" charset="utf-8"></script>
        <script src="../../codebase/ext/dhtmlxscheduler_key_nav.js" type="text/javascript" charset="utf-8"></script>
        <script src="../../codebase/ext/dhtmlxscheduler_collision.js" type="text/javascript" charset="utf-8"></script>

Here is an example of what I mean.
Load this page.
Left click on “my event”
control+c then control+v
A new event is placed under “my event”. Now we have 2 overlapping events which are saved.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	<meta http-equiv="Content-type" content="text/html; charset=utf-8">
	<title>For demo purpose only :: &1</title>
        <script src='../../sources/dhtmlxscheduler.js' type="text/javascript" charset="utf-8"></script>
        <script src='../../sources/ext/dhtmlxscheduler_timeline.js' type="text/javascript" charset="utf-8"></script>
        <script src='../../sources/ext/dhtmlxscheduler_treetimeline.js' type="text/javascript" charset="utf-8"></script>
        <script src="../../sources/ext/dhtmlxscheduler_key_nav.js" type="text/javascript" charset="utf-8"></script>
        <script src="../../sources/ext/dhtmlxscheduler_collision.js" type="text/javascript" charset="utf-8"></script>

	<link rel='stylesheet' type='text/css' href='../../codebase/dhtmlxscheduler.css'>

<style type="text/css" media="screen">
	html, body{
		padding-top:5px; padding-left:5px;
		text-align:left !important;

<script type="text/javascript" charset="utf-8">
	function init() {

		scheduler.locale.labels.timeline_tab = "Timeline";
		scheduler.locale.labels.section_video_format="Video Format";
		scheduler.locale.labels.section_audio_format="Audio Format";
		scheduler.config.xml_date="%Y-%m-%d %H:%i";
		var elements = [ // original hierarhical array to display
			{key:10, label:"Stuff", open: true, children: [
					{key:40, label:"Stuff 1"},
					{key:50, label:"Stuff 2"}
			section_autoheight: false,
			name:	"timeline",
			x_unit:	"minute",
			x_date:	"%H:%i",
			x_step:	30,
			x_size: 24,
			x_start: 16,
			x_length:	48,
			y_unit: elements,
			y_property:	"section_id",
			render: "tree",

		//Data loading

			{name:"description", height:130, map_to:"text", type:"textarea" , focus:true},
			{name:"custom", height:23, type:"timeline", options:null , map_to:"section_id" }, //type should be the same as name of the tab
			{name:"time", height:72, type:"time", map_to:"auto"}
		scheduler.init('scheduler_here',new Date(2009,5,30),"timeline");
			{ start_date: "2009-06-30 12:00", end_date: "2009-06-30 14:00", text:"my event", section_id:40},

<body onload="init();">
	<div id="scheduler_here" class="dhx_cal_container" style='width:100%; height:100%;'>
		<div class="dhx_cal_navline">
			<div class="dhx_cal_prev_button">&nbsp;</div>
			<div class="dhx_cal_next_button">&nbsp;</div>
			<div class="dhx_cal_today_button"></div>
			<div class="dhx_cal_date"></div>
			<div class="dhx_cal_tab" name="day_tab" style="right:204px;"></div>
			<div class="dhx_cal_tab" name="week_tab" style="right:140px;"></div>
			<div class="dhx_cal_tab" name="timeline_tab" style="right:280px;"></div>
			<div class="dhx_cal_tab" name="month_tab" style="right:76px;"></div>
		<div class="dhx_cal_header">
		<div class="dhx_cal_data">


Please try again using attached files.
Collision event is called now and you can either block it or allow operation.

Kind regards,
collision+key_nav.zip (2.12 KB)

Many thanks Ilya. The collision detector now pays attention to “scheduler.config.collision_limit” and won’t let me paste into an area below. However, by doing so this solution effectively cancels the ability to cut&paste.

The majority of the reason for implementing the cut&paste feature is to copy all the peripheral information contained within an event, rather than the start and end date of the event. That said I think the pasting mechanism should make best effort to find a legal place to paste itself into. The current pasting mechanism doesn’t let you specify where the pasted event will be located so one is likely to want to change it’s location straight away it anyway.

My suggestion would perhaps be to see how much room there was after (or before) the event and place it there, reducing it’s duration if necessary. It’s a time line so there will be room somewhere!

Many thanks,

It’s really not a job of copy&paste extension to find “right” place. “Right” place is very subjective and depends on business logic. And collision extension is goal is quite clear - if there is a collision it calls corresponding event and now you can apply your custom logic to allow it or deny.

For example I booked appointment for 3 hours and then called and asked to move it to another day. Manager cut my event and pasted to the new day. Now he didn’t notice that there is another event there and suddenly my appointment is happening at different hour and lasts not 3 hours but who-knows-how-many :slight_smile:

Remember that you yourself can attach handlers to different internal events (onEventCollision, onEventPasted) and manually directly change event time.

Best regards,

Thanks very much for the clear advice. I’ve really got into it over the last few days and even learnt enough to overcome the single click double click problems.
I’ve implemented most of “my right way” and I understand the problem more clearly!
Thanks again for the help.