Saving scheduler event

Good day,

We have been looking for a client-side scheduler to purchase, and we found the dhtmlxscheduler a very good one that we can use on our website. But we are using a NoSQL database as our data store, and I have seen the dhtmlxscheduler allows exporting data to json, but would it be possible only to save, update, or delete only the event being modified, using the db-less saving? It seems that using scheduler.toJson() would always give the entire scheduler data, which would be a problem for us due to performance.

Thank you very much.

Hello,

toJSON method is rather simple and you can modify it (or even write new one) which will do the same but to a single event.

Or even better, here’s updated version (change the one in dhtmlxscheduler_serialization.js):

scheduler.toJSON = function(id){ var json = []; var attrs = this.data_attributes(); var evs = this._events; if(id && this.getEvent(id)) { evs = { id: this.getEvent(id) }; } for (var a in evs){ var ev = evs[a]; if (ev.id.toString().indexOf("#")!=-1) continue; var line =[]; for (var i=0; i < attrs.length; i++) line.push(' "'+attrs[i][0]+'": "'+((attrs[i][1]?attrs[i][1](ev[attrs[i][0]]):ev[attrs[i][0]])||"").toString().replace(/\n/g,"")+'" '); json.push("{"+line.join(",")+"}"); } return "["+json.join(",\n")+"]"; };
Kind regards,
Ilya

Good day sir,

Sorry, but I’m a little bit confused. I only want to be able to push create/update/delete one event at a time. Do I just call the code example you gave, and pass in the id of the event to create, update, or delete?

Thank you very much.

Hello,

I provided the updated version, where you can pass event_id and it will return JSON for that particular event. After that you most likely want to create AJAX request to your server script and use generated JSON there.
Please note that dhtmlxScheduler includes dhtmlxAjax library.

Kind regards,
Ilya