Hello,
I created a very simple web application where I am using Grid and Form with a php connector and a dataProcessor (using the same connector).
I am able to add new records in my database but when I try deleting one it just doesn’t happen, it’s crossed-out and removed from my Grid but not from the database table.
As you can see below I don’t really use my whole Form yet, just the buttons.
Any thoughts?
My html file:
[code]
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="STYLESHEET" type ="text/css" href="dhtmlxSuite/dhtmlxGrid/codebase/dhtmlxgrid.css">
<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">
<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/ext/dhtmlxgrid_srnd.js"></script>
<script src="dhtmlxSuite/dhtmlxDataProcessor/codebase/dhtmlxdataprocessor.js"></script>
<script src="dhtmlxSuite/dhtmlxDataProcessor/codebase/dhtmlxdataprocessor_debug.js"></script>
<script src="dhtmlxSuite/dhtmlxConnector_php/codebase/connector.js"></script>
<script src="dhtmlxSuite/dhtmlxForm/codebase/dhtmlxcommon.js"></script>
<script src="dhtmlxSuite/dhtmlxForm/codebase/dhtmlxform.js"></script>
mygrid = new dhtmlXGridObject("gridbox");
mygrid.setImagePath("dhtmlxSuite/dhtmlxGrid/codebase/imgs/");
mygrid.setHeader("First Name,Last Name");
mygrid.setInitWidths("200,*");
mygrid.setColTypes("ed,ed"); //editable,editable
mygrid.setSkin("dhx_skyblue");
mygrid.init();
mygrid.enableSmartRendering(true);
mygrid.loadXML("connector.php");
var mydp = new dataProcessor("connector.php");
mydp.init(mygrid);
var myForm, formData;
initForm();
function initForm() {
formData = [
{type:"settings",position:"label-top"},
{type: "fieldset",name:"form", label: "Εγγραφή", list:[
{type: "input", name: 'firstName', label: 'First name:'},
{type:"input", name:"lastName", label:"Last Name:", position:"label-top"},
{type:"button", name:"submit", value:"Υποβολή"},
{type:"button", name:"delete", value:"Διαγραφή"}
]}
];
myForm = new dhtmlXForm("form_container", formData);
//myForm.bind(mygrid);
myForm.attachEvent("onButtonClick", function(id){
if(id=="submit"){
var new_id = mygrid.uid();
mygrid.addRow(new_id, "Tralala, Tralalo",0);
}
else if(id=="delete"){
var selectedItem = mygrid.getSelectedRowId();
mygrid.deleteRow(selectedItem);
}
});
}
</script>
[/code]
My connector:
[code]<?php
require_once(“dhtmlxSuite/dhtmlxConnector_php/codebase/grid_connector.php”);
$conn = mysql_connect(““,”“,”***”);
mysql_select_db(“****”);
$grid = new GridConnector($conn,“MySQL”);
$grid->dynamic_loading(1000);
$grid->enable_log(“log.txt”, true);
//
if($grid->is_select_mode())
$grid->render_sql(“SELECT firstname, lastname FROM employee”,“employee_id”, “firstname,lastname”);
else
$grid->render_table(“employee”, “employee_id”, “firstname,lastname”);
?>[/code]
My log:
====================================
Log started, 21/08/2012 03:08:15
SELECT firstname, lastname FROM employee LIMIT 0,1000
SELECT COUNT(*) as DHX_COUNT FROM employee
Done in 0.17958378791809s
====================================
Log started, 21/08/2012 03:08:19
DataProcessor object initialized
1345557435x6_gr_id => 1345557435x6
1345557435x6_c0 => Tralala
1345557435x6_c1 => Tralalo
1345557435x6_!nativeeditor_status => deleted
ids => 1345557435x6
Row data [1345557435x6]
employee_id => 1345557435x6
firstname => Tralala
lastname => Tralalo
!nativeeditor_status => deleted
DELETE FROM employee WHERE employee_id
=‘1345557435x6’
Edit operation finished
0 => action:deleted; sid:1345557435x6; tid:1345557435x6;
Done in 0.11796998977661s