Bug Report - Units View in Week Mode - dhtmlx Scheduler

Units are not populated properly in newly created events when in a multi-day view.

Instructions:

  1. Load bug_reproduction.html from /samples/03_extensions/bug_reproduction.html
  2. Create an event on Mon, June 30 in Section C. - Notice how it sets the section to Section A.
  3. Create an event on Tue, Jul 1 in Section A. - Notice how it sets the section to Section B.

The section calculation is not properly taking the week view into consideration, and is simply assigning the Section based as if the dates were the sections.

bug_reproduction.html

<!doctype html>
<head>
	<meta http-equiv="Content-type" content="text/html; charset=utf-8">
	<title>Units view</title>
</head>
	<script src="../../codebase/dhtmlxscheduler.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../codebase/ext/dhtmlxscheduler_units.js" type="text/javascript" charset="utf-8"></script>
	<link rel="stylesheet" href="../../codebase/dhtmlxscheduler.css" type="text/css" title="no title" charset="utf-8">
	
<style type="text/css" media="screen">
	html, body{
		margin:0px;
		padding:0px;
		height:100%;
		overflow:hidden;
	}	
</style>

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

		var sections=[
			{key:1, label:"Section A"},
			{key:2, label:"Section B"},
			{key:3, label:"Section C"},
			{key:4, label:"Section D"}
		];
		
		scheduler.locale.labels.unit_tab = "Unit"
		scheduler.locale.labels.section_custom="Section";
		scheduler.config.details_on_create=true;
		scheduler.config.details_on_dblclick=true;
		scheduler.config.xml_date="%Y-%m-%d %H:%i";
		
		scheduler.config.lightbox.sections=[	
			{name:"description", height:130, map_to:"text", type:"textarea" , focus:true},
			{name:"custom", height:23, type:"select", options:sections, map_to:"section_id" },
			{name:"time", height:72, type:"time", map_to:"auto"}
		]
		
		scheduler.createUnitsView({
			name:"unit",
			property:"section_id",
			list:sections,
			days:4
		});
		scheduler.config.multi_day = true;
		
		scheduler.init('scheduler_here',new Date(2014,5,30),"unit");
		scheduler.load("./data/units.xml");
	}
</script>

<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="unit_tab" style="right:280px;"></div>
			<div class="dhx_cal_tab" name="month_tab" style="right:76px;"></div>
		</div>
		<div class="dhx_cal_header">
		</div>
		<div class="dhx_cal_data">
		</div>		
	</div>
</body>

Hello,
I tried to reproduce the error on the latest evaluation package of the scheduler (v4.3.1), but it seemed worked correctly.
Are there any other steps need to be done for reproducing the bug? Does it happens in certain timezone only?

Hi Aliaksandr,

I work with gggggggg and is the one who actually reported the bug.

We are using v4.3.1 Enterprise. I think I might not have been 100% clear.

Step 1, make sure you load the unit view in week mode (in the attached file from the original post it’s 4 days). You should see the following:

Now, try to create a new event in section B on the first visible day by double clicking in the section B column. You will notice that it initialized the event with Section A set in the lightbox. It should be Section B. See here:

When using Units view in single day mode, it is correct - when double clicking in a section column, that column is populated correctly in the lightbox.

Note that sometimes it’s correct, but that’s just random. I selected a 4 day view, because there are 4 sections too. So whenever you click anywhere in Day 1, Section A will be selected. Whenever you click in Day 2, Section B will be selected, etc. So obviously there’s an offset calculation issue.

In fact I tried to debug it a bit, and found that the x position value is always undefined in the mouse click event when in weekly mode. But it was really getting into the internals of scheduler, so not sure if I was on the right track.

Thanks,
J

Oh, we’re in Australia Eastern timezone (UTC+10) if that matters at all.

Hello,
i’ve confirmed the issue. It happens only when you create an event by double clicking on a calendar area (previously I’ve tried creating events by drag and drop).
As a workaround you can add this snippet on the page, note that ev.section_id is a mapping property of a units view. It may differ in your case

scheduler.attachEvent("onEventCreated", function(id, e){ var click = scheduler.getActionData(e); var ev = scheduler.getEvent(id); ev.section_id = click.section; scheduler.updateEvent(id); });

Hi Aliaksandr,

That snippet worked perfectly. Thank you very much.

-J