Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Jeremy on Oct 29, 2009 08:11
open dhtmlx forum
dataprocessor and scheduler

Hi

I'm trying to detect concurrency issues where two people update one record. I'm doing this with a timestamp in the database. What I want to do is send back the new timestamp value in the returned XML like this

<data><action type="updated " sid="7050" tid="7050" ts="12345"></action></data>

and then have access to the xml in the "onEventChanged" event.

is this possible?

Regards

Jeremy
Answer posted by Alex (support) on Oct 30, 2009 04:00
Hello,

If you use connectors, it is possible set afterUpdate event handler:

function
doAfterProcessing($action){
$action->set_response_attribute("ts","12345");
}
$gridConn->event->attach("afterProcessing",doAfterProcessing);

The details can be found here:
http://www.dhtmlx.com/dhxdocs/doku.php?id=dhtmlxconnector:dataaction_object

The attributes can be got on the client-side using defineAction method of dataprocessor:
dp.defineAction("update",function(node){
alert(node.getAttribute("ts"));
return true;
})
The article about this approach is
http://www.dhtmlx.com/dhxdocs/doku.php?id=dhtmlxdataprocessor:custom_server_side_responses
Answer posted by Jeremy on Oct 30, 2009 06:29

Hi

I'm using perl at the server end.

This works but does need some global data

Jeremy

 

var lastxml

scheduler.locale.labels.workweek_tab = "W-Week"

//load stuff

scheduler.config.xml_date="%Y-%m-%dT%H:%i";

scheduler.init('scheduler_here',null,"week");

scheduler.setLoadMode("month");

//scheduler.load("events.xml");

scheduler.load("ajax/entries.cgi");

myDataProcessor = new dataProcessor("ajax/test.cgi"); //lock feed url

//myDataProcessor.enableDebug(true);

myDataProcessor.init(scheduler); //link dataprocessor to the scheduler

myDataProcessor.defineAction("updated",function(tag){

//will need this later in after update...

lastxml = tag

return true;

});

 

...

scheduler.attachEvent("onEventChanged", function(event_id,event_object){

alert("changed");

event_object.ts = lastxml.getAttribute("ts");

//alert (event_object.ts)

})

 

Answer posted by Alex (support) on Oct 30, 2009 07:01
You can set a new property of updated event directly in the update handler:
dp.defineAction("update",function(node){
var id = node.getAttribute("sid");
var event = scheduler.getEvent(id);
event.ts = node.getAttribute("ts");
return true;
})


Answer posted on Oct 30, 2009 07:38

Hi

very good. thats much clearer

Thanks

Jeremy