Hello,
I'm trying to obtain the "id" on update, but when I tried to access the variable return "<a href= ".
Could you help me to fix it?
Thank you.
Code:
$col = array();
$col["title"] = "id"; // caption of column, can use HTML tags too
$col["name"] = "id"; // grid column name, same as db field or alias from sql
$col["width"] = "5"; // width on grid
$col["hidden"] = false;
$col["editable"] = false;
$col["viewable"] = true;
$col["link"] = "action.php?action=document&idCase={id}";
$cols[] = $col;
$e["on_update"] = array("update_case", null, false);
$grid->set_events($e);
function update_case($data) {
global $grid, $table;
$handle = fopen("temp.txt", "w");
foreach ($data["params"] as $key => $value) {
fwrite($handle, "Nombre: $key Valor: $value n");
}
fwrite($handle,$data["id"]);
fclose($handle);
}
Ok. If I comment this line:
$col["link"] = "action.php?action=document&idCase={id}";
the problem disappear. But I want to use this link in the column. Do you know how to fix it?
Thank you.
You can create 2 column.
First with non-link and second with link.
and make first column as hidden:true.
First column is used in update so it will fix the query.
And second column will only be visible for your purpose.
I tried something like that:
$col = array();
$col["title"] = "id"; // caption of column, can use HTML tags too
$col["name"] = "id"; // grid column name, same as db field or alias from sql
$col["width"] = "5"; // width on grid
$col["hidden"] = true;
$col["editable"] = false;
$col["viewable"] = false;
$cols[] = $col;
$col = array();
$col["title"] = "X"; // caption of column, can use HTML tags too
$col["name"] = "id"; // grid column name, same as db field or alias from sql
$col["width"] = "5"; // width on grid
$col["hidden"] = false;
$col["editable"] = false;
$col["viewable"] = true;
$col["link"] = "acciones.php?accion=generardocumento&idCaso={id}";
$cols[] = $col;
It's replicate the link in the two colums.
Ok,
Try selecting this column in sql_command with different alias.=
e.g.
select id, id as id_link, ….
And name first column as id and second as id_link.