Hi! i need some help…
(no pro version)
I’ve 2 Grids connected to the same Table (by a render_sql)
Double click in one = copy row + add one field ( i just need to add 1 field(idCurso) to the same id)
Table: alumno
rut
nombre
apellido
direccion
sexo
idCurso
1st Grid (show all where idCurso is empty)
//Grid Alumnos sin Curso
mateqGrid = layout.cells("a").attachGrid();
mateqGrid.setHeader("rut,nombre,apellido,direccion,sexo,idCurso");
mateqGrid.setInitWidths("100,170,170,*,150,100");
mateqGrid.setColAlign("left,left,left,left,left,left");
mateqGrid.setColTypes("ro,ro,ro,ro,ro,ro");
mateqGrid.setColSorting("str,str,str,str,str,str");
mateqGrid.attachHeader("#text_filter,#text_filter,#text_filter,#text_filter,#select_filter,#text_filter");
mateqGrid.init();
mateqGrid.load("recursos/gridMostrarAlumnos.php?bdcol=<?php echo $_GET['bdcol'] . '&idCurso=' . $_GET['idCurso'];?>");
//DataProcessor para Grid
var dpg = new dataProcessor ("recursos/gridMostrarAlumnos.php?bdcol=<?php echo $_GET['bdcol'] . '&idCurso=' . $_GET['idCurso'];?>");
dpg.setUpdateMode("off");
dpg.init(mateqGrid);
//Eventos Grid Alumnos sin Curso
mateqGrid.attachEvent("onRowDblClicked", function(rId,cInd){
var newId=dhtmlx.uid();
mateqGrid2.addRow(newId,[(mateqGrid.cellById(rId,0).getValue()),(mateqGrid.cellById(rId,1).getValue()),(mateqGrid.cellById(rId,2).getValue()),(mateqGrid.cellById(rId,3).getValue()),(mateqGrid.cellById(rId,4).getValue()),<?php echo $_GET['idCurso'];?>],0);
var selectedItem = mateqGrid.getSelectedRowId();
mateqGrid.deleteRow(selectedItem);
});
gridMostrarAlumnos.php
<?php
require("../codebase/connector/grid_connector.php");
$res=mysql_connect("localhost","root","12345");
$bdcol=$_GET['bdcol'];
$idCurso=$_GET['idCurso'];
mysql_select_db($bdcol);
$gridConn = new GridConnector($res,"MySQL");
$gridConn->enable_log("alumnosincurso.log");
$gridConn->render_sql("SELECT * FROM alumno WHERE idCurso=''","rut","rut,nombre,apellido,direccion,sexo,idCurso");
?>
2nd Grid (show all where idCurso = $idCurso)
//Grid Alumnos en Curso
mateqGrid2 = layout.cells("b").attachGrid();
mateqGrid2.setHeader("rut,nombre,apellido,direccion,sexo,idCurso");
mateqGrid2.setInitWidths("100,170,170,*,150,100");
mateqGrid2.setColAlign("left,left,left,left,left,left");
mateqGrid2.setColTypes("ro,ro,ro,ro,ro,ro");
mateqGrid2.setColSorting("str,str,str,str,str,str");
mateqGrid2.attachHeader("#text_filter,#text_filter,#text_filter,#text_filter,#select_filter,#text_filter");
mateqGrid2.init();
mateqGrid2.load("recursos/gridMostrarCursoAlumnos.php?bdcol=<?php echo $_GET['bdcol'] . '&idCurso=' . $_GET['idCurso'];?>");
//DataProcessor para Grid
var dpg2 = new dataProcessor ("recursos/gridMostrarCursoAlumnos.php?bdcol=<?php echo $_GET['bdcol'] . '&idCurso=' . $_GET['idCurso'];?>");
dpg2.setUpdateMode("off");
dpg2.init(mateqGrid2);
gridMostrarCursoAlumnos.php
<?php
require("../codebase/connector/grid_connector.php");
$res=mysql_connect("localhost","root","12345");
$bdcol=$_GET['bdcol'];
$idCurso=$_GET['idCurso'];
mysql_select_db($bdcol);
$gridConn = new GridConnector($res,"MySQL");
$gridConn->enable_log("alumnoconcurso.log");
$gridConn->render_sql("SELECT * FROM alumno WHERE idCurso='$idCurso'","rut","rut,nombre,apellido,direccion,sexo,idCurso");
?>
sendData()
toolbar.attachEvent("onClick",function(id){
if(id=="saveProd"){
dpg2.sendData();
}
});
The problem is when i save, dataprocessor try to insert a new record, but i just need to UPDATE the same with 1 more field.
how can i do it? (