Tried almost everything but still not working. When I click the save button the id of the new row is submitted to server but data does not go as per firebug (debugger in Firefox)
here is the full dhtml client side function
<script src="codebase/dhtmlxcommon.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="codebase/dhtmlxlayout.css">
<link rel="stylesheet" type="text/css" href="codebase/skins/dhtmlxlayout_dhx_blue.css">
<script src="codebase/dhtmlxlayout.js"></script>
<script src="codebase/dhtmlxtoolbar.js"></script>
<link rel="stylesheet" type="text/css" href="codebase/skins/dhtmlxtoolbar_dhx_blue.css">
<script src="codebase/dhtmlxgrid.js" type="text/javascript"></script>
<script src="codebase/dhtmlxgridcell.js" type="text/javascript"></script>
<link rel="STYLESHEET" type="text/css" href="codebase/dhtmlxgrid.css">
<link rel="stylesheet" type="text/css" href="codebase/skins/dhtmlxgrid_dhx_blue.css">
<!-- The order of inclusion below is impt -->
<script src="codebase/dhtmlxdataprocessor.js"></script>
<script src="codebase/dhtmlxcontainer.js"></script>
<script language="JavaScript">
<!--
var dhxLayout,dhxT1,dhxT2,mygrid1,mygrid2,myDP,wgrp;
wgrp='';
function setpage()
{
dhxLayout = new dhtmlXLayoutObject(document.body, "2E","dhx_blue");
dhxLayout.cells("a").setText("Workgroups");
dhxLayout.cells("b").setText("Define WorkStatus Types");
dhxT1 = dhxLayout.cells("a").attachToolbar();
dhxT1.setSkin("dhx_blue");
dhxT1.setIconsPath("./pics/");
dhxT1.addButton("addw",1,"New","addwg.gif","addwg.gif");
dhxT1.setItemToolTip("addw","Create new workgroup");
dhxT1.addButton("savew",2,"Save","save.gif","saved.gif");
dhxT1.setItemToolTip("savew","Save all workgroup changes");
dhxT1.addSeparator("spa",3);
dhxT1.addButton("openw",4,"Show Leave","infog.gif","infog.gif");
dhxT1.setItemToolTip("savew","Show leave for selected workgroup");
dhxT1.attachEvent("onClick", function(id){
switch(id)
{
case 'addw' : adw();
break;
case 'savew': savw();
break;
case 'openw': openw();
break;
};
});
dhxT2 = dhxLayout.cells("b").attachToolbar();
dhxT2.setSkin("dhx_blue");
dhxT2.setIconsPath("./pics/");
dhxT2.addButton("addh",1,"New","addwg.gif","addwg.gif");
dhxT1.attachEvent("onClick", function(id){
switch(id)
{
case 'addh': addlv();
break;
};
});
mygrid1=dhxLayout.cells("a").attachGrid(); //Workgroup listing
mygrid2=dhxLayout.cells("b").attachGrid(); // leave definition
mygrid1.setImagePath("codebase/imgs/");
mygrid2.setImagePath("codebase/imgs/");
mygrid1.setHeader("Name,Comp-Off Eligible,Year Starts On");
mygrid1.setColAlign("left,center,left");
mygrid1.setColSorting("str,na,str");
mygrid1.setInitWidths("120,120,*");
mygrid1.setColTypes("ed,ch,co");
mygrid1.setSkin("light");
var combo = mygrid1.getCombo(2);
combo.put('0','Joining Date');
combo.put('1','January');
combo.put('2','February');
combo.put('3','March');
combo.put('4','April');
combo.put('5','May');
combo.put('6','June');
combo.put('7','July');
combo.put('8','August');
combo.put('9','September');
combo.put('10','October');
combo.put('11','November');
combo.put('12','December');
myDP = new dataProcessor("wg.php");
myDP.setDataColumns([true, true, true]);
myDP.setTransactionMode("POST", true);
myDP.setUpdateMode("off");
myDP.init(mygrid1);
myDP.setVerificator(0, v_wgn);
myDP.styles = {
updated: "font-style:italic; color:green;",
inserted: "font-weight:bold; color:blue;",
deleted: "font-weight:bold; color:red;",
invalid: "color:orange; text-decoration:none;",
error: "color:red; text-decoration:none;",
clear: "font-weight:normal;text-decoration:none;"
};
//myDP.enableDataNames(true);
myDP.attachEvent("onValidatationError", function(id, messages) {
alert(messages.join("\n"));
return false;
//confirm block
});
mygrid1.init();
mygrid1.loadXML("wgview.php");
dhxLayout.cells("b").collapse();
mygrid2.setHeader("Abbreviation,Name,Leave Counter,Quantity,Applicable for,Carry-Fwd p.a,Workgroup");
mygrid2.setColTypes("ed,ed,co,ed,co,ed,ro");
mygrid2.setSkin("light");
mygrid2.setColAlign("center,left,center,center,left,center,left");
mygrid2.setColSorting("str,str,str,int,str,int,str");
mygrid2.init();
mygrid2.loadXML("lwgview.php");
var lc = mygrid2.getCombo(2);
lc.put('0','No change');
lc.put('-1','Decrease by 1');
var sx = mygrid2.getCombo(4);
sx.put('M','Male only');
sx.put('F','Female only');
sx.put('ALL','Everyone');
};
function v_wgn(value, id, ind) {
rv=true;
cnt=0;
if (value == "" && ind==0) return "Please specify a Workgroup name. It cannot be null";
mygrid1.forEachRow(function(rid){
if(rid != id && mygrid1.cells(rid,0).getValue().toLowerCase()==value.toLowerCase()) rv="The Workgroup already exists and cannot be recreated" ;
});
return rv;
};
function addlv()
{
//add leave data
if(wgrp=='') alert("Please select a Workgroup to add leave type");
else mygrid2.addRow(mygrid2.uid(),['','','-1','1','ALL','0',wgrp]);
};
function adw()
{
mygrid1.addRow(mygrid1.uid(),['','0','0']);
};
function openw()
{
mygrid2.clearAll();
i=mygrid1.getSelectedRowId();
if(i==null)
{
alert("ERROR: No workgroup selected\nPlease select a workgroup to see leave details");
return;
}else
{
wgrp=mygrid1.cells(i,0).getValue();
mygrid2.loadXML("lwgview.php?wid="+wgrp);
};
dhxLayout.cells("b").expand();
};
function savw()
{
myDP.sendData();
};
-->
</script>
</head>
<body onLoad="setpage()">
…and the server side of the page where the grid data is submitted.
<?
require_once('auth.inc.php');
adminchk();
require("grid_connector.php");
$gridConn = new GridConnector($con,"MySQL");
if ($gridConn->is_select_mode())
$gridConn->render_sql("select id,name,cof,start_mnth from wg_def where disabled=0","id","name,cof,start_mnth");
else
$gridConn->render_table("wg_def","id","name,cof,start_mnth");
function my_update($data){
$name=$data->get_value("name");
$id=$data->get_value("id");
$cof=$data->get_value("cof");
$sd=$data->get_value("start_mnth");
$gridConn->sql->query("UPDATE wg_def SET name='" . $name. "',cof=" . $cof . ",start_mnth=" . $sd . " where id=" . $id );
$data->success(); //mark operation as finished
} ;
function my_insert($data){
$name=$data->get_value("name");
$cof=$data->get_value("cof");
$sd=$data->get_value("start_mnth");
if(mysql_result(mysql_query("select count(*) from wg_def where name='". $name ."'"),0)==0){
$gridConn->sql->query("insert into wg_def(name,cof,start_mnth) values('" . $name . "'," . $cof . "," . $sd . ")");
$data->success(); //mark operation as finished
}else{
$data->invalid();
};
} ;
function canceldel($action){
$action->invalid(); //deletion not allowed
};
function validate($data){
if ($data->get_value("name")=="")
$data->invalid();
};
$gridConn->event->attach("beforeUpdate","my_update");
$gridConn->event->attach("beforeDelete","canceldel");
$gridConn->event->attach("beforeProcessing","validate");
$gridConn->event->attach("beforeInsert","my_insert");
?>
Thanks guys for all time and help. Grid looks very difficult when it comes to customized integration with server to me