Reload Data after Save Event

hi,

i want to reload the data(from xml) when a event is updated(saved).

 scheduler.attachEvent("onEventChanged", function(id,e){
            //any custom logic here
            scheduler.load("records");
        });

is not working because its load the records before the change is made in the DB. :frowning:

any advice?

got it:

        scheduler.attachEvent("onAfterLightbox", function (){
            //any custom logic here
            scheduler.load("records");
        });

Actually it is not safe as well.

dp.attachEvent("onFullSync", function(){ //all saved scheduler.load("some.url"); });

Thanks.

Can you explain me the differens?

Data saving is async, when you are calling code from onAfterLightbox - in that moment of time, data is already sent to server side for the saving, but in fact it is not saved yet. In moment when load call will reach the serve it may be saved ( most probably ) or not saved yet ( may occur if server was busy )

When onFullSync event is triggered when saving confirmation is received from the server, so all data is saved for sure, and loading call will retrieve the new data in all cases.

I am sorry but I am fighting with the same problem. Your method works until I turn the Live update mode on. With this on the event gets updated for a fraction of second and then gets back to previous state (I belive this revert is done by Live update). How can I fix this?

I don’t know how to edit posts. Sorry.

Of course when I refresh the page the events appear correctly, including changes I’ve made. Changes concern of event text and color.

Please provide a sample of code for which issues occurs ( client side part only )
Also, which version of scheduler you are using ?

Thank you for the answer.

[code] scheduler.config.collision_limit = 1;
scheduler.locale.labels.unit_tab = “Sale”;
scheduler.locale.labels.grupy_tab = “Grupy”;
scheduler.locale.labels.wykladowcy_tab = “Wykładow.”;
scheduler.locale.labels.section_time=“Czas”;
scheduler.locale.labels.section_sala=“Sala”;
scheduler.locale.labels.section_przedmiot=“Przedmiot”;
scheduler.locale.labels.section_wykladowca=“Wykładowca”;
scheduler.locale.labels.section_szkola=“Szkoła”;
scheduler.locale.labels.section_komentarz=“Komentarz”;
scheduler.locale.labels.section_grupa=“Grupa”;

	scheduler.config.first_hour = 7;
	scheduler.config.last_hour = 22;
	scheduler.config.start_on_monday = true;

	scheduler.config.event_duration = 90; //specify event duration in minutes for auto end time
	scheduler.config.auto_end_date = true;
	
	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:"przedmiot", height:23, type:"select", options:scheduler.serverList("przedmiot_id"), map_to:"przedmiot_id" },
		{name:"sala", height:23, type:"select", options:scheduler.serverList("sala_id"), map_to:"sala_id" },
		{name:"wykladowca", height:23, type:"select", options:scheduler.serverList("wykladowca_id"), map_to:"wykladowca_id" },
		{name:"grupa", height:23, type:"select", options:scheduler.serverList("grupa_id"), map_to:"grupa_id" },
		{name:"szkola", height:23, type:"select", options:scheduler.serverList("szkola_id"), map_to:"szkola_id" },
		{name:"komentarz", height:130, map_to:"komentarz", type:"textarea" , focus:true},
		{name:"time", height:72, type:"time", map_to:"auto"}
	]
	
	scheduler.createUnitsView({
		name:"unit",
		property:"sala_id",
		list:scheduler.serverList("sala_id"),
		size:12,
		step:5
	});
	
	scheduler.createUnitsView({
		name:"grupy",
		property:"grupa_id",
		list:scheduler.serverList("grupa_id"),
		size:10,
		step:5
	});
	
	scheduler.createUnitsView({
		name:"wykladowcy",
		property:"wykladowca_id",
		list:scheduler.serverList("wykladowca_id"),
		size:10,
		step:5
	});
	
	scheduler.config.multi_day = true;

	scheduler.init('scheduler_here',new Date(),"unit");
	
	scheduler.load("inc/slowniki.php");
	
	var dp = new dataProcessor("inc/connector_write.php");
	
	dp.attachEvent("onFullSync", function(){
		scheduler.load("inc/slowniki.php");
	});
	
	dp.live_updates("http://172.16.1.11:8008/sync");
	
	dp.init(scheduler);
			
	scheduler.addMarkedTimespan({  
		days:  [1,2,3,4,5,6,7],               // marks each Friday
		zones: [9*60+30,9*60+45, 11*60+15,11*60+30, 13*60,13*60+15, 14*60+45,15*60, 16*60+30,16*60+45, 18*60+15,18*60+30],
		css:   "przerwa"   // the applied css style
	});
	scheduler.updateView();[/code]

I am using Scheduler v40 std 130813

Event color depends on ‘szkola’ section, and event text depends on ‘przedmiot’, ‘sala’, ‘wykladowca’, ‘grupa’.

When I update another event the previously updated event starts displaying properly (color and text gets updated).

You have in code the next line

dp.attachEvent("onFullSync", function(){ scheduler.load("inc/slowniki.php"); });

As result after data saving the next order of event occurs

  • data saved in DB
  • after saving response received
  • fullsync event triggered
  • data loading started (because of the above event)
  • live update sends the event as it is in the browser to all other clients
  • returns data from the load command
  • refresh data from load command ( server side data )
  • returns data from live update sync
  • refresh data from live update sync ( client side data )

So the data is updated from DB first and after that refreshed once more because of live update. As live update fires before data loading callback, it sync the original, not affected by server side code, data.

To fix the issue you can change the logic of data updating, instead of calling scheduler.load you can include the values which need to be updated in the server side response for data saving, and use onAfterUpdate event to fetch those extra details and apply them to the event.

Thank you for the answer. I don’t fully understand the way it works. Shouldn’t live update fetch the data from DB? When live update is fired the data in DB is already updated. I don’t understand the fix method you gave me. Could you explain what exactly should I change?

LiveUpdate feature synchronizes not the data from the database, it sync the changed client side data between all clients. Normally the client side data is the same as server side data - so there is no difference which one to sync.

In you case you need to disable live-updates or update the data on client in onAfterUpdate callback instead of separate .load call.