Hello,
I have a grid which seems to be working fine when inserting, deleting, updating, BUT , when a new row is inserted and the grid updated, then the column ‘ID’ which is supposed to display the newly generated MySQL id for the table is still empty.
If I reload the grid then the ID is displayed properly.
I notice similar behavior with fields that have default values, after saving the grid the row is not repopulated with the values currently in the database.
In the following example, the column “isactive” has a default value of 0 , “durationdays” also default value 0 , nothing is shown in the grid after saving.
Finally , after the grid is saved , I check that there is only one request to the server, but the “onAfterUpdate” event is fired as many times as the rows that were updated. Is there any way to only fire the event once?
mygrid = new dhtmlXGridObject('grShows');
mygrid.setImagePath("../dhtmlx/codebase/imgs/");
mygrid.setHeader("ID,Description,Days Duration,Active,Registration Open,Registration Close"); //sets the headers of columns
mygrid.setColumnIds("id,description,durationdays,isactive,registration_open,registration_close"); //sets the columns' ids
mygrid.setInitWidths("50,250,100,100,200,*"); //sets the initial widths of columns
mygrid.setColAlign("left,left,left,left,left,left"); //sets the alignment of columns
mygrid.setColTypes("ro,ed,ed,ch,ed,ed"); //sets the types of columns
mygrid.setColSorting("str,str,str,str,str,str"); //sets the sorting types of columns
mygrid.init();
mygrid.load("data/shows.php");
dpf = new dataProcessor("data/shows.php");
dpf.setUpdateMode("off");
dpf.init(mygrid);
dpf.attachEvent("onAfterUpdate", function(sid, action, tid){
if (action == "error")
{
alert("There was an error:"+node.firstChild.data);
} else {
alert('Data saved!');
}
});
shows.php
require("../../dhtmlx/connector/grid_connector.php");
require("../../dhtmlx/connector/db_mysqli.php");
$mysqli = new mysqli('localhost', 'user', 'pass', 'mytestdb');
mysqli_set_charset($mysqli,"utf8");
$gridConn = new GridConnector($mysqli,"MySQLi");
$gridConn->render_table("shows","id","id,description,durationdays,isactive,registration_open,registration_close");