Hi Abu,
I have a field to capture the last modified DateTime, this works fine but the current datetime value will only change when the html page is reloaded. After an update/insert/delete or clicking the in-grid refresh button the datetime value doesn’t change. I’ve tried to use an event to reload the page but it’s throwing a 404 error. Any clues? Thanks mate.
MY COLUMN CODE WHICE CREATES A DROPDOWN WITH A SINGLE ENTRY
$col = array();
$col[“title”] = “<p class=’rotate’>Last Modified Datetime</p>”;
$col[“name”] = “disd_lastmodifieddatetime”;
$col[“fixed”] = true;
$col[“editable”] = true;$col[“width”] = “120”;
$col[“align”] = “center”;
$col[“edittype”] = “select”;
$str = date(“Y-m-d H:i:s”).’|’.date(“Y-m-d H:i:s”);
$col[“editoptions”] = array(“value” => $str, “separator” => “|”, “delimiter” => “;”);
$col[“formatter”] = “datetime”;
$col[“formatoptions”] = array(“srcformat”=>’Y-m-d H:i:s’,”newformat”=>’d/m/Y H:i:s’);
$cols[] = $col;
THE EVENT CODE I TRIED BUT NOT WORKING
$e[“on_after_insert”] = array(“after_insert”, null, true);
$g->set_events($e);
function after_insert($data){
location.reload();
}
Hello,
If you wish to save last modified time while add/update operations, you can use build in mysql feature.
https://dev.mysql.com/doc/refman/8.0/en/timestamp-initialization.html
I really don’t understand how and where you are going to save update time on deleting that row.
Hi Abu,
Thank you very much, I never thought to do it like that but it’s quite obvious now. I’ve been able to get it to work by changing $col[“editable”] = false in the grids lastmodifieddatetime field and setting the DATETIME field in the database to have default value “CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP”
This works as intended, thanks.
Matt