Schedulie shown twice

Hi,

I’m experiencing a strange behavior while creating new schedule.
I’ve my scheduler and when I create new schedule (double clicking to the day cell) through the default ligthbox. At Save time I create an entry into my database then I call scheduler load function. The scheduler is correctly refreshed, but I see to entries into the scheduler, see attachments.

One is from the database, the 2nd don’t know from where (into the database I’ve just one insert).

The load function is:

	scheduler.attachEvent("onEventSave",function(id,data,is_new_event){
		var date_to_str = scheduler.date.date_to_str(scheduler.config.api_date);
		var param = "idm="+id+"&title="+data.text+"&ds="+date_to_str(data.start_date)+"&de="+date_to_str(data.end_date);

		$.get("data/calendarEventManage.php?act=ins&"+param, function(data) {
			alert(data);	
			scheduler.load("xml/calendarLoad.php");
			return true;
		});
	})

calendarLoad.php is:

<?php
header("Content-type: text/xml");

session_start();
require("../db/conn.php");
require("../php/general_functions.php");
$uid = $_SESSION["uid"];
//$uid = 1;


//create the XML

echo('<?xml version="1.0" encoding="UTF-8"?>');
echo('<data>');

$sql = "SELECT m.id_meeting, m.id_customer, c.company_name, m.title, ".
       "       m.date_start, m.date_end, m.note  ".
       "  FROM v_meeting m, v_customer_list c ".
	   " WHERE m.id_user = $uid ".
	   "   AND date_start > now() ".
	   "   AND c.id_customer = m.id_customer";
	   
$asset = mysql_query ($sql);
if($asset){
	while($row=mysql_fetch_array($asset)){
		echo('	<event id="'.$row['id_meeting'].'">');
		$text = $row['title'];
		if($row['company_name'] != "") {
				$text = $row['company_name'].' - '.$text;
		}
		
		echo('		<text><![CDATA['.$text.']]></text>');
		echo('		<start_date>'.getSchedulerFormatFromMYSQL($row['date_start']).'</start_date>');
		echo('		<end_date>'.getSchedulerFormatFromMYSQL($row['date_end']).'</end_date>');
		echo('		<details><![CDATA['.$row['note'].']]></details>');
		echo('	</event>');
	}
}	

echo('</data>');
?>

Thanks in advance,
Samuel

Hello,
you need to clear calendar before loading data, otherwise you’ll get a mix of old and loaded data. $.get("data/calendarEventManage.php?act=ins&"+param, function(data) { alert(data); scheduler.clearAll(); scheduler.load("xml/calendarLoad.php"); return true; });
However, why do you need to send Ajax with event data manually?
If you use dhtmlxDataProcessor on client side, you won’t need to trace data changes manually. The data processor will send all needed requests, you’ll only have to render response in a correct format.
And if you use dhtmlxConnector on server side, you won’t need any manual code for handling save or load operation. It will handle dataprocessor requests automatically. Connector supports filters, so you could attach conditions from ‘WHERE’ section to it

docs.dhtmlx.com/doku.php?id=dhtm … filtration
docs.dhtmlx.com/doku.php?id=dhtm … cessor:toc

Check the example from the package
samples/01_initialization_loading/05_loading_database.html

Thanks it worked.
Don’t know how I forgot about the clearAll…

I’ll have a look at the connector.
Thanks for the suggestion!

Samuel