Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Bert on Jan 09, 2009 04:56
open dhtmlx forum
dataprocessor setOnAfterUpdate

The function dhxDataProcessor.setOnAfterUpdate isn't being executed and I can't see why it wouldn't.

Code snippet :

//load grid in layout
    dhxGrid = dhxLayout.cells("c").attachGrid();
    dhxGrid.setImagePath/grid_codebase/imgs/");
    dhxGrid.enableDistributedParsing(true, 20, 50);
    
    //load dataprocessor
    dhxDataProcessor = new dataProcessor("dpgrid.php");
    dhxDataProcessor.setTransactionMode("POST");
    dhxDataProcessor.init(dhxGrid);
    
    //set OnAfterUpdate Event
dhxDataProcessor.setOnAfterUpdate(function(){ alert("single row updated"); });

When I change a cell value it is perfectly update in the database but the event is not fired.

What is wrong ?
Answer posted by dhxSupport on Jan 09, 2009 08:04
Function defined by setOnAfterUpdate will be called only when
a) valid response received ( valid XML )
b) xml contains<action type="delete", <action type="delete", <action type="insert",  <action type="update", it may not be called in case of custom action type 
Answer posted by Bert on Jan 12, 2009 00:58

a) and b) are forefilled but it doesn't fire.

Full code :

test.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" type="text/css" href../grid_codebase/dhtmlxgrid.css" />
<link rel="stylesheet" type="text/css" href../grid_codebase/skins/dhtmlxgrid_dhx_blue.css" />     

<script src../grid_codebase/dhtmlxcommon.js"></script>
<script src../grid_codebase/dhtmlxgrid.js"></script>
<script src../grid_codebase/dhtmlxgridcell.js"></script>

<script src../codebase_dataprocessor/dhtmlxdataprocessor.js"></script>
<script src../codebase_dataprocessor/dhtmlxdataprocessor_debug.js"></script>

<script>
var dhxGrid;
var dhxDataProcessor;
</script>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<div id="gridbox" style="width:800px;height:600px;"></div>
<script>
//load grid
dhxGrid = new dhtmlXGridObject('gridbox');
dhxGrid.setImagePath("../grid_codebase/imgs/");
dhxGrid.init();
dhxGrid.load("grid.php?gid=33059&time="+new Date().valueOf());

//load dataprocessor
dhxDataProcessor = new dataProcessor("update.php");
dhxDataProcessor.setTransactionMode("POST");
dhxDataProcessor.enableDataNames(true);
dhxDataProcessor.enableDebug(false);
dhxDataProcessor.init(dhxGrid);
 
dhxDataProcessor.setOnAfterUpdate(function(){
alert("OnAfterUpdate");
});

</script>
</body>
</html>


update.php

//set content type and xml tag
if(stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml"))
 header("Content-type: application/xhtml+xml");
else
 header("Content-type: text/xml");
print("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");

print("<!-- response xml -->\n");
print("<data>\n\t");
print("<action type='update' sid='".$_POST["gr_id"]."' tid='".$_POST["gr_id"]."'/>");
print("</data>");

Answer posted by Support on Jan 12, 2009 03:10
Please try to include attached js file in addition to dhtmlxdataprocessor.js and if issue still occurs - provide content of debug console. 
Attachments (1)
Answer posted by Bert on Jan 12, 2009 03:21

ok now

Problem was in my dhtmlxdataprocessor_debug.js file on line 63 : if (!atag || !atag.tagName) return that._log("Not a XML");

Your attached js file doesn't have this line.

Thanks for the support.