editable and I don't want update it

Questionseditable and I don't want update it
Cristian Engelmann asked 2 months ago

Hi Abu,

I need a litle push!

The case is

$col = array();
$col[“title”] = “Cant.<br>hay”;
$col[“name”] = “cantidadhay”;
$col[“width”] = “6”;
$col[“align”] = “right”;
$col[“formatter”] = “number”;
$col[“formatoptions”] = array(“prefix” => ”,”suffix” => ”,”thousandsSeparator” => ‘.’,”decimalSeparator” => ‘,’,”decimalPlaces” => 0);

$col[“editable”] = true;
$col[“editrules”][“readonly”] = true;

$cols[] = $col;

and when press save

The message is “Couldn’t execute query. Unknown column ‘cantidadhay’ in ‘field list’ – UPDATE guiadespachoventadetalletmp SET `cantidadhay`=’3′,`cantidad`=’3′ WHERE n_item IN (‘5’)”

I don´t want to update ‘cantidadhay’ only I want to read it.The `cantidad`=’3′ is Ok update.

I would appreciate your help

2 Answers
Abu Ghufran Staff answered 1 month ago

Hello,

You can have an on_update event handler and remove it from query after postback. e.g.

$e["on_update"] = array("update_data", null, true);
$g->set_events($e);

function update_data($data)
{
	unset($data["cantidadhay"]);
}

 

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Cristian Engelmann answered 1 month ago

Hi Abu,

Thank you

But I have to add I use the method

$grid = new jqgrid($db_conf);
$opt[“caption”] = “Detalle Orden de Compra”;
$opt[“sortname”] = ‘descripcion’;
$opt[“sortorder”] = “asc”;
$opt[“width”] = “667”;
$opt[“height”] = “185”;

$opt[“edit_options”][“beforeSubmit”] = “function(post,form){ return validate_form_once(post,form); }”;
$opt[“edit_options”][“afterSubmit”] = “function(){ sumacompragrilla();return [true,”];}”;
$opt[“edit_options”][“reloadAfterSubmit”]=false;

and below in javascrit

function validate_form_once(post,form)
{
var str=[];

if (parseFloat(post.stock_minimo) <= 0)
str[str.length] = “Stock mínimo debe ser mayor a 0”;
else
if (parseFloat(post.stock_minimo) > parseFloat(post.stock_maximo))
str[str.length] = “Stock mínimo debe ser menor a ” + post.stock_maximo + ” ,stock máximo.”;
else
if (parseFloat(post.reposicion) > parseFloat(post.stock_maximo))
str[str.length] = “Reposición debe ser menor a ” + post.stock_maximo + ” ,stock máximo.”;
else
if (parseFloat(post.stock_minimo) > parseFloat(post.reposicion))
str[str.length] = “Stock mínimo debe ser menor a ” + post.reposicion + ” ,Reposición.”;
else
if (parseFloat(post.cantidad) > parseFloat(post.cantidad_sucursal))
str[str.length] = “Cantidad debe ser menor o igual a ” + post.cantidad_sucursal + ” ,Sucursal origen.”;
else
if (parseFloat(post.cantidad) < 0)
str[str.length] = “La compra debe ser mayor a 0”;
else
if (parseFloat(post.cantidad) <= parseFloat(post.hay))// I DON’T WANT TO UPDATE THIS FIELD post.hay
str[str.length] = “Cantidad debe ser menor o igual a ” + post.hay + ” ,Stock.”;

str = str.join(“<br>”);

if (str.length == 0)
return [true,””];
else
return [false,”Revise el siguiente problema:<br>” + str];
}

I appreciate your help

Your Answer

1 + 18 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 5 / 5. Vote count: 1

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?