Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Todd Kazakov on Jun 04, 2009 08:59
open dhtmlx forum
Grid + DataProcessor + Connector

Hi,
We are interested in buying the pro version of the product, but we are not sure if it will satisfy our needs and we wanted to try it first.
With the free version I am not able to update/add/delete any rows.

Here is what is in the js file:

var myGrid, dp;
function doInitGrid(){

// Initialising the grid
myGrid = new dhtmlXGridObject('gridbox');
myGrid.setImagePath("../grid/imgs/");
myGrid.setHeader("Id,Ref,Name,Telephone,Fax,E-Mail,Web Page");
myGrid.setColumnIds("id,ref,name,tel,fax,email,www")
myGrid.setInitWidths("60,100,*,100,100,150,150");
myGrid.setColAlign("left,left,left,left,left,left,left");
myGrid.setSkin("light");
myGrid.init();
myGrid.loadXML("suppliers_test_controller.php");

// Initialising the data processor (needed for add/update/delete)
dp = new dataProcessor("suppliers_test_controller.php");
dp.init(myGrid);
dp.enableDebug(true);

// Set auto-update off
//dp.setUpdateMode("off");

//use column IDs instead of column indexes naming request parameters
dp.enableDataNames(true);

//set error handler (handler for action with type "error")
dp.defineAction("error",myErrorHandler);

}

function myErrorHandler($obj){
alert("Error occured.\n"+obj.firstChild.nodeValue);
dp.stopOnError = true;
return false;
}


===============
In the connector file:
include("../includes/connection_manager_default.php");

include("../connector/grid_connector.php");
$grid = new GridConnector($res);
$grid->enable_log("temp2.log",true);
$grid->dynamic_loading(100);
$grid->render_table("tblsuppliers","tblSupplier_ID","tblSupplier_ID,tblSupplier_Ref,tblSupplier_Name,tblSupplier_tel,tblSupplier_fax,tblSupplier_Email,tblSupplier_WWW");

Can you help me to resolve the problem?
Thanks in Advance
Answer posted by Support on Jun 04, 2009 09:44
a) because you are not using smart-rendering or paging modes , the next line has not sense 
          $grid->dynamic_loading(100); 

b) all commands after dp.init need to be removed from your client side code, the next two commands are enough to activate dataprocessor and attach it to server side connector
          dp = new dataProcessor("suppliers_test_controller.php"); 
          dp.init(myGrid); 
( by the way, which sample you are using as a base? connectors package contains few samples of grid usage and none of them has such code used ) 

c) please be sure that connectors.js included and loaded after other js file.

Answer posted on Jun 04, 2009 18:38
It is working now and I really like it. It is really simple and there is no need of complicated queries. The problem was with the include of the connector.js
Do I need to take for escaping the " and ' characters with add slashes?
Answer posted by Support on Jun 05, 2009 02:43

>>Do I need to take for escaping the " and ' characters with add slashes?
No any extra escaping required.
When loading data from server to client - data wrapped is CDATA section, so it can contain any content.
When sending data from client to server - all data automatically url-encoded before sending.