We have a page that uses a grid as an input component. It is set for manual update so that when the user enters several rows of data in the grid, they click a button that is suppose to add the rows as new records in the database. The problem is that the system matches the rowid in the grid with the existing record id in the database and updates, or changes, the existing record with the data from the grid. If the rowid of the grid does not match any database record id, the record is not added to the database. We need the rows in the grid to be appended (added) to the database as new records with their own unique id (id is set as auto-increment in the database).
Our code that sets the dataprocessor for manual update is:
var mydpgrid = new dataProcessor(‘php/bl_gridDetail.php’);
mydpgrid.setTransactionMode(“POST”,true);
mydpgrid.setUpdateMode(“off”);
mydpgrid.init(mygrid);
The code that sets a button to manually add grid rows to database is:
[b]var submitButton = new dhtmlXForm(“footer”,formDatafooter);
submitButton.attachEvent(“onButtonClick”,function(id){
for (var rowId=0; rowId<mygrid.getRowsNum(); rowId++){
mygrid.forEachRow(function(rowId){
mydpgrid.setUpdated(rowId,true);
mydpgrid.sendData(rowId);
})
}
});[/b]
The php code that is used is:
[b]<?php
require_once("…/…/…/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php");
$conn = mysql_connect(“localhost”,“root”,"");
mysql_select_db(“billoflading”); // Database name
$gridConn = new GridConnector($conn);
$gridConn>render_table("blproddetail","id","BL_num,Qty,Item,Lot_num,Unit,Haz,
ProductDescription,Weight");
?>[/b]
We would appreciate any guidance or insights to solving this problem.