scheduler jumps to current time

When i add an event to the scheduler it jumps to the current hour. So i need to scroll down to see my just newly added event. I’ve tried the following, but it has no positive result…

dp.attachEvent("onFullSync",function(){ scheduler.clearAll(); scheduler.load("inc/xml/agenda/agenda_renderer.php?uid="+scheduler.uid()); })

The scheduler.clearAll(); is the problem here.

I need to reload the dataprocessor (agenda_renderer.php) after i insert or update an event. Without the scheduler going (scrolling) to the current hour…

Any ideas, i’ve been working to long on a fix for this ?

The overal problem is that the event is not displaying the customized “event_text”.

Example of customized event_text:


if 		(event.Type == 1){	// 1 = klant afspraak
scheduler.templates.event_class=function(start,end,event){ return "";}	//Kleur instellen event type 1
return "<img src=images/icons/user.png><b><a style='text-decoration:none;color:#0482DB;' href='klanten_overzicht.php?KlantID="+event.KlantID+"'>"+event.details+"</a></b><br><img src=images/icons/scissors-normal.png> <p2 style='font-size:10px;'>"+event.BehandelingID+"<img src=images/icons/printer.png border=0 align=right onclick='openInIFrame(\"inc/labelprinter.php?KlantID="+event.KlantID+"&eventid=""\")'></p2><br><img src=images/icons/user_suit.png> "+event.Behandelaar+"<br>"+event.text+"";	}
else if (event.Type == 2){	// 2 = overige afspraak
scheduler.templates.event_class=function(start,end,event){ return "event_twee";}//Kleur instellen event type 2
return "</b><img src=images/icons/note.png> "+event.text+"";


So i can render the event_text is rendered GOOD when i add following:

dp.attachEvent("onFullSync",function(){ /* scheduler.clearAll(); scheduler.load("inc/xml/agenda/agenda_renderer.php?ts=" + (new Date()).valueOf()); });

But then the scheduler scrolls/jumps to the current hour after creation of a new event. This is obviously caused by “scheduler.clearAll();”


The culprit here is definitely

scheduler.load("inc/xml/agenda/agenda_renderer.php?ts=" + (new Date()).valueOf()); 

as it refreshes current view (which in turn resets current scroll).

What I can offer is a bit tricky though:

  1. Save start end hour of the last changed event.
  2. Save current value of scheduler.config.scroll_hour option.
  3. Replace it with value saved in [1].
  4. Call scheduler.load function (view will be scrolled to display event).
  5. Restore original scroll_hour value.

Best regards,

That’s seems resonable. Need to save the current scroll_hour and than give it back after rendering :slight_smile:

How can i get the latest event_start_time…

Or could you give me a starting script to get me going?

As onFullSync event occurs after all operations were finished so you can attach handler to those update operations. Use onAfterUpdate event, grab event id, save it’s start/end time and use it later in onFullSync.

Best regards,

Ok thanks! :smiley:

How do i get the start/end time from latest added event ?

i can get the id with:

dp.attachEvent("onAfterUpdate",function(sid,action,tid,xml_node){ alert(sid); alert("hallo"); return true; });

But how do i get start/end time from this event?

var ev = scheduler.getEvent(sid); // got and stored event in 'ev' variable scheduler._latest_time = ev.start_date; // some global flag you can use further
Best regards,

Thanks very much !!

I’ve got it sort of working with following:

[code]Stamp = new Date();
var Hours = Stamp.getHours();
scheduler.config.scroll_hour = Hours;

		var ev = scheduler.getEvent(sid);
		scheduler._latest_time = ev.start_date;
		var latest_begin_uur = scheduler._latest_time.getHours();
		scheduler.config.scroll_hour = latest_begin_uur;

		return true;
	dp.attachEvent("onFullSync", function(){
		return true;

Only problem is that the scheduler.config.scroll_hour is the start hour of the event. So the screens still jumps to the starting hour of the last added event. I have no clue on how to fix this…

Any ideas ? Would be so glad to get this right!

Didn’t get it.

Initial problem:

Now even after calling scheduler.load function your last added event will be displayed on the screen (as scroll will be set to displayed it), window won’t jump to the top.
What seems to be the problem?

I believe you missed a bit of code

var ev = scheduler.getEvent(sid);
scheduler._latest_time = ev.start_date;

return true;


dp.attachEvent(“onFullSync”, function(){
var initial_scroll = scheduler.config.scroll_hour; // saving initial scroll
scheduler.config.scroll_hour = scheduler._latest_time.getHours(); // changing to the latest hours
scheduler.load(“inc/xml/agenda/agenda_renderer.php?uid=”+scheduler.uid(), function(){
scheduler.config.scroll_hour = initial_scroll; // restoring initial scroll in the callback function
return true;

Best regards,


problem is that i set the scheduler to scroll to the current hour with the following:

Stamp = new Date(); var Hours = Stamp.getHours(); scheduler.config.scroll_hour = Hours;

Let’s say it’s 10:00, ‘scheduler.config.scroll_hour’ would be 10.

Now i make an appointment at 18:00. In my view then the hour on the left would be for instance 16:45.
If I declare: var initial_scroll = scheduler.config.scroll_hour;
then the ‘initial_scroll’ would also be 10 and not the 16:45 …

I can give you an online example, but copying everything is too much work. And i don’t want to make the url public. Maybe i can PM you ?

That indeed works, but the screen still jumps and puts the last created event on top of screen. Not that bad, but not perfect i mean…

I’ve fixed it in a much more effective way.

dp.attachEvent("onFullSync", function(){ scheduler.clearAll(); var init_scroll = scheduler._els["dhx_cal_data"][0].scrollTop; scheduler.load("inc/xml/agenda/agenda_renderer.php?uid="+scheduler.uid(), function(){ scheduler._els["dhx_cal_data"][0].scrollTop = init_scroll; }); return true; });

Above code remembers the scroll position from the top of element “dhx_cal_data” . Then it loads the new information from MySQL db with “agenda_renderer.php”. After that I set the scrolling from the top of element “dhx_cal_date” back to the original value before ‘scheduler.load’.

With this the problem of reloading and jumping screen is GONE!!

Thanks for thinking with me Ilya. much much thanks! You’ve got me thinking in the right direction.