Hi! Abu.
I see this question:
https://phpgrid.desk.com/customer/portal/questions/16261098-set-default-values-with-js
But I want make "default values" the result of a sqlcommand (last record saved, for a SaveAndNext edit dialog form).
With this:
$grid["add_options"]["closeAfterAdd"] =false;
mantains opened the edit dialog.I need set the default values for a few fields of the form.
How can I do it?
Thanks.
To get query data on client side is not doable now and will need manual work.
What you can do is to remove these fields from dialog and add them silently by fetching from query in callback function e.g. on_insert or on_update.
Refer demos/editing/custom-events.php for demo code.
Hi,
Finally I decided to use variable session to determinate default values without SaveAndContinue button.
In "on_insert" and "on_update", session variables take the values:
$_SESSION["hfin"] = substr($data["params"]["t_horafin"],11,8); $_SESSION["fecha"] = substr($data["params"]["t_fecha"],8,2) . "/" . substr($data["params"]["t_fecha"],5,2) . "/" . substr($data["params"]["t_fecha"],0,4);
, and in column definition I use it:
//time column (Hour
if (isset($_SESSION["hfin"])) {
$col["editoptions"] = array("defaultValue"=>$_SESSION["hfin"]);
}else{
$col["editoptions"] = array("defaultValue"=>'00:00');
}
//date column
if (isset($_SESSION["fecha"])) {
$col["editoptions"] = array("defaultValue"=>$_SESSION["fecha_denis"]);
}
But, after insert, only refresh data on grid, default values aren't asigned to columns. Pressinf F5 to reload page, default values are applied fine. Can I force to reload it?
Thanks.
If you want to refresh page, you can set:
$opt["onAfterSave"] = "location.reload();";
$g->set_options($opt);
$opt["onAfterSave"] = "location.reload();";
works fine in inline editing.
I've tried:
$opt["edit_options"]["afterSubmit"] = "location.reload();";
$opt["add_options"]["afterSubmit"] = "location.reload();";
but It doesn't works.
How can I force reload page when Add/Edit dialog form is closed?
Thanks