Hi to everybody…
I try to use DataProcessor and when I try to edit a column in datagrid I’ve this error, and nothing happens.
Thanks
My HTML is:
[code]
Venditori
</div>
<link rel="STYLESHEET" type="text/css" href="../dhtmlxSuite/dhtmlxGrid/codebase/skins/dhtmlxgrid_dhx_skyblue.css">
<link rel="STYLESHEET" type="text/css" href="../dhtmlxSuite/dhtmlxForm/codebase/skins/dhtmlxform_dhx_skyblue.css">
<link rel="STYLESHEET" type="text/css" href="../dhtmlxSuite/dhtmlxCalendar/codebase/skins/dhtmlxcalendar_dhx_skyblue.css">
<script src="../dhtmlxSuite/dhtmlxGrid/codebase/dhtmlxcommon.js"></script>
<script src="../dhtmlxSuite/dhtmlxGrid/codebase/dhtmlxgrid.js"></script>
<script src="../dhtmlxSuite/dhtmlxGrid/codebase/dhtmlxgridcell.js"></script>
<script src="../dhtmlxSuite/dhtmlxGrid/codebase/dhtmlxgrid_srnd.js"></script>
<script src="../dhtmlxSuite/dhtmlxGrid/codebase/excells/dhtmlxgrid_excell_dhxcalendar.js"></script>
<script src="../dhtmlxSuite/dhtmlxCalendar/codebase/dhtmlxcalendar.js"></script>
<script src="../dhtmlxSuite/dhtmlxForm/codebase/dhtmlxform.js"></script>
<script src="../dhtmlxSuite/dhtmlxConnector/dhtmlxdataprocessor.js"></script>
<script src="../dhtmlxSuite/dhtmlxConnector/gridconnector.js"></script>
<div id="gridbox" style="width:450px; height:160px; background-color:white;"></div>
<div id="box-append" style="width:450px; height:100px; background-color:white;"></div>
<script>
var mygrid = new dhtmlXGridObject('gridbox');
mygrid.setImagePath("../dhtmlxSuite/dhtmlxGrid/codebase/imgs/");
mygrid.setHeader("Nominativo");
mygrid.setInitWidths("*")
mygrid.setColAlign("left")
mygrid.setColSorting("str")
mygrid.setSkin("dhx_skyblue")
mygrid.init();
//—grid initialization
//mygrid.loadXML(“…/dhtmlxSuite/dhtmlxGrid/common/grid_dates.xml”);
mygrid.loadXML(“data.php”);
//mygrid.load(“data.php”);//populates the grid with data from the DB
//—dataProcessor initialization
var mydp = new dataProcessor (“data.php”);// object constructor. Here you should specify a connector file
mydp.init(mygrid); // initializes dataProcessor. As the parameter you should specify your grid
//—form initialization. We will initialize form to add ‘Add’, ‘Delete’ buttons
formData = [
{type: “button”, offsetTop: 10, name:“add”, value:“Add”},
{type:“newcolumn”},
{type: “button”, offsetTop: 10, name:“delete”, value:“Delete”}
];
var myForm = new dhtmlXForm(“box-append”,formData);
//—handlers for buttons’ clicks
myForm.attachEvent(“onButtonClick”, function(id){
if( id==“delete”){
var selectedItem = mygrid.getSelectedRowId();// gets an id of the selected row
mygrid.deleteRow(selectedItem);// deletes a row with the specified id
}
else if (id==‘add’){
var new_id=mygrid.uid()// gets an unique id
mygrid.addRow(new_id, “new book”, 0);// adds a new record.
}
});
<div style="clear:both;"></div>
<div class="code" id="code">
</body>
[/code]
My data.php is:
[code]<?php
require_once(“…/dhtmlxSuite/dhtmlxConnector/grid_connector.php”);// includes the appropriate connector
$res=mysql_connect(“localhost”,“root”,“”);//connects to a server that contains the desired DB
mysql_select_db(“my_phenotype”);// connects to the DB. ‘tasks’ is the name of our DB
$conn = new GridConnector($res,“MySQL”);// connector initialization
$conn->render_table(“car_venditori”,“IdVenditore”,“Nominativo”);// data configuration
?>[/code]
My database is
CREATE TABLE IF NOT EXISTS `car_venditori` (
`IdVenditore` int(4) NOT NULL AUTO_INCREMENT,
`ScontoVenditore` int(3) DEFAULT NULL,
`Nominativo` varchar(40) DEFAULT NULL,
`DataNasc` date DEFAULT NULL,
`Indirizzo` varchar(45) DEFAULT NULL,
`Comune` varchar(30) DEFAULT NULL,
`Provincia` varchar(2) DEFAULT NULL,
`CAP` varchar(6) DEFAULT NULL,
`CodFisc` varchar(16) DEFAULT NULL,
PRIMARY KEY (`IdVenditore`),
KEY `IdVenditore` (`IdVenditore`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;